diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/enchants/EcoCraftEnchantment.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/enchants/EcoCraftEnchantment.java index ae5858e4..a445720e 100644 --- a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/enchants/EcoCraftEnchantment.java +++ b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/enchants/EcoCraftEnchantment.java @@ -1,5 +1,6 @@ package com.willfp.ecoenchants.proxy.v1_16_R3.enchants; +import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata; import net.minecraft.server.v1_16_R3.Enchantment; import org.bukkit.NamespacedKey; @@ -25,6 +26,11 @@ public class EcoCraftEnchantment extends CraftEnchantment { return metadata.getMaxLevel() == null ? this.getHandle().getMaxLevel() : metadata.getMaxLevel(); } + @Override + public boolean conflictsWith(@NotNull final org.bukkit.enchantments.Enchantment other) { + return EcoEnchants.getFromEnchantment(other) == null ? super.conflictsWith(other) : other.conflictsWith(other); + } + public void register() { try { Field byIdField = org.bukkit.enchantments.Enchantment.class.getDeclaredField("byKey"); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java index 3371010d..239ec95c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java @@ -80,24 +80,26 @@ public class CommandRandomenchant extends AbstractCommand { for (EcoEnchant ecoEnchant : ecoEnchants) { if (ecoEnchant.canEnchantItem(itemStack)) { if (!ecoEnchant.conflictsWithAny(onItem)) { - if (onItem.stream().noneMatch(enchantment -> enchantment.conflictsWith(ecoEnchant))) { - if (!onItem.contains(ecoEnchant)) { - boolean conflicts = false; - for (Enchantment enchantment : onItem) { - if (EcoEnchants.getFromEnchantment(enchantment) != null) { - EcoEnchant ecoEnchantOnItem = EcoEnchants.getFromEnchantment(enchantment); - if (ecoEnchantOnItem.getType().equals(ecoEnchant.getType()) && ecoEnchantOnItem.getType().isSingular()) { - conflicts = true; + if (ecoEnchant.isEnabled()) { + if (onItem.stream().noneMatch(enchantment -> enchantment.conflictsWith(ecoEnchant))) { + if (!onItem.contains(ecoEnchant)) { + boolean conflicts = false; + for (Enchantment enchantment : onItem) { + if (EcoEnchants.getFromEnchantment(enchantment) != null) { + EcoEnchant ecoEnchantOnItem = EcoEnchants.getFromEnchantment(enchantment); + if (ecoEnchantOnItem.getType().equals(ecoEnchant.getType()) && ecoEnchantOnItem.getType().isSingular()) { + conflicts = true; + } } } - } - if (this.getPlugin().getConfigYml().getBool("anvil.hard-cap.enabled") - && !player.hasPermission("ecoenchants.randomenchant.bypasshardcap") - && onItem.size() >= this.getPlugin().getConfigYml().getInt("anvil.hard-cap.cap")) { - conflicts = true; - } - if (!conflicts) { - enchant = ecoEnchant; + if (this.getPlugin().getConfigYml().getBool("anvil.hard-cap.enabled") + && !player.hasPermission("ecoenchants.randomenchant.bypasshardcap") + && onItem.size() >= this.getPlugin().getConfigYml().getInt("anvil.hard-cap.cap")) { + conflicts = true; + } + if (!conflicts) { + enchant = ecoEnchant; + } } } }