From 5d774e62cb3dd44af1c5fe82ac4c79c91560d748 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 14 Sep 2020 20:45:00 +0100 Subject: [PATCH] Refactored config versions --- .../java/com/willfp/ecoenchants/EcoEnchantsPlugin.java | 10 ---------- .../com/willfp/ecoenchants/config/ConfigManager.java | 8 ++++++++ .../java/com/willfp/ecoenchants/config/YamlConfig.java | 2 +- .../com/willfp/ecoenchants/display/EnchantDisplay.java | 2 +- .../java/com/willfp/ecoenchants/loader/Loader.java | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java b/Plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java index 90e193d2..81b94f00 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java @@ -12,16 +12,6 @@ import java.util.HashMap; public class EcoEnchantsPlugin extends JavaPlugin { private static EcoEnchantsPlugin instance; - /** - * Config versions for config.yml and lang.yml - */ - public static final HashMap configVersions = new HashMap() {{ - put("config", 5.0); - put("lang", 5.0); - put("target", 1.0); - put("rarity", 1.0); - }}; - /** * Is the plugin outdated */ diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java index c36eab24..9d785548 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java @@ -2,10 +2,18 @@ package com.willfp.ecoenchants.config; import com.willfp.ecoenchants.config.configs.*; +import java.util.HashMap; import java.util.HashSet; import java.util.Set; public class ConfigManager { + public static final HashMap configVersions = new HashMap() {{ + put("config", 5.0); + put("lang", 5.0); + put("target", 1.0); + put("rarity", 1.0); + }}; + private static final Lang LANG = new Lang(); private static final Config CONFIG = new Config(); private static final Target TARGET = new Target(); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/YamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/YamlConfig.java index 2ccfd6bc..850e1113 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/YamlConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/YamlConfig.java @@ -52,7 +52,7 @@ public abstract class YamlConfig { } private void checkVersion() { - double latestVersion = EcoEnchantsPlugin.configVersions.get(this.name); + double latestVersion = ConfigManager.configVersions.get(this.name); if (latestVersion != config.getDouble("config-version")) { Bukkit.getLogger().warning("EcoEnchants detected an older or invalid " + name + ".yml. Replacing it with the default config..."); Bukkit.getLogger().warning("If you've edited the config, copy over your changes!"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java index 7558141b..e100b7b6 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -204,7 +204,7 @@ public class EnchantDisplay { name = enchantment.getName(); description = EcoEnchants.getFromEnchantment(enchantment).getDescription(); EnchantmentRarity rarity = EcoEnchants.getFromEnchantment(enchantment).getRarity(); - if(rarity.hasCustomColor()) { + if(rarity.hasCustomColor() && type != EcoEnchant.EnchantmentType.CURSE) { color = rarity.getCustomColor(); } description.replaceAll(line -> prefix + descriptionColor + line); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/loader/Loader.java b/Plugin/src/main/java/com/willfp/ecoenchants/loader/Loader.java index 9d94dd5a..fa814002 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/loader/Loader.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/loader/Loader.java @@ -285,7 +285,7 @@ public class Loader { } else { Bukkit.getLogger().info(EnchantmentRarity.getAll().size() + " Rarities Loaded:"); EnchantmentRarity.getAll().forEach((rarity -> { - Bukkit.getLogger().info("- " + rarity.getName() + ": Table Probability=" + rarity.getProbability() + ", Minimum Level=" + rarity.getMinimumLevel() + ", Villager Probability=" + rarity.getVillagerProbability() + ", Loot Probability=" + rarity.getLootProbability()); + Bukkit.getLogger().info("- " + rarity.getName() + ": Table Probability=" + rarity.getProbability() + ", Minimum Level=" + rarity.getMinimumLevel() + ", Villager Probability=" + rarity.getVillagerProbability() + ", Loot Probability=" + rarity.getLootProbability() + ", Has Custom Color=" + rarity.hasCustomColor()); })); Bukkit.getLogger().info("");