From 31dd086c6e77b530d642ec586dbc197225168afb Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 22 Aug 2023 15:03:02 +0200 Subject: [PATCH] [1.2.2] - Add version 1.2.1 to convert subcommand --- .../subCommands/ConvertSubCommand.java | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/plugin/src/main/java/me/lucaaa/advanceddisplays/commands/subCommands/ConvertSubCommand.java b/plugin/src/main/java/me/lucaaa/advanceddisplays/commands/subCommands/ConvertSubCommand.java index 5c23808..41224ff 100644 --- a/plugin/src/main/java/me/lucaaa/advanceddisplays/commands/subCommands/ConvertSubCommand.java +++ b/plugin/src/main/java/me/lucaaa/advanceddisplays/commands/subCommands/ConvertSubCommand.java @@ -58,6 +58,7 @@ public void run(CommandSender sender, String[] args) { } else if (config.getString("item") != null) { config.set("type", DisplayType.ITEM.name()); settingsSection.set("item", config.getString("item")); + settingsSection.set("enchanted", false); settingsSection.set("itemTransformation", config.getString("itemTransformation")); config.set("item", null); config.set("itemTransformation", null); @@ -99,12 +100,19 @@ public void run(CommandSender sender, String[] args) { case "1.1" -> { for (File configFile : Objects.requireNonNull(new File(AdvancedDisplays.getPlugin().getDataFolder().getAbsolutePath() + File.separator + "displays").listFiles())) { YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); - if (DisplayType.valueOf(config.getString("type")) != DisplayType.TEXT) continue; + DisplayType type = DisplayType.valueOf(config.getString("type")); + if (type == DisplayType.BLOCK) continue; ConfigurationSection settingsSection = config.getConfigurationSection("settings"); - settingsSection.set("animationTime", 20); - settingsSection.set("refreshTime", 20); - settingsSection.set("text", List.of(settingsSection.get("text"))); + + if (type == DisplayType.TEXT) { + settingsSection.set("animationTime", 20); + settingsSection.set("refreshTime", 20); + settingsSection.set("text", List.of(settingsSection.get("text"))); + + } else if (type == DisplayType.ITEM) { + settingsSection.set("enchanted", false); + } try { config.save(configFile); @@ -117,11 +125,18 @@ public void run(CommandSender sender, String[] args) { case "1.2" -> { for (File configFile : Objects.requireNonNull(new File(AdvancedDisplays.getPlugin().getDataFolder().getAbsolutePath() + File.separator + "displays").listFiles())) { YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); - if (DisplayType.valueOf(config.getString("type")) != DisplayType.TEXT) continue; + DisplayType type = DisplayType.valueOf(config.getString("type")); + if (type == DisplayType.BLOCK) continue; ConfigurationSection settingsSection = config.getConfigurationSection("settings"); - settingsSection.set("animationTime", 20); - settingsSection.set("refreshTime", 20); + + if (type == DisplayType.TEXT) { + settingsSection.set("animationTime", 20); + settingsSection.set("refreshTime", 20); + + } else if (type == DisplayType.ITEM) { + settingsSection.set("enchanted", false); + } try { AdvancedDisplays.mainConfig.getConfig().set("text-update", null); @@ -133,6 +148,22 @@ public void run(CommandSender sender, String[] args) { } } + case "1.2.1" -> { + for (File configFile : Objects.requireNonNull(new File(AdvancedDisplays.getPlugin().getDataFolder().getAbsolutePath() + File.separator + "displays").listFiles())) { + YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); + if (DisplayType.valueOf(config.getString("type")) != DisplayType.ITEM) continue; + + ConfigurationSection settingsSection = config.getConfigurationSection("settings"); + settingsSection.set("enchanted", false); + + try { + config.save(configFile); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + default -> sender.sendMessage(MessagesManager.getColoredMessage("&b" + args[1] + " &cis not a valid version.", true)); }