Fixed non-objects being accepted as object values

This commit is contained in:
Anuken
2026-02-04 21:51:10 -05:00
parent 05771f4337
commit 9ffc9cb4f4

View File

@@ -278,7 +278,9 @@ public class ContentParser{
}); });
put(PlanetGenerator.class, (type, data) -> { put(PlanetGenerator.class, (type, data) -> {
var result = new AsteroidGenerator(); //only one type for now var result = new AsteroidGenerator(); //only one type for now
readFields(result, data); if(data.isObject()){
readFields(result, data);
}
return result; return result;
}); });
put(Mat3D.class, (type, data) -> { put(Mat3D.class, (type, data) -> {
@@ -436,6 +438,9 @@ public class ContentParser{
try{ try{
return (T)classParsers.get(type).parse(type, jsonData); return (T)classParsers.get(type).parse(type, jsonData);
}catch(Exception e){ }catch(Exception e){
if(e instanceof RuntimeException rt){
throw rt;
}
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@@ -1223,6 +1228,7 @@ public class ContentParser{
} }
void readFields(Object object, JsonValue jsonMap){ void readFields(Object object, JsonValue jsonMap){
if(!jsonMap.isObject()) throw new SerializationException("Expecting an object, but found: '" + jsonMap + "'");
JsonValue research = jsonMap.remove("research"); JsonValue research = jsonMap.remove("research");
toBeParsed.remove(object); toBeParsed.remove(object);