Skip to content

Commit

Permalink
Fix null condition in addConditions
Browse files Browse the repository at this point in the history
  • Loading branch information
apple502j committed Apr 9, 2024
1 parent 9c3cc6a commit a431beb
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public interface ResourceCondition {
static void addConditions(JsonObject baseObject, ResourceCondition... conditions) {
if (baseObject.has(ResourceConditions.CONDITIONS_KEY)) {
throw new IllegalArgumentException("Object already has a condition entry: " + baseObject);
} else if (conditions == null || conditions.length == 0) {
// Datagen might pass null conditions.
return;
}

baseObject.add(ResourceConditions.CONDITIONS_KEY, LIST_CODEC.encodeStart(JsonOps.INSTANCE, Arrays.asList(conditions)).getOrThrow());
Expand Down

0 comments on commit a431beb

Please sign in to comment.