Forgot 1.6.3.1 commit. Whoops!

Added compound serializer to 1.7.10
Fixed a bug that would cause ALL variables to be unused if a single
compound variable was invalid
This commit is contained in:
TheBukor 2016-04-09 12:24:43 -03:00
parent 226d0dc931
commit 7140ed1cff
4 changed files with 62 additions and 7 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
version: 1.6.3.1
main: me.TheBukor.SkStuff.SkStuff
softdepend: [Skript, WorldEdit, VanishNoPacket]

View File

@ -316,7 +316,47 @@ public class NMS_v1_7_R4 implements NMSInterface {
public String toVariableNameString(NBTTagCompound compound) {
return compound.toString();
}
}));
}).serializer(new Serializer<NBTTagCompound>() {
@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;
}

View File

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

View File

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