Posibility to ignore some enchantment from ItemStack

Add configuration IGNORE_ENCHANT_ATTRIBUTE_FOR_SIMILARITY
This commit is contained in:
v_manijashvili 2023-11-26 10:24:54 +04:00
parent c7ee705012
commit 86605352be
2 changed files with 17 additions and 2 deletions

View File

@ -137,10 +137,18 @@ public class MaterialUtil {
if (oneMeta == twoMeta || oneMeta == null || twoMeta == null) {
return oneMeta == twoMeta;
}
Map<String, Object> oneSerMeta = new HashMap<>(oneMeta.serialize());
Map<String, Object> 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;
}

View File

@ -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<String> IGNORE_ENCHANT_ATTRIBUTE_FOR_SIMILARITY = new LinkedHashSet<>();
}