Skip to content

Commit 2241472

Browse files
committed
Handle invalid skulls gracefully
1 parent e726b91 commit 2241472

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/main/java/org/geysermc/geyser/util/JsonUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public static JsonObject fromJson(InputStream stream) {
4949
}
5050

5151
public static JsonObject parseJson(String s) {
52-
return (JsonObject) new JsonParser().parse(s);
52+
var output = new JsonParser().parse(s);
53+
if (output instanceof JsonObject jsonObject) {
54+
return jsonObject;
55+
}
56+
throw new IllegalArgumentException("Invalid JSON: " + s);
5357
}
5458

5559
public static <T> T fromJson(InputStream stream, Type type) {

0 commit comments

Comments
 (0)