Skip to content

Commit

Permalink
Fix the regex ingredient being incredibly borked. (#758)
Browse files Browse the repository at this point in the history
It will now actually serialize and deserialize using the same key, and it will actually serialize the full pattern and flags, instead of just the pattern (which can't be understood by the method used to parse it)
  • Loading branch information
ChiefArug authored Dec 25, 2023
1 parent 28e6f5c commit 4d69f57
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class RegExIngredient extends KubeJSIngredient {
public final Pattern pattern;

public RegExIngredient(Pattern pattern) {
if (pattern == null) throw new IllegalArgumentException("Pattern for a RegExIngredient cannot be null! Check your pattern format");
this.pattern = pattern;
}

Expand All @@ -39,7 +40,7 @@ public boolean test(@Nullable ItemStack stack) {

@Override
public void toJson(JsonObject json) {
json.addProperty("regex", pattern.toString());
json.addProperty("pattern", UtilsJS.toRegexString(pattern));
}

@Override
Expand Down

0 comments on commit 4d69f57

Please sign in to comment.