Skip to content

Commit

Permalink
2.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ZZZank committed Mar 25, 2024
1 parent 18854a9 commit c873b7f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# ProbeJS Legacy 2.6.0 -> 2.6.1

Fix optional class dumping crash

## What's new?

- ProbeJS will now catch error thrown when classes to be looked into is missing.
- This means that "Optional" classes, like classes intended for cross-mod compatibility, should be able to be dumped without crashing the whole game

---

# ProbeJS Legacy 2.5.0 -> 2.6.0

Registry Dumping
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ loom.platform=forge
parchment_version=1.16.5:2022.03.06

# Mod Properties
mod_version=2.6.0
mod_version=2.6.1
maven_group=com.prunoideae
archives_base_name=probejs
mod_id=probejs
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/probejs/info/EventInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,26 @@ public List<String> getBuiltinPropAsComment() {

@SuppressWarnings("unchecked")
public static Optional<EventInfo> fromJson(JsonObject json) {
//id
String id = json.get("id").getAsString();
//class
Class<?> clazz;
try {
clazz = Class.forName(json.get("class").getAsString());
} catch (ClassNotFoundException | NoClassDefFoundError e) {
return Optional.empty();
}
//type
EnumSet<ScriptType> types = EnumSet.noneOf(ScriptType.class);
if (json.has("type")) {
JsonArray jArray = json.get("type").getAsJsonArray();
jArray.forEach(jElement -> types.add(ScriptType.valueOf(jElement.getAsString())));
}
//sub
String sub = json.has("sub") ? json.get("sub").getAsString() : null;
//cancellable
boolean cancellable = json.has("cancellable") && json.get("cancellable").getAsBoolean();

return Optional.of(new EventInfo((Class<? extends EventJS>) clazz, id, sub, types, cancellable));
}
}

0 comments on commit c873b7f

Please sign in to comment.