From 1ef8c7d0e5f434bd766ad473719ed64ff0205f76 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 5 Feb 2021 11:46:35 +0000 Subject: [PATCH] Fixed /randomenchant --- .../command/commands/CommandRandomenchant.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 fa718fde..0ce7078a 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 @@ -57,7 +57,20 @@ public class CommandRandomenchant extends AbstractCommand { if (ecoEnchant.canEnchantItem(itemStack)) { if (!ecoEnchant.conflictsWithAny(onItem)) { if (!onItem.stream().anyMatch(enchantment -> enchantment.conflictsWith(ecoEnchant))) { - enchant = 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 (!conflicts) { + enchant = ecoEnchant; + } + } } } }