Skip to content

Commit

Permalink
rename sanitizing to implicit count handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rlnt committed Aug 22, 2024
1 parent 448d2a9 commit ff9973a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static boolean matches(JsonObject first, JsonObject second, CompareSettin
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);
}
Expand Down Expand Up @@ -262,13 +262,14 @@ public String getName() {
}

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<String, Rule> rules = new LinkedHashMap<>();
private final Set<String> ignoredFields = new HashSet<>();
private boolean shouldSanitize;
private boolean handleImplicitCounts;

public void ignoreField(String property) {
ignoredFields.add(property);
Expand All @@ -282,10 +283,6 @@ public void addRule(String key, Rule rule) {
}
}

public void setShouldSanitize(boolean shouldSanitize) {
this.shouldSanitize = shouldSanitize;
}

public Set<String> getIgnoredFields() {
return Collections.unmodifiableSet(ignoredFields);
}
Expand All @@ -303,7 +300,7 @@ public JsonObject serialize() {
});
result.add(RULES, rulesJson);

result.addProperty(SHOULD_SANITIZE, shouldSanitize);
result.addProperty(HANDLE_IMPLICIT_COUNTS, handleImplicitCounts);

return result;
}
Expand All @@ -322,7 +319,7 @@ public void deserialize(JsonObject json) {
addRule(e.getKey(), r);
});

shouldSanitize = json.getAsJsonPrimitive(SHOULD_SANITIZE).getAsBoolean();
handleImplicitCounts = json.getAsJsonPrimitive(HANDLE_IMPLICIT_COUNTS).getAsBoolean();
}

public Map<String, Rule> getRules() {
Expand Down
4 changes: 2 additions & 2 deletions testmod_configs/duplicates.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"energy": "HigherRule",
"experience": "HigherRule"
},
"should_sanitize": false
"handle_implicit_counts": false
},
"override_duplicate_rules": {
"minecraft:crafting_shaped": {
Expand All @@ -28,7 +28,7 @@
"group"
],
"rules": {},
"should_sanitize": false
"handle_implicit_counts": false
}
},
"compare_all": false
Expand Down

0 comments on commit ff9973a

Please sign in to comment.