Skip to content

Commit

Permalink
Don't hard crash and add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
UnRealDinnerbone committed Jul 5, 2024
1 parent 0f99a40 commit 69a5e2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### 6.0.1
### 6.0.2

- Re add Mekanism Support
- Don't hard crash on invalid codecs and print more erros
15 changes: 13 additions & 2 deletions common/src/main/java/com/unrealdinnerbone/jamd/WorldType.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,25 @@ public void export(MinecraftServer server) throws IllegalStateException, IOExcep
});
}

DataResult<JsonElement> result = ConfigCodec.CODEC.encodeStart(JsonOps.INSTANCE, new ConfigCodec(1, false, oresCodecs));
List<OresCodec> workedOres = new ArrayList<>();

for (OresCodec oresCodec : oresCodecs) {
DataResult<JsonElement> jsonElementDataResult = OresCodec.CODEC.encodeStart(JsonOps.INSTANCE, oresCodec);
if(jsonElementDataResult.result().isPresent()) {
workedOres.add(oresCodec);
}else {
LOGGER.error("Failed to encode: {}", jsonElementDataResult.error().get());
}
}

DataResult<JsonElement> result = ConfigCodec.CODEC.encodeStart(JsonOps.INSTANCE, new ConfigCodec(1, false, workedOres));
if (result.result().isPresent()) {
if (!Files.exists(JAMD.CONFIG_FOLDER)) {
Files.createDirectories(JAMD.CONFIG_FOLDER);
}
Files.writeString(configPath, GSON.toJson(result.result().get()));
} else {
throw new IllegalStateException(result.error().get().message());
LOGGER.error("Failed to load config: {}", result.error().get());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project
mod_version=5.0.1
mod_version=5.0.2
maven_group=com.unrealdinnerbone
curse_id=422981
mod_name=JAMD
Expand Down

0 comments on commit 69a5e2d

Please sign in to comment.