Added support for env flags as arrays of json strings

This commit is contained in:
Anuken
2021-10-31 13:27:59 -04:00
parent 1a0bcfc745
commit 5d93362741

View File

@@ -196,6 +196,18 @@ public class ContentParser{
}
}
//try to parse env bits
if((type == int.class || type == Integer.class) && jsonData.isArray()){
int value = 0;
for(var str : jsonData){
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);
}
return (T)(Integer)value;
}
//try to parse "item/amount" syntax
if(type == ItemStack.class && jsonData.isString() && jsonData.asString().contains("/")){
String[] split = jsonData.asString().split("/");