mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-25 20:17:38 +01:00
Added color support to anvils
This commit is contained in:
parent
f5e34258a9
commit
0f91aa8a75
@ -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
|
||||
}
|
||||
|
@ -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<ItemStack, Integer> 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();
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user