From 5d93362741303f0ed547c81eeeb3aa74d79bfd53 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 31 Oct 2021 13:27:59 -0400 Subject: [PATCH] Added support for env flags as arrays of json strings --- core/src/mindustry/mod/ContentParser.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index 2134b21fec..1ffae2a6ea 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -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.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("/");