Skip to content

Commit

Permalink
Add error messages + support single ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollounknowndev committed Nov 27, 2024
1 parent 07a1871 commit 15b54bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,15 @@ public static List<ModResourcePack> getModResourcePacks(FabricLoader fabricLoade
sorter.addPack(pack);

CustomValue loadOrder = metadata.getCustomValue(LOAD_ORDER_KEY);
if (loadOrder == null) continue;

if (loadOrder != null && loadOrder.getType() == CustomValue.CvType.OBJECT) {
if (loadOrder.getType() == CustomValue.CvType.OBJECT) {
CustomValue.CvObject object = loadOrder.getAsObject();

addLoadOrdering(object, allIds, sorter, Order.BEFORE, id);
addLoadOrdering(object, allIds, sorter, Order.AFTER, id);
} else {
LOGGER.error("[Fabric] Resource load order should be an object");
}
}

Expand All @@ -114,14 +117,23 @@ public static List<ModResourcePack> getModResourcePacks(FabricLoader fabricLoade

public static void addLoadOrdering(CustomValue.CvObject object, List<String> allIds, ModResourcePackSorter sorter, Order order, String currentId) {
List<String> modIds = new ArrayList<>();
CustomValue array = object.get(order.jsonKey);

if (array != null && array.getType() == CustomValue.CvType.ARRAY) {
for (CustomValue id : array.getAsArray()) {
if (id.getType() == CustomValue.CvType.STRING) {
modIds.add(id.getAsString());
CustomValue array = object.get(order.jsonKey);
if (array == null) return;

switch (array.getType()) {
case STRING -> modIds.add(array.getAsString());

Check failure on line 125 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'case' child has incorrect indentation level 12, expected level should be 8.
case ARRAY -> {

Check failure on line 126 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'case' child has incorrect indentation level 12, expected level should be 8.
for (CustomValue id : array.getAsArray()) {

Check failure on line 127 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'for' has incorrect indentation level 16, expected level should be 12.
if (id.getType() == CustomValue.CvType.STRING) {

Check failure on line 128 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'if' has incorrect indentation level 20, expected level should be 16.
modIds.add(id.getAsString());

Check failure on line 129 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'if' child has incorrect indentation level 24, expected level should be 20.
}

Check failure on line 130 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'if rcurly' has incorrect indentation level 20, expected level should be 16.
}

Check failure on line 131 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'for rcurly' has incorrect indentation level 16, expected level should be 12.
}

Check failure on line 132 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'block rcurly' has incorrect indentation level 12, expected level should be 8.
default -> {

Check failure on line 133 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'case' child has incorrect indentation level 12, expected level should be 8.
LOGGER.error("[Fabric] {} should be a string or an array", order.jsonKey);

Check failure on line 134 in fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java

View workflow job for this annotation

GitHub Actions / build (21-ubuntu)

'block' child has incorrect indentation level 16, expected level should be 12.
return;
}
}

modIds.stream().filter(allIds::contains).forEach(modId -> sorter.addLoadOrdering(modId, currentId, order));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
},
"custom": {
"fabric:resource_load_order": {
"after": [
"fabric-resource-loader-v0-testmod-b"
]
"after": "fabric-resource-loader-v0-testmod-b"
}
}
}

0 comments on commit 15b54bb

Please sign in to comment.