From 79c42a56e61e76b679bd515c7ed4fa1b72f2a7e2 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 24 Nov 2012 19:14:25 +0100 Subject: [PATCH] Possible hotfix for empty NMS lists. --- .../mcore5/adapter/NbtGsonConverter.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/massivecraft/mcore5/adapter/NbtGsonConverter.java b/src/com/massivecraft/mcore5/adapter/NbtGsonConverter.java index 06af6bd5..306545cf 100644 --- a/src/com/massivecraft/mcore5/adapter/NbtGsonConverter.java +++ b/src/com/massivecraft/mcore5/adapter/NbtGsonConverter.java @@ -75,12 +75,10 @@ public class NbtGsonConverter if (type == NBType.LIST) { JsonElement elemtypeElement = jsonObject.get(ELEMTYPE); - if (elemtypeElement == null) + if (elemtypeElement != null) { - // must have an elemtype - return null; + elemtype = NBType.getByName(elemtypeElement.getAsString()); } - elemtype = NBType.getByName(elemtypeElement.getAsString()); } // Fetch the value field @@ -215,7 +213,13 @@ public class NbtGsonConverter if (type == NBType.LIST) { - ret.addProperty(ELEMTYPE, NBType.getByTag(((NBTTagList)nbt).get(0)).getName()); + NBType elemtype = NBType.UNKNOWN; + NBTTagList nbtl = (NBTTagList)nbt; + if (nbtl.size() > 0) + { + elemtype = NBType.getByTag(nbtl.get(0)); + } + ret.addProperty(ELEMTYPE, elemtype.getName()); } JsonElement val = nbtToGsonVal(nbt);