Can has json version of a scarpet value

This commit is contained in:
gnembon committed 2020-08-21 01:44:19 -03:00
1 parent b48c52cce4
commit e759a368b9
5 files changed
+57 -3

No files matched your search

@@ -1,6 +1,8 @@
package carpet.script.value;
import carpet.script.exception.InternalExpressionException;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
@@ -256,4 +258,12 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
});
return tag;
}
@Override
public JsonElement toJson()
{
JsonObject jsonMap = new JsonObject();
map.forEach((k, v) -> jsonMap.add(k.getString(), v.toJson()));
return jsonMap;
}
}