From 99f3861ad3d766bd22bb551bfe89eb4ceb89907b Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 10 Oct 2020 12:49:23 +0100 Subject: [PATCH] EcoEnchant names are now loadable from lang.yml --- .../ecoenchants/command/commands/CommandEnchantinfo.java | 2 +- .../ecoenchants/config/configs/EnchantmentConfig.java | 9 +++++++++ .../com/willfp/ecoenchants/display/EnchantDisplay.java | 4 ++-- .../com/willfp/ecoenchants/enchantments/EcoEnchant.java | 1 + Plugin/src/main/resources/lang.yml | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java index a4ae34f6..277438ed 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java @@ -81,7 +81,7 @@ public final class CommandEnchantinfo extends AbstractCommand { if(EcoEnchants.getFromEnchantment(enchantment1) != null) { conflictNames.add(EcoEnchants.getFromEnchantment(enchantment1).getName()); } else { - conflictNames.add(ConfigManager.getLang().getString("vanilla." + enchantment1.getKey().getKey() + ".name")); + conflictNames.add(ConfigManager.getLang().getString("enchantments." + enchantment1.getKey().getKey() + ".name")); } })); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java index 4cd28db7..1309a1df 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java @@ -1,5 +1,6 @@ package com.willfp.ecoenchants.config.configs; +import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.config.EnchantmentYamlConfig; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; @@ -98,4 +99,12 @@ public class EnchantmentConfig extends EnchantmentYamlConfig { return targets; } + + public void loadFromLang() { + if(!ConfigManager.getLang().config.contains("enchantments." + this.getName())) + return; + + config.set("name", ConfigManager.getLang().getString("enchantments." + this.getName() + ".name")); + config.set("description", ConfigManager.getLang().getString("enchantments." + this.getName() + ".description")); + } } 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 9e8f3e2f..8715eb51 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -82,7 +82,7 @@ public final class EnchantDisplay { description = Arrays.asList( WordUtils.wrap( - String.valueOf(ConfigManager.getLang().getString("vanilla." + enchantment.getKey().getKey().toLowerCase() + ".description")), + String.valueOf(ConfigManager.getLang().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".description")), ConfigManager.getConfig().getInt("lore.describe.wrap"), "\n", false ).split("\\r?\\n")); @@ -218,7 +218,7 @@ public final class EnchantDisplay { if(!EcoEnchants.getFromEnchantment(enchantment).isEnabled()) forRemoval.add(enchantment); } else { - name = ConfigManager.getLang().getString("vanilla." + enchantment.getKey().getKey() + ".name"); + name = ConfigManager.getLang().getString("enchantments." + enchantment.getKey().getKey() + ".name"); } if(!(enchantment.getMaxLevel() == 1 && level == 1)) { 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 1fa67835..43d9ad40 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java @@ -59,6 +59,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist * Update the enchantment based off config values */ public void update() { + config.loadFromLang(); rarity = config.getRarity(); conflicts = config.getEnchantments(EcoEnchants.GENERAL_LOCATION + "conflicts"); grindstoneable = config.getBool(EcoEnchants.GENERAL_LOCATION + "grindstoneable"); diff --git a/Plugin/src/main/resources/lang.yml b/Plugin/src/main/resources/lang.yml index f2944b9c..57831fd9 100644 --- a/Plugin/src/main/resources/lang.yml +++ b/Plugin/src/main/resources/lang.yml @@ -30,7 +30,7 @@ artifact-color: "&e" description-color: "&8" -vanilla: +enchantments: protection: name: "Protection" description: Reduces most types of damage.