This commit is contained in:
Anuken
2026-08-02 04:18:40 -04:00
parent ff427fbffb
commit 5daa268748
2 changed files with 6 additions and 7 deletions
+5 -6
View File
@@ -92,11 +92,11 @@ public class ContentParser{
return Attribute.add(attr);
});
put(Attributes.class, (type, data) -> {
if(!data.isObject()){
if(!(data instanceof JsonMap map)){
throw new IllegalArgumentException("Attribute definitions must be objects, e.g. {heat: 10}");
}
Attributes attr = new Attributes();
for(var entry : data.asObject()){
for(var entry : map){
Attribute value = Attribute.exists(entry.key) ? Attribute.get(entry.key) : Attribute.add(entry.key);
attr.set(value, entry.value.asFloat());
}
@@ -449,9 +449,9 @@ public class ContentParser{
}
//try to parse env bits
if((type == int.class || type == Integer.class) && jsonData.isArray()){
if((type == int.class || type == Integer.class) && jsonData instanceof JsonArray arr){
int value = 0;
for(var str : jsonData.asArray()){
for(var str : arr){
if(!str.isString()) throw new SerializationException("Integer bitfield values must all be strings. Found: " + str);
String field = str.asString();
value |= Reflect.<Integer>get(Env.class, field);
@@ -487,8 +487,7 @@ public class ContentParser{
}
//try to parse Rect as array
if(type == Rect.class && jsonData.isArray() && jsonData.asArray().size == 4){
JsonArray arr = jsonData.asArray();
if(type == Rect.class && jsonData instanceof JsonArray arr && arr.size == 4){
return (T)new Rect(arr.get(0).asFloat(), arr.get(1).asFloat(), arr.get(2).asFloat(), arr.get(3).asFloat());
}
+1 -1
View File
@@ -26,4 +26,4 @@ org.gradle.caching=true
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
android.enableR8.fullMode=false
archash=e3d0326a1b
archash=41afca02cd