From 301cb085b8ebaaf609f391c5015f85240cb2f66b Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 5 May 2021 21:33:38 +0100 Subject: [PATCH] Hopefully fixed hard cap bypass --- .../support/merging/anvil/AnvilMerge.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 f8f2be83..219a3480 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 @@ -152,6 +152,14 @@ public class AnvilMerge { rightEnchants.remove(enchantment); } + if (PLUGIN.getConfigYml().getBool("anvil.hard-cap.enabled")) { + if (!player.hasPermission("ecoenchants.anvil.bypasshardcap")) { + if (outEnchants.size() >= PLUGIN.getConfigYml().getInt("anvil.hard-cap.cap")) { + return; + } + } + } + outEnchants.put(enchantment, level); })); @@ -182,10 +190,15 @@ public class AnvilMerge { canEnchantItem = true; } - if (canEnchantItem && !doesConflict.get()) { - if (PLUGIN.getConfigYml().getBool("anvil.hard-cap.enabled") && !player.hasPermission("ecoenchants.anvil.bypasshardcap") && outEnchants.size() >= PLUGIN.getConfigYml().getInt("anvil.hard-cap.cap")) { - return; + if (PLUGIN.getConfigYml().getBool("anvil.hard-cap.enabled")) { + if (!player.hasPermission("ecoenchants.anvil.bypasshardcap")) { + if (outEnchants.size() >= PLUGIN.getConfigYml().getInt("anvil.hard-cap.cap")) { + doesConflict.set(true); + } } + } + + if (canEnchantItem && !doesConflict.get()) { outEnchants.put(enchantment, integer); } }));