EcoEnchant names are now loadable from lang.yml

This commit is contained in:
Auxilor 2020-10-10 12:49:23 +01:00
parent 045cd685f5
commit 99f3861ad3
5 changed files with 14 additions and 4 deletions

View File

@ -81,7 +81,7 @@ public final class CommandEnchantinfo extends AbstractCommand {
if(EcoEnchants.getFromEnchantment(enchantment1) != null) { if(EcoEnchants.getFromEnchantment(enchantment1) != null) {
conflictNames.add(EcoEnchants.getFromEnchantment(enchantment1).getName()); conflictNames.add(EcoEnchants.getFromEnchantment(enchantment1).getName());
} else { } else {
conflictNames.add(ConfigManager.getLang().getString("vanilla." + enchantment1.getKey().getKey() + ".name")); conflictNames.add(ConfigManager.getLang().getString("enchantments." + enchantment1.getKey().getKey() + ".name"));
} }
})); }));

View File

@ -1,5 +1,6 @@
package com.willfp.ecoenchants.config.configs; package com.willfp.ecoenchants.config.configs;
import com.willfp.ecoenchants.config.ConfigManager;
import com.willfp.ecoenchants.config.EnchantmentYamlConfig; import com.willfp.ecoenchants.config.EnchantmentYamlConfig;
import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
@ -98,4 +99,12 @@ public class EnchantmentConfig extends EnchantmentYamlConfig {
return targets; 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"));
}
} }

View File

@ -82,7 +82,7 @@ public final class EnchantDisplay {
description = description =
Arrays.asList( Arrays.asList(
WordUtils.wrap( 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"), ConfigManager.getConfig().getInt("lore.describe.wrap"),
"\n", false "\n", false
).split("\\r?\\n")); ).split("\\r?\\n"));
@ -218,7 +218,7 @@ public final class EnchantDisplay {
if(!EcoEnchants.getFromEnchantment(enchantment).isEnabled()) forRemoval.add(enchantment); if(!EcoEnchants.getFromEnchantment(enchantment).isEnabled()) forRemoval.add(enchantment);
} else { } 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)) { if(!(enchantment.getMaxLevel() == 1 && level == 1)) {

View File

@ -59,6 +59,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
* Update the enchantment based off config values * Update the enchantment based off config values
*/ */
public void update() { public void update() {
config.loadFromLang();
rarity = config.getRarity(); rarity = config.getRarity();
conflicts = config.getEnchantments(EcoEnchants.GENERAL_LOCATION + "conflicts"); conflicts = config.getEnchantments(EcoEnchants.GENERAL_LOCATION + "conflicts");
grindstoneable = config.getBool(EcoEnchants.GENERAL_LOCATION + "grindstoneable"); grindstoneable = config.getBool(EcoEnchants.GENERAL_LOCATION + "grindstoneable");

View File

@ -30,7 +30,7 @@ artifact-color: "&e"
description-color: "&8" description-color: "&8"
vanilla: enchantments:
protection: protection:
name: "Protection" name: "Protection"
description: Reduces most types of damage. description: Reduces most types of damage.