From ff9973a95e45fe0141c9bec8b31d3ab4b4f83b71 Mon Sep 17 00:00:00 2001 From: rlnt Date: Thu, 22 Aug 2024 22:31:16 +0200 Subject: [PATCH] rename sanitizing to implicit count handling --- .../almostreliable/unified/utils/JsonCompare.java | 15 ++++++--------- testmod_configs/duplicates.json | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Common/src/main/java/com/almostreliable/unified/utils/JsonCompare.java b/Common/src/main/java/com/almostreliable/unified/utils/JsonCompare.java index ce78c17..3691a2b 100644 --- a/Common/src/main/java/com/almostreliable/unified/utils/JsonCompare.java +++ b/Common/src/main/java/com/almostreliable/unified/utils/JsonCompare.java @@ -103,7 +103,7 @@ public final class JsonCompare { if (secondElem == null) return false; // sanitize elements for implicit counts of 1 - if (compareSettings.shouldSanitize && needsSanitizing(firstElem, secondElem)) { + if (compareSettings.handleImplicitCounts && needsSanitizing(firstElem, secondElem)) { firstElem = sanitize(firstElem); secondElem = sanitize(secondElem); } @@ -262,13 +262,14 @@ public final class JsonCompare { } public static class CompareSettings { + public static final String IGNORED_FIELDS = "ignored_fields"; public static final String RULES = "rules"; - public static final String SHOULD_SANITIZE = "should_sanitize"; + public static final String HANDLE_IMPLICIT_COUNTS = "handle_implicit_counts"; private final LinkedHashMap rules = new LinkedHashMap<>(); private final Set ignoredFields = new HashSet<>(); - private boolean shouldSanitize; + private boolean handleImplicitCounts; public void ignoreField(String property) { ignoredFields.add(property); @@ -282,10 +283,6 @@ public final class JsonCompare { } } - public void setShouldSanitize(boolean shouldSanitize) { - this.shouldSanitize = shouldSanitize; - } - public Set getIgnoredFields() { return Collections.unmodifiableSet(ignoredFields); } @@ -303,7 +300,7 @@ public final class JsonCompare { }); result.add(RULES, rulesJson); - result.addProperty(SHOULD_SANITIZE, shouldSanitize); + result.addProperty(HANDLE_IMPLICIT_COUNTS, handleImplicitCounts); return result; } @@ -322,7 +319,7 @@ public final class JsonCompare { addRule(e.getKey(), r); }); - shouldSanitize = json.getAsJsonPrimitive(SHOULD_SANITIZE).getAsBoolean(); + handleImplicitCounts = json.getAsJsonPrimitive(HANDLE_IMPLICIT_COUNTS).getAsBoolean(); } public Map getRules() { diff --git a/testmod_configs/duplicates.json b/testmod_configs/duplicates.json index b27864e..33d0a7b 100644 --- a/testmod_configs/duplicates.json +++ b/testmod_configs/duplicates.json @@ -15,7 +15,7 @@ "energy": "HigherRule", "experience": "HigherRule" }, - "should_sanitize": false + "handle_implicit_counts": false }, "override_duplicate_rules": { "minecraft:crafting_shaped": { @@ -28,7 +28,7 @@ "group" ], "rules": {}, - "should_sanitize": false + "handle_implicit_counts": false } }, "compare_all": false