From 86605352bed2d9a8b1f7cf6185499e39f3360a23 Mon Sep 17 00:00:00 2001 From: v_manijashvili Date: Sun, 26 Nov 2023 10:24:54 +0400 Subject: [PATCH] Posibility to ignore some enchantment from ItemStack Add configuration IGNORE_ENCHANT_ATTRIBUTE_FOR_SIMILARITY --- .../java/com/Acrobot/Breeze/Utils/MaterialUtil.java | 12 ++++++++++-- .../Acrobot/ChestShop/Configuration/Properties.java | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/Acrobot/Breeze/Utils/MaterialUtil.java b/src/main/java/com/Acrobot/Breeze/Utils/MaterialUtil.java index 58ea46d..003987c 100644 --- a/src/main/java/com/Acrobot/Breeze/Utils/MaterialUtil.java +++ b/src/main/java/com/Acrobot/Breeze/Utils/MaterialUtil.java @@ -137,10 +137,18 @@ public class MaterialUtil { if (oneMeta == twoMeta || oneMeta == null || twoMeta == null) { return oneMeta == twoMeta; } + Map oneSerMeta = new HashMap<>(oneMeta.serialize()); Map twoSerMeta = new HashMap<>(twoMeta.serialize()); - oneSerMeta.remove("repair-cost"); - twoSerMeta.remove("repair-cost"); + System.out.println("IGNORE LIST: "); + System.out.println(Properties.IGNORE_ENCHANT_ATTRIBUTE_FOR_SIMILARITY); + if (!Properties.IGNORE_ENCHANT_ATTRIBUTE_FOR_SIMILARITY.isEmpty()) { + for (String ignoreKey : Properties.IGNORE_ENCHANT_ATTRIBUTE_FOR_SIMILARITY) { + oneSerMeta.remove(ignoreKey); + twoSerMeta.remove(ignoreKey); + } + } + if (oneSerMeta.equals(twoSerMeta)) { return true; } diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java index cb2e7e7..493265f 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java @@ -18,6 +18,7 @@ import java.util.Locale; import java.util.Set; import java.util.UUID; import java.util.logging.Level; +import java.util.Collections; /** * @author Acrobot @@ -337,4 +338,10 @@ public class Properties { @PrecededBySpace @ConfigurationComment("Add stock counter to quantity line?") public static boolean USE_STOCK_COUNTER = false; + + @PrecededBySpace + @ConfigurationComment("Ignore enchantment attribute for similarity") + @Parser("StringSet") + public static Set IGNORE_ENCHANT_ATTRIBUTE_FOR_SIMILARITY = new LinkedHashSet<>(); + } \ No newline at end of file