diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java index 32de8b03..3d09ba90 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java @@ -53,7 +53,6 @@ public class AnvilListeners extends PluginDependent implements Listener { ItemStack out = event.getResult(); String name = event.getInventory().getRenameText(); - if (event.getViewers().isEmpty()) { return; // Prevent ArrayIndexOutOfBoundsException when using AnvilGUI } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java index 937dd51e..047e52d1 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java @@ -1,5 +1,6 @@ package com.willfp.ecoenchants.enchantments.support.merging.anvil; +import com.willfp.eco.util.StringUtils; import com.willfp.eco.util.tuplets.Pair; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; @@ -39,17 +40,20 @@ public class AnvilMerge { * @param left The {@link ItemStack} on the left of the anvil. * @param right The {@link ItemStack} in the middle of the anvil. * @param old The previous {@link ItemStack} result. - * @param name The anvil display name. + * @param itemName The anvil display name. * @param player The player merging (for permissions). * @return The result, stored as a {@link Pair} of {@link ItemStack} and {@link Integer}. */ public Pair doMerge(@Nullable final ItemStack left, @Nullable final ItemStack right, @Nullable final ItemStack old, - @NotNull final String name, + @NotNull final String itemName, @NotNull final Player player) { // Here so it can be accessed later (scope) + // Copied to non-final string. + String name = itemName; + int outDamage = -1; if (old != null && old.getItemMeta() instanceof Damageable) { outDamage = ((Damageable) old.getItemMeta()).getDamage(); @@ -63,6 +67,12 @@ public class AnvilMerge { return new Pair<>(null, null); } + name = name.replace("ยง", "&"); + + if (player.hasPermission("ecoenchants.anvil.color")) { + name = StringUtils.translate(name); + } + if (!EnchantmentTarget.ALL.getMaterials().contains(left.getType()) || right == null || !EnchantmentTarget.ALL.getMaterials().contains(right.getType())) { ItemStack out = left.clone(); ItemMeta outMeta = out.getItemMeta(); diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index 0c097f75..82844827 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -50,6 +50,7 @@ permissions: default: op children: ecoenchants.anvil.bypasshardcap: true + ecoenchants.anvil.color: true ecoenchants.fromtable.*: description: Allows getting all enchantments from an enchanting table default: true @@ -69,6 +70,9 @@ permissions: ecoenchants.anvil.bypasshardcap: description: Allows bypassing the anvil hard cap default: op + ecoenchants.anvil.color: + description: Allows color from anvil renames + default: op # Perks ecoenchants.cooldowntime.half: