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
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]

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}