Skip to content

Commit

Permalink
[1.2.2] - Add version 1.2.1 to convert subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Aug 22, 2023
1 parent 6cb7261 commit 31dd086
Showing 1 changed file with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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));
}

Expand Down

0 comments on commit 31dd086

Please sign in to comment.