diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java index 05f7545c..b93223cf 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEnchantinfo.java @@ -52,7 +52,7 @@ public class CommandEnchantinfo extends AbstractCommand { if (enchantment == null) { String finalSearchName = searchName; - enchantment = EcoEnchants.values().stream().filter(ecoEnchant -> ChatColor.stripColor(ecoEnchant.getName()).equalsIgnoreCase(finalSearchName)).findFirst().orElse(null); + enchantment = EcoEnchants.values().stream().filter(ecoEnchant -> ChatColor.stripColor(ecoEnchant.getDisplayName()).equalsIgnoreCase(finalSearchName)).findFirst().orElse(null); } if (enchantment == null || !enchantment.isEnabled()) { @@ -74,7 +74,7 @@ public class CommandEnchantinfo extends AbstractCommand { conflicts.forEach((enchantment1 -> { if (EcoEnchants.getFromEnchantment(enchantment1) != null) { - conflictNames.add(EcoEnchants.getFromEnchantment(enchantment1).getName()); + conflictNames.add(EcoEnchants.getFromEnchantment(enchantment1).getDisplayName()); } else { conflictNames.add(this.getPlugin().getLangYml().getString("enchantments." + enchantment1.getKey().getKey() + ".name")); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java index fc4bb9a2..034e6751 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/tabcompleters/TabCompleterEnchantinfo.java @@ -20,7 +20,7 @@ public class TabCompleterEnchantinfo extends AbstractTabCompleter { /** * The cached enchantment names. */ - private static final List ENCHANT_NAMES = EcoEnchants.values().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getName).map(ChatColor::stripColor).collect(Collectors.toList()); + private static final List ENCHANT_NAMES = EcoEnchants.values().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getDisplayName).map(ChatColor::stripColor).collect(Collectors.toList()); /** * Instantiate a new tab-completer for /enchantinfo. @@ -37,7 +37,7 @@ public class TabCompleterEnchantinfo extends AbstractTabCompleter { @ConfigUpdater public static void reload() { ENCHANT_NAMES.clear(); - ENCHANT_NAMES.addAll(EcoEnchants.values().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getName).map(ChatColor::stripColor).collect(Collectors.toList())); + ENCHANT_NAMES.addAll(EcoEnchants.values().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getDisplayName).map(ChatColor::stripColor).collect(Collectors.toList())); } /** diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java index 6e882e34..0bda3d61 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java @@ -103,7 +103,7 @@ public class EnchantmentCache { if (EcoEnchants.getFromEnchantment(enchantment) != null) { EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment); description = ecoEnchant.getWrappedDescription(); - name = ecoEnchant.getName(); + name = ecoEnchant.getDisplayName(); type = ecoEnchant.getType(); rarity = ecoEnchant.getRarity(); } else { diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java index e545369a..dbff7815 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java @@ -43,84 +43,102 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche */ @Getter(AccessLevel.PROTECTED) private final EcoEnchantsPlugin plugin = EcoEnchantsPlugin.getInstance(); + /** * The permission/config name of the enchantment. */ @Getter private final String permissionName; + /** * The type of the enchantment. */ @Getter private final EnchantmentType type; + /** * The enchantment's config. */ @Getter private final EnchantmentConfig config; + /** * The targets of the enchantment. */ @Getter private final Set targets = new HashSet<>(); + /** * The materials of the targets. */ @Getter private final Set targetMaterials = new HashSet<>(); + /** * The names of the worlds that this enchantment is disabled in. */ @Getter private final Set disabledWorldNames = new HashSet<>(); + /** * The worlds that this enchantment is disabled in. */ @Getter private final List disabledWorlds = new ArrayList<>(); + /** * The display name of the enchantment. */ - private String name; + @Getter + private String displayName; + /** * The description of the enchantment. */ @Getter private String description; + /** * If the enchantment can be removed in a grindstone. */ @Getter private boolean grindstoneable; + /** * If the enchantment can be obtained from an enchanting table. */ @Getter private boolean availableFromTable; + /** * If the enchantment can be obtained from a villager. */ @Getter private boolean availableFromVillager; + /** * If the enchantment can be obtained from a loot chest. */ @Getter private boolean availableFromLoot; + /** * The maximum level for the enchantment to be obtained naturally. */ private int maxLevel; + /** * The enchantments that conflict with this enchantment. */ @Getter private Set conflicts; + /** * The rarity of the enchantment. */ @Getter private EnchantmentRarity rarity; + /** * If the enchantment is enabled. */ @@ -187,7 +205,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche availableFromVillager = config.getBool(EcoEnchants.OBTAINING_LOCATION + "villager"); availableFromLoot = config.getBool(EcoEnchants.OBTAINING_LOCATION + "loot"); maxLevel = config.getInt(EcoEnchants.GENERAL_LOCATION + "maximum-level", 1); - name = StringUtils.translate(config.getString("name")); + displayName = StringUtils.translate(config.getString("name")); description = StringUtils.translate(config.getString("description")); disabledWorldNames.clear(); disabledWorldNames.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "disabled-in-worlds")); @@ -223,7 +241,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche Map byKey = (Map) byIdField.get(null); Map byName = (Map) byNameField.get(null); byKey.remove(this.getKey()); - byName.remove(this.getName()); + byName.remove(this.getDisplayName()); Map byNameClone = new HashMap<>(byName); for (Map.Entry entry : byNameClone.entrySet()) { @@ -271,16 +289,15 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche } /** - * Get the display name of the enchantment. - *

- * Not deprecated, unlike superclass. + * Get the internal name of the enchantment. * * @return The name. + * @deprecated Exists for parity. */ - @Override @NotNull + @Deprecated public String getName() { - return name; + return this.getKey().getKey().toUpperCase(); } /** diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java index b981f8f9..42b21dbd 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java @@ -592,7 +592,7 @@ public class EcoEnchants { BY_KEY.remove(enchant.getKey()); BY_NAME.inverse().remove(enchant); BY_KEY.put(enchant.getKey(), enchant); - BY_NAME.put(enchant.getName(), enchant); + BY_NAME.put(enchant.getDisplayName(), enchant); } /**