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?
This commit is contained in:
TheBukor 2016-08-23 19:45:18 -03:00
parent 6193221637
commit 8ba1820254
6 changed files with 72 additions and 43 deletions

View File

@ -1,6 +1,6 @@
name: SkStuff name: SkStuff
author: TheBukor author: TheBukor
description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support. 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 main: me.TheBukor.SkStuff.SkStuff
softdepend: [Skript, WorldEdit, VanishNoPacket] softdepend: [Skript, WorldEdit, VanishNoPacket]

View File

@ -413,9 +413,15 @@ public class NMS_v1_10_R1 implements NMSInterface {
@Override @Override
@Nullable @Nullable
public NBTTagList parse(String listString, ParseContext context) { public NBTTagList parse(String listString, ParseContext context) {
if (listString.startsWith("[") && listString.endsWith("]")) { if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); int substring;
NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); 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 parsedList;
} }
return null; return null;
@ -452,19 +458,19 @@ public class NMS_v1_10_R1 implements NMSInterface {
@Override @Override
protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException {
String s = fields.getObject("asString", String.class); String s = fields.getObject("asString", String.class);
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); if (tempNBT == null || !tempNBT.hasKey("temp")) {
if (tempNBT == null || nbtList == null) {
throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s);
} }
NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }
@Override @Override
@Nullable @Nullable
public NBTTagList deserialize(String s) { public NBTTagList deserialize(String s) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }

View File

@ -300,8 +300,7 @@ public class NMS_v1_7_R4 implements NMSInterface {
@Nullable @Nullable
public NBTTagCompound parse(String rawNBT, ParseContext context) { public NBTTagCompound parse(String rawNBT, ParseContext context) {
if (rawNBT.startsWith("nbt:{") && rawNBT.endsWith("}")) { if (rawNBT.startsWith("nbt:{") && rawNBT.endsWith("}")) {
rawNBT.substring(4); NBTTagCompound NBT = parseRawNBT(rawNBT.substring(4));
NBTTagCompound NBT = parseRawNBT(rawNBT);
return NBT; return NBT;
} }
return null; return null;
@ -396,9 +395,15 @@ public class NMS_v1_7_R4 implements NMSInterface {
@Override @Override
@Nullable @Nullable
public NBTTagList parse(String listString, ParseContext context) { public NBTTagList parse(String listString, ParseContext context) {
if (listString.startsWith("[") && listString.endsWith("]")) { if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); int substring;
NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); 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 parsedList;
} }
return null; return null;
@ -435,19 +440,19 @@ public class NMS_v1_7_R4 implements NMSInterface {
@Override @Override
protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException {
String s = fields.getObject("asString", String.class); String s = fields.getObject("asString", String.class);
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); if (tempNBT == null || !tempNBT.hasKey("temp")) {
if (tempNBT == null || nbtList == null) {
throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s);
} }
NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }
@Override @Override
@Nullable @Nullable
public NBTTagList deserialize(String s) { public NBTTagList deserialize(String s) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }

View File

@ -411,9 +411,15 @@ public class NMS_v1_8_R3 implements NMSInterface {
@Override @Override
@Nullable @Nullable
public NBTTagList parse(String listString, ParseContext context) { public NBTTagList parse(String listString, ParseContext context) {
if (listString.startsWith("[") && listString.endsWith("]")) { if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); int substring;
NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); 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 parsedList;
} }
return null; return null;
@ -450,19 +456,19 @@ public class NMS_v1_8_R3 implements NMSInterface {
@Override @Override
protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException {
String s = fields.getObject("asString", String.class); String s = fields.getObject("asString", String.class);
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); if (tempNBT == null || !tempNBT.hasKey("temp")) {
if (tempNBT == null || nbtList == null) {
throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s);
} }
NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }
@Override @Override
@Nullable @Nullable
public NBTTagList deserialize(String s) { public NBTTagList deserialize(String s) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }

View File

@ -413,9 +413,15 @@ public class NMS_v1_9_R1 implements NMSInterface {
@Override @Override
@Nullable @Nullable
public NBTTagList parse(String listString, ParseContext context) { public NBTTagList parse(String listString, ParseContext context) {
if (listString.startsWith("[") && listString.endsWith("]")) { if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); int substring;
NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); 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 parsedList;
} }
return null; return null;
@ -452,19 +458,19 @@ public class NMS_v1_9_R1 implements NMSInterface {
@Override @Override
protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException {
String s = fields.getObject("asString", String.class); String s = fields.getObject("asString", String.class);
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); if (tempNBT == null || !tempNBT.hasKey("temp")) {
if (tempNBT == null || nbtList == null) {
throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s);
} }
NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }
@Override @Override
@Nullable @Nullable
public NBTTagList deserialize(String s) { public NBTTagList deserialize(String s) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }

View File

@ -413,9 +413,15 @@ public class NMS_v1_9_R2 implements NMSInterface {
@Override @Override
@Nullable @Nullable
public NBTTagList parse(String listString, ParseContext context) { public NBTTagList parse(String listString, ParseContext context) {
if (listString.startsWith("[") && listString.endsWith("]")) { if ((listString.startsWith("nbt:[") || listString.startsWith("nbtlist:[")) && listString.endsWith("]")) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + listString + "}"); int substring;
NBTTagList parsedList = (NBTTagList) tempNBT.get("SkStuffIsCool"); 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 parsedList;
} }
return null; return null;
@ -452,19 +458,19 @@ public class NMS_v1_9_R2 implements NMSInterface {
@Override @Override
protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException { protected NBTTagList deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException {
String s = fields.getObject("asString", String.class); String s = fields.getObject("asString", String.class);
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); if (tempNBT == null || !tempNBT.hasKey("temp")) {
if (tempNBT == null || nbtList == null) {
throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s); throw new StreamCorruptedException("Unable to parse NBT list from a variable: " + s);
} }
NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }
@Override @Override
@Nullable @Nullable
public NBTTagList deserialize(String s) { public NBTTagList deserialize(String s) {
NBTTagCompound tempNBT = parseRawNBT("{SkStuffIsCool:" + s + "}"); NBTTagCompound tempNBT = parseRawNBT("{temp:" + s + "}");
NBTTagList nbtList = (NBTTagList) tempNBT.get("SkStuffIsCool"); NBTTagList nbtList = (NBTTagList) tempNBT.get("temp");
return nbtList; return nbtList;
} }