diff --git a/Common/src/main/java/com/almostreliable/unified/config/DuplicationConfig.java b/Common/src/main/java/com/almostreliable/unified/config/DuplicationConfig.java index eb0210e..09f82eb 100644 --- a/Common/src/main/java/com/almostreliable/unified/config/DuplicationConfig.java +++ b/Common/src/main/java/com/almostreliable/unified/config/DuplicationConfig.java @@ -16,12 +16,14 @@ public class DuplicationConfig extends Config { private final LinkedHashMap overrideRules; private final Set ignoreRecipeTypes; private final Set ignoreRecipes; + private final boolean strictMode; - public DuplicationConfig(JsonCompare.CompareSettings defaultRules, LinkedHashMap overrideRules, Set ignoreRecipeTypes, Set ignoreRecipes) { + public DuplicationConfig(JsonCompare.CompareSettings defaultRules, LinkedHashMap overrideRules, Set ignoreRecipeTypes, Set ignoreRecipes, boolean strictMode) { this.defaultRules = defaultRules; this.overrideRules = overrideRules; this.ignoreRecipeTypes = ignoreRecipeTypes; this.ignoreRecipes = ignoreRecipes; + this.strictMode = strictMode; } public boolean shouldIgnoreRecipe(RecipeLink recipe) { @@ -32,11 +34,16 @@ public class DuplicationConfig extends Config { return overrideRules.getOrDefault(type, defaultRules); } + public boolean isStrictMode() { + return strictMode; + } + public static class Serializer extends Config.Serializer { public static final String DEFAULT_DUPLICATE_RULES = "defaultDuplicateRules"; public static final String OVERRIDE_DUPLICATE_RULES = "overrideDuplicateRules"; public static final String IGNORED_RECIPE_TYPES = "ignoredRecipeTypes"; public static final String IGNORED_RECIPES = "ignoredRecipes"; + public static final String STRICT_MODE = "strictMode"; @Override public DuplicationConfig deserialize(JsonObject json) { @@ -54,8 +61,9 @@ public class DuplicationConfig extends Config { entry -> createCompareSet(entry.getValue().getAsJsonObject()), (a, b) -> b, LinkedHashMap::new)), new LinkedHashMap<>()); + boolean strictMode = safeGet(() -> json.get(STRICT_MODE).getAsBoolean(), false); - return new DuplicationConfig(defaultRules, overrideRules, ignoreRecipeTypes, ignoreRecipes); + return new DuplicationConfig(defaultRules, overrideRules, ignoreRecipeTypes, ignoreRecipes, strictMode); } private JsonCompare.CompareSettings defaultSet() { @@ -85,6 +93,7 @@ public class DuplicationConfig extends Config { overrides.add(rl.toString(), compareSettings.serialize()); }); json.add(OVERRIDE_DUPLICATE_RULES, overrides); + json.addProperty(STRICT_MODE, false); return json; } diff --git a/Common/src/main/java/com/almostreliable/unified/recipe/RecipeLink.java b/Common/src/main/java/com/almostreliable/unified/recipe/RecipeLink.java index caa9b14..988b8fb 100644 --- a/Common/src/main/java/com/almostreliable/unified/recipe/RecipeLink.java +++ b/Common/src/main/java/com/almostreliable/unified/recipe/RecipeLink.java @@ -135,7 +135,7 @@ public class RecipeLink { } if (selfDuplicate == null && otherDuplicate == null) { - RecipeLink compare = RecipeLink.compare(this, otherRecipe, compareSettings); + RecipeLink compare = compare(this, otherRecipe, compareSettings); if (compare == null) { return false; } @@ -147,7 +147,7 @@ public class RecipeLink { } if (otherDuplicate != null) { - RecipeLink compare = RecipeLink.compare(this, otherDuplicate.getMaster(), compareSettings); + RecipeLink compare = compare(this, otherDuplicate.getMaster(), compareSettings); if (compare == null) { return false; } @@ -157,7 +157,7 @@ public class RecipeLink { } // selfDuplicate != null - RecipeLink compare = RecipeLink.compare(selfDuplicate.getMaster(), otherRecipe, compareSettings); + RecipeLink compare = compare(selfDuplicate.getMaster(), otherRecipe, compareSettings); if (compare == null) { return false; } diff --git a/Common/src/main/java/com/almostreliable/unified/recipe/RecipeTransformer.java b/Common/src/main/java/com/almostreliable/unified/recipe/RecipeTransformer.java index c0c91b7..e5799de 100644 --- a/Common/src/main/java/com/almostreliable/unified/recipe/RecipeTransformer.java +++ b/Common/src/main/java/com/almostreliable/unified/recipe/RecipeTransformer.java @@ -111,9 +111,9 @@ public class RecipeTransformer { } } - for (RecipeLink unifiedLink : unified) { - if (handleDuplicate(unifiedLink, recipeLinks)) { - duplicates.add(unifiedLink.getDuplicateLink()); + for (RecipeLink recipeLink : duplicationConfig.isStrictMode() ? recipeLinks : unified) { + if (handleDuplicate(recipeLink, recipeLinks)) { + duplicates.add(recipeLink.getDuplicateLink()); } }