diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java index 6902056f..6caffb04 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java @@ -43,7 +43,7 @@ public abstract class EnchantmentYamlConfig { if(!basedir.exists()) basedir.mkdirs(); - File dir = new File(basedir, type.name().toLowerCase() + "/"); + File dir = new File(basedir, type.getName() + "/"); if (!dir.exists()) { dir.mkdirs(); } @@ -64,7 +64,7 @@ public abstract class EnchantmentYamlConfig { } private void saveResource(boolean replace) { - String resourcePath = "/enchants/" + type.name().toLowerCase() + "/" + name + ".yml"; + String resourcePath = "/enchants/" + type.getName() + "/" + name + ".yml"; InputStream in = source.getResourceAsStream(resourcePath); @@ -98,7 +98,7 @@ public abstract class EnchantmentYamlConfig { try { config.load(configFile); - String resourcePath = "/enchants/" + type.name().toLowerCase() + "/" + name + ".yml"; + String resourcePath = "/enchants/" + type.getName() + "/" + name + ".yml"; InputStream newIn = source.getResourceAsStream(resourcePath); BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java index de807705..c16f040c 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java @@ -436,28 +436,30 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist } public static class EnchantmentType { - public static final EnchantmentType NORMAL = new EnchantmentType(false, () -> ConfigManager.getLang().getString("not-curse-color")); - public static final EnchantmentType CURSE = new EnchantmentType(false, () -> ConfigManager.getLang().getString("curse-color")); - public static final EnchantmentType SPECIAL = new EnchantmentType(() -> !ConfigManager.getConfig().getBool("types.special.allow-multiple"), () -> ConfigManager.getLang().getString("special-color")); - public static final EnchantmentType ARTIFACT = new EnchantmentType(() -> !ConfigManager.getConfig().getBool("types.artifact.allow-multiple"), () -> ConfigManager.getLang().getString("artifact-color")); - public static final EnchantmentType SPELL = new EnchantmentType(true, () -> ConfigManager.getLang().getString("spell-color")); + public static final EnchantmentType NORMAL = new EnchantmentType("normal", false, () -> ConfigManager.getLang().getString("not-curse-color")); + public static final EnchantmentType CURSE = new EnchantmentType("curse", false, () -> ConfigManager.getLang().getString("curse-color")); + public static final EnchantmentType SPECIAL = new EnchantmentType("special", () -> !ConfigManager.getConfig().getBool("types.special.allow-multiple"), () -> ConfigManager.getLang().getString("special-color")); + public static final EnchantmentType ARTIFACT = new EnchantmentType("artifact", () -> !ConfigManager.getConfig().getBool("types.artifact.allow-multiple"), () -> ConfigManager.getLang().getString("artifact-color")); + public static final EnchantmentType SPELL = new EnchantmentType("spell", true, () -> ConfigManager.getLang().getString("spell-color")); private static final Set values = new HashSet<>(); private boolean singular; private String color; + private final String name; private final ObjectCallable colorCallable; private final ObjectCallable singularCallable; - public EnchantmentType(boolean singular, String color) { - this(() -> singular, () -> color); + public EnchantmentType(String name, boolean singular, String color) { + this(name, () -> singular, () -> color); } - public EnchantmentType(boolean singular, ObjectCallable colorCallable) { - this(() -> singular, colorCallable); + public EnchantmentType(String name, boolean singular, ObjectCallable colorCallable) { + this(name, () -> singular, colorCallable); } - public EnchantmentType(ObjectCallable singularCallable, ObjectCallable colorCallable) { + public EnchantmentType(String name, ObjectCallable singularCallable, ObjectCallable colorCallable) { + this.name = name; this.singularCallable = singularCallable; this.colorCallable = colorCallable; color = colorCallable.call(); @@ -478,6 +480,10 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist return singular; } + public String getName() { + return name; + } + public static void update() { values.forEach(EnchantmentType::refresh); }