Skip to content

Commit 1a09148

Browse files
committed
fix: skip unloaded entry page files
1 parent 44ad2bd commit 1a09148

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

common/src/main/java/com/klikli_dev/modonomicon/data/BookDataManager.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ protected void apply(Map<Identifier, JsonElement> content, ResourceManager pReso
491491
}
492492

493493
//Merge per-page JSON files into BookContentEntry inline page lists
494-
this.mergePageJsons(pageJsons);
494+
this.mergePageJsons(pageJsons, categoryJsons, entryJsons);
495495

496496
//load commands
497497
for (var entry : commandJsons.entrySet()) {
@@ -529,7 +529,7 @@ protected void apply(Map<Identifier, JsonElement> content, ResourceManager pReso
529529
* Pages in a file replace inline pages with the same ID.
530530
* Pages without a matching inline ID are inserted at sort_number position (default: end of list).
531531
*/
532-
private void mergePageJsons(Map<Identifier, JsonObject> pageJsons) {
532+
private void mergePageJsons(Map<Identifier, JsonObject> pageJsons, Map<Identifier, JsonObject> categoryJsons, Map<Identifier, JsonObject> entryJsons) {
533533
var sortedEntries = new ArrayList<>(pageJsons.entrySet());
534534
sortedEntries.sort(Comparator.comparing(e -> e.getKey().toString()));
535535
for (var entry : sortedEntries) {
@@ -564,10 +564,22 @@ private void mergePageJsons(Map<Identifier, JsonObject> pageJsons) {
564564
// Entry ID: category path + "/" + entry name (part just before "pages")
565565
var entryPath = categoryPath + "/" + pathParts[pagesIdx - 1];
566566
var entryId = Identifier.fromNamespaceAndPath(path.getNamespace(), entryPath);
567+
var categoryJsonKey = Identifier.fromNamespaceAndPath(path.getNamespace(), pathParts[0] + "/categories/" + categoryId.getPath());
568+
var entryJsonKey = Identifier.fromNamespaceAndPath(path.getNamespace(), pathParts[0] + "/entries/" + entryId.getPath());
567569

568570
BookErrorManager.get().setCurrentBookId(bookId);
569571
BookErrorManager.get().getContextHelper().entryId = entryId;
570572

573+
var categoryJson = categoryJsons.get(categoryJsonKey);
574+
if (categoryJson != null && !this.testConditionOnLoad(categoryId, categoryJson, this.registries)) {
575+
continue;
576+
}
577+
578+
var entryJson = entryJsons.get(entryJsonKey);
579+
if (entryJson != null && !this.testConditionOnLoad(entryId, entryJson, this.registries)) {
580+
continue;
581+
}
582+
571583
var book = this.books.get(bookId);
572584
if (book == null) {
573585
BookErrorManager.get().error("Page file references unknown book: " + bookId);

0 commit comments

Comments
 (0)