From 8ba182025498f055f4b66cd84428244ad2cdf293 Mon Sep 17 00:00:00 2001 From: TheBukor Date: Tue, 23 Aug 2016 19:45:18 -0300 Subject: [PATCH] This should fix errors when using SkQ lambdas in general. NBT Lists now should be preceded with either "nbt:" or "nbtlist:" before being parsed (e.g "nbt:[entry1,entry2]" parsed as nbtlist). Also removed unnecessary "SkStuffIsCool" and replaced it with "temp". Great, huh? --- plugin.yml | 2 +- .../TheBukor/SkStuff/util/NMS_v1_10_R1.java | 22 ++++++++++------ src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java | 25 +++++++++++-------- src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java | 22 ++++++++++------ src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java | 22 ++++++++++------ src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java | 22 ++++++++++------ 6 files changed, 72 insertions(+), 43 deletions(-) diff --git a/plugin.yml b/plugin.yml index 24250c9..3c51be1 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.6 +version: 1.6.3.7 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_10_R1.java b/src/me/TheBukor/SkStuff/util/NMS_v1_10_R1.java index b04ff4e..2b6726c 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_10_R1.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_10_R1.java @@ -413,9 +413,15 @@ public class NMS_v1_10_R1 implements NMSInterface { @Override @Nullable public NBTTagList parse(String listString, ParseContext context) { - if (listString.startsWith("[") && listString.endsWith("]")) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); - NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) { + int substring; + if (listString.startsWith("nbt:[")) { + substring = 4; + } else { // "nbtlist:[WHATEVER]" + substring = 8; + } + NBTTagCompound tempNBT = parseRawNBT("{temp:" + listString.substring(substring) + "}"); + NBTTagList parsedList = (NBTTagList) tempNBT.get("temp"); return parsedList; } return null; @@ -452,19 +458,19 @@ public class NMS_v1_10_R1 implements NMSInterface { @Override protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { String s = fields.getObject("asString", String.class); - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); - if (tempNBT == null || nbtList == null) { + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + if (tempNBT == null || !tempNBT.hasKey("temp")) { throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); } + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); return nbtList; } @Override @Nullable public NBTTagList deserialize(String s) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); return nbtList; } 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 7e7a45e..d683d2b 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java @@ -300,8 +300,7 @@ public class NMS_v1_7_R4 implements NMSInterface { @Nullable public NBTTagCompound parse(String rawNBT, ParseContext context) { if (rawNBT.startsWith("nbt:{") && rawNBT.endsWith("}")) { - rawNBT.substring(4); - NBTTagCompound NBT = parseRawNBT(rawNBT); + NBTTagCompound NBT = parseRawNBT(rawNBT.substring(4)); return NBT; } return null; @@ -396,9 +395,15 @@ public class NMS_v1_7_R4 implements NMSInterface { @Override @Nullable public NBTTagList parse(String listString, ParseContext context) { - if (listString.startsWith("[") && listString.endsWith("]")) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); - NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) { + int substring; + if (listString.startsWith("nbt:[")) { + substring = 4; + } else { // "nbtlist:[WHATEVER]" + substring = 8; + } + NBTTagCompound tempNBT = parseRawNBT("{temp:" + listString.substring(substring) + "}"); + NBTTagList parsedList = (NBTTagList) tempNBT.get("temp"); return parsedList; } return null; @@ -435,19 +440,19 @@ public class NMS_v1_7_R4 implements NMSInterface { @Override protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { String s = fields.getObject("asString", String.class); - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); - if (tempNBT == null || nbtList == null) { + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + if (tempNBT == null || !tempNBT.hasKey("temp")) { throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); } + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); return nbtList; } @Override @Nullable public NBTTagList deserialize(String s) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); 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 d072519..8b477f1 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java @@ -411,9 +411,15 @@ public class NMS_v1_8_R3 implements NMSInterface { @Override @Nullable public NBTTagList parse(String listString, ParseContext context) { - if (listString.startsWith("[") && listString.endsWith("]")) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); - NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) { + int substring; + if (listString.startsWith("nbt:[")) { + substring = 4; + } else { // "nbtlist:[WHATEVER]" + substring = 8; + } + NBTTagCompound tempNBT = parseRawNBT("{temp:" + listString.substring(substring) + "}"); + NBTTagList parsedList = (NBTTagList) tempNBT.get("temp"); return parsedList; } return null; @@ -450,19 +456,19 @@ public class NMS_v1_8_R3 implements NMSInterface { @Override protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { String s = fields.getObject("asString", String.class); - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); - if (tempNBT == null || nbtList == null) { + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + if (tempNBT == null || !tempNBT.hasKey("temp")) { throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); } + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); return nbtList; } @Override @Nullable public NBTTagList deserialize(String s) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); 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 9683e75..0c67bb1 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java @@ -413,9 +413,15 @@ public class NMS_v1_9_R1 implements NMSInterface { @Override @Nullable public NBTTagList parse(String listString, ParseContext context) { - if (listString.startsWith("[") && listString.endsWith("]")) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); - NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) { + int substring; + if (listString.startsWith("nbt:[")) { + substring = 4; + } else { // "nbtlist:[WHATEVER]" + substring = 8; + } + NBTTagCompound tempNBT = parseRawNBT("{temp:" + listString.substring(substring) + "}"); + NBTTagList parsedList = (NBTTagList) tempNBT.get("temp"); return parsedList; } return null; @@ -452,19 +458,19 @@ public class NMS_v1_9_R1 implements NMSInterface { @Override protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { String s = fields.getObject("asString", String.class); - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); - if (tempNBT == null || nbtList == null) { + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + if (tempNBT == null || !tempNBT.hasKey("temp")) { throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); } + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); return nbtList; } @Override @Nullable public NBTTagList deserialize(String s) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); return nbtList; } diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java index 3611b4b..814111a 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java @@ -413,9 +413,15 @@ public class NMS_v1_9_R2 implements NMSInterface { @Override @Nullable public NBTTagList parse(String listString, ParseContext context) { - if (listString.startsWith("[") && listString.endsWith("]")) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); - NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) { + int substring; + if (listString.startsWith("nbt:[")) { + substring = 4; + } else { // "nbtlist:[WHATEVER]" + substring = 8; + } + NBTTagCompound tempNBT = parseRawNBT("{temp:" + listString.substring(substring) + "}"); + NBTTagList parsedList = (NBTTagList) tempNBT.get("temp"); return parsedList; } return null; @@ -452,19 +458,19 @@ public class NMS_v1_9_R2 implements NMSInterface { @Override protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { String s = fields.getObject("asString", String.class); - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); - if (tempNBT == null || nbtList == null) { + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + if (tempNBT == null || !tempNBT.hasKey("temp")) { throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); } + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); return nbtList; } @Override @Nullable public NBTTagList deserialize(String s) { - NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); - NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); + NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}"); + NBTTagList nbtList = (NBTTagList) tempNBT.get("temp"); return nbtList; }