diff --git a/plugin.yml b/plugin.yml index 0f1d77c..abd2150 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SkStuff author: TheBukor description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support. -version: 1.6.3 +version: 1.6.3.1 main: me.TheBukor.SkStuff.SkStuff softdepend: [Skript, WorldEdit, VanishNoPacket] \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java b/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java index 8dc2bac..060acc8 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java @@ -316,7 +316,47 @@ public class NMS_v1_7_R4 implements NMSInterface { public String toVariableNameString(NBTTagCompound compound) { return compound.toString(); } - })); + }).serializer(new Serializer() { + + @Override + public Fields serialize(NBTTagCompound compound) throws NotSerializableException { + Fields f = new Fields(); + f.putObject("asString", compound.toString()); + return f; + } + + @Override + public void deserialize(NBTTagCompound compound, Fields f) throws StreamCorruptedException, NotSerializableException { + assert false; + } + + @Override + protected boolean canBeInstantiated() { + return false; + } + + @Override + protected NBTTagCompound deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { + String raw = fields.getObject("asString", String.class); + NBTTagCompound compound = parseRawNBT(raw); + if (compound == null) { + throw new StreamCorruptedException("Unable to parse NBT compound from a variable: " + raw); + } + return compound; + } + + @Override + @Nullable + public NBTTagCompound deserialize(String s) { + NBTTagCompound compound = parseRawNBT(s); + return compound; + } + + @Override + public boolean mustSyncDeserialization() { + return true; + } + })); } @@ -397,6 +437,9 @@ public class NMS_v1_7_R4 implements NMSInterface { String s = fields.getObject("asString", String.class); NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + if (tempNBT == null || nbtList == null) { + throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); + } return nbtList; } diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java b/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java index 4fbc5da..bb5698b 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java @@ -94,7 +94,7 @@ public class NMS_v1_8_R3 implements NMSInterface { return 0; } - @Override + @Override public Object getNBTTagValue(Object compound, String tag, byte typeId) { if (compound instanceof NBTTagCompound) { switch (typeId) { @@ -351,8 +351,11 @@ public class NMS_v1_8_R3 implements NMSInterface { @Override protected NBTTagCompound deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { - String s = fields.getObject("asString", String.class); - NBTTagCompound compound = parseRawNBT(s); + String raw = fields.getObject("asString", String.class); + NBTTagCompound compound = parseRawNBT(raw); + if (compound == null) { + throw new StreamCorruptedException("Unable to parse NBT from a variable: " + raw); + } return compound; } @@ -448,6 +451,9 @@ public class NMS_v1_8_R3 implements NMSInterface { String s = fields.getObject("asString", String.class); NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + if (tempNBT == null || nbtList == null) { + throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); + } return nbtList; } diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java index 5f5ef5a..962d96b 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java @@ -352,8 +352,11 @@ public class NMS_v1_9_R1 implements NMSInterface { @Override protected NBTTagCompound deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { - String s = fields.getObject("asString", String.class); - NBTTagCompound compound = parseRawNBT(s); + String raw = fields.getObject("asString", String.class); + NBTTagCompound compound = parseRawNBT(raw); + if (compound == null) { + throw new StreamCorruptedException("Unable to parse NBT from a variable: " + raw); + } return compound; } @@ -449,6 +452,9 @@ public class NMS_v1_9_R1 implements NMSInterface { String s = fields.getObject("asString", String.class); NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + if (tempNBT == null || nbtList == null) { + throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); + } return nbtList; }