diff --git a/.classpath b/.classpath
index 502a1af..d86587e 100644
--- a/.classpath
+++ b/.classpath
@@ -7,5 +7,9 @@
+
+
+
+
diff --git a/bin/.gitignore b/bin/.gitignore
index 24cb195..4060509 100644
--- a/bin/.gitignore
+++ b/bin/.gitignore
@@ -1,2 +1 @@
/me/
-/org/
diff --git a/src/me/TheBukor/SkStuff.java b/src/me/TheBukor/SkStuff.java
index 5c01682..52b12a6 100644
--- a/src/me/TheBukor/SkStuff.java
+++ b/src/me/TheBukor/SkStuff.java
@@ -27,11 +27,19 @@ import me.TheBukor.expressions.ExprFileNBTv1_8_R2;
import me.TheBukor.expressions.ExprFileNBTv1_8_R3;
import me.TheBukor.expressions.ExprHeightOfSchematic;
import me.TheBukor.expressions.ExprHeightOfSelection;
+import me.TheBukor.expressions.ExprItemNBTv1_7_R1;
+import me.TheBukor.expressions.ExprItemNBTv1_7_R2;
+import me.TheBukor.expressions.ExprItemNBTv1_7_R3;
+import me.TheBukor.expressions.ExprItemNBTv1_7_R4;
import me.TheBukor.expressions.ExprItemNBTv1_8_R1;
import me.TheBukor.expressions.ExprItemNBTv1_8_R2;
import me.TheBukor.expressions.ExprItemNBTv1_8_R3;
import me.TheBukor.expressions.ExprLengthOfSchematic;
import me.TheBukor.expressions.ExprLengthOfSelection;
+import me.TheBukor.expressions.ExprNBTv1_7_R1;
+import me.TheBukor.expressions.ExprNBTv1_7_R2;
+import me.TheBukor.expressions.ExprNBTv1_7_R3;
+import me.TheBukor.expressions.ExprNBTv1_7_R4;
import me.TheBukor.expressions.ExprNBTv1_8_R1;
import me.TheBukor.expressions.ExprNBTv1_8_R2;
import me.TheBukor.expressions.ExprNBTv1_8_R3;
@@ -39,6 +47,10 @@ import me.TheBukor.expressions.ExprNewEditSession;
import me.TheBukor.expressions.ExprSelectionOfPlayer;
import me.TheBukor.expressions.ExprSelectionPos1;
import me.TheBukor.expressions.ExprSelectionPos2;
+import me.TheBukor.expressions.ExprTagOfv1_7_R1;
+import me.TheBukor.expressions.ExprTagOfv1_7_R2;
+import me.TheBukor.expressions.ExprTagOfv1_7_R3;
+import me.TheBukor.expressions.ExprTagOfv1_7_R4;
import me.TheBukor.expressions.ExprTagOfv1_8_R1;
import me.TheBukor.expressions.ExprTagOfv1_8_R2;
import me.TheBukor.expressions.ExprTagOfv1_8_R3;
@@ -59,7 +71,160 @@ public class SkStuff extends JavaPlugin {
if (Bukkit.getPluginManager().getPlugin("Skript") != null) {
Skript.registerAddon(this);
getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!");
- if (Bukkit.getVersion().contains("(MC: 1.8)")){
+ if (Bukkit.getVersion().contains("(MC: 1.7.2)")) {
+ getLogger().info("Successfully found 1.7.2! Registering version specific expressions...");
+ exprAmount += 3;
+ typeAmount += 1;
+ Skript.registerExpression(ExprNBTv1_7_R1.class, net.minecraft.server.v1_7_R1.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
+ Skript.registerExpression(ExprItemNBTv1_7_R1.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
+ Skript.registerExpression(ExprTagOfv1_7_R1.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%");
+ //WARNING! HIGHLY EXPERIMENTAL, IT CAN CORRUPT WORLDS AT CURRENT VERSION, USE AT YOUR OWN RISK!
+ //Skript.registerExpression(ExprFileNBTv1_7_R1.class, net.minecraft.server.v1_7_R1.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%");
+ Classes.registerClass(new ClassInfo(net.minecraft.server.v1_7_R1.NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser() {
+ @Override
+ public String getVariableNamePattern() {
+ return ".+";
+ }
+
+ @Override
+ @Nullable
+ public net.minecraft.server.v1_7_R1.NBTTagCompound parse(String s, ParseContext context) {
+ net.minecraft.server.v1_7_R1.NBTTagCompound NBT = new net.minecraft.server.v1_7_R1.NBTTagCompound();
+ net.minecraft.server.v1_7_R1.NBTTagCompound NBT1 = (net.minecraft.server.v1_7_R1.NBTTagCompound) net.minecraft.server.v1_7_R1.MojangsonParser.a(s);
+ NBT.set("", NBT1);
+ if (NBT.isEmpty() || NBT == null) {
+ return null;
+ }
+ return NBT;
+ }
+
+ @Override
+ public String toString(net.minecraft.server.v1_7_R1.NBTTagCompound compound, int arg1) {
+ return compound.toString();
+ }
+
+ @Override
+ public String toVariableNameString(net.minecraft.server.v1_7_R1.NBTTagCompound compound) {
+ return compound.toString();
+ }
+ }));
+ }
+ if (Bukkit.getVersion().contains("(MC: 1.7.5)")) {
+ getLogger().info("Successfully found 1.7.5! Registering version specific expressions...");
+ exprAmount += 3;
+ typeAmount += 1;
+ Skript.registerExpression(ExprNBTv1_7_R2.class, net.minecraft.server.v1_7_R2.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
+ Skript.registerExpression(ExprItemNBTv1_7_R2.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
+ Skript.registerExpression(ExprTagOfv1_7_R2.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%");
+ //WARNING! HIGHLY EXPERIMENTAL, IT CAN CORRUPT WORLDS AT CURRENT VERSION, USE AT YOUR OWN RISK!
+ //Skript.registerExpression(ExprFileNBTv1_7_R2.class, net.minecraft.server.v1_7_R2.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%");
+ Classes.registerClass(new ClassInfo(net.minecraft.server.v1_7_R2.NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser() {
+ @Override
+ public String getVariableNamePattern() {
+ return ".+";
+ }
+
+ @Override
+ @Nullable
+ public net.minecraft.server.v1_7_R2.NBTTagCompound parse(String s, ParseContext context) {
+ net.minecraft.server.v1_7_R2.NBTTagCompound NBT = new net.minecraft.server.v1_7_R2.NBTTagCompound();
+ net.minecraft.server.v1_7_R2.NBTTagCompound NBT1 = (net.minecraft.server.v1_7_R2.NBTTagCompound) net.minecraft.server.v1_7_R2.MojangsonParser.parse(s);
+ NBT.set("", NBT1);
+ if (NBT.isEmpty() || NBT == null) {
+ return null;
+ }
+ return NBT;
+ }
+
+ @Override
+ public String toString(net.minecraft.server.v1_7_R2.NBTTagCompound compound, int arg1) {
+ return compound.toString();
+ }
+
+ @Override
+ public String toVariableNameString(net.minecraft.server.v1_7_R2.NBTTagCompound compound) {
+ return compound.toString();
+ }
+ }));
+ }
+ if (Bukkit.getVersion().contains("(MC: 1.7.9)")) {
+ getLogger().info("Successfully found 1.7.9! Registering version specific expressions...");
+ exprAmount += 3;
+ typeAmount += 1;
+ Skript.registerExpression(ExprNBTv1_7_R3.class, net.minecraft.server.v1_7_R3.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
+ Skript.registerExpression(ExprItemNBTv1_7_R3.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
+ Skript.registerExpression(ExprTagOfv1_7_R3.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%");
+ //WARNING! HIGHLY EXPERIMENTAL, IT CAN CORRUPT WORLDS AT CURRENT VERSION, USE AT YOUR OWN RISK!
+ //Skript.registerExpression(ExprFileNBTv1_7_R3.class, net.minecraft.server.v1_7_R3.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%");
+ Classes.registerClass(new ClassInfo(net.minecraft.server.v1_7_R3.NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser() {
+ @Override
+ public String getVariableNamePattern() {
+ return ".+";
+ }
+
+ @Override
+ @Nullable
+ public net.minecraft.server.v1_7_R3.NBTTagCompound parse(String s, ParseContext context) {
+ net.minecraft.server.v1_7_R3.NBTTagCompound NBT = new net.minecraft.server.v1_7_R3.NBTTagCompound();
+ net.minecraft.server.v1_7_R3.NBTTagCompound NBT1 = (net.minecraft.server.v1_7_R3.NBTTagCompound) net.minecraft.server.v1_7_R3.MojangsonParser.parse(s);
+ NBT.set("", NBT1);
+ if (NBT.isEmpty() || NBT == null) {
+ return null;
+ }
+ return NBT;
+ }
+
+ @Override
+ public String toString(net.minecraft.server.v1_7_R3.NBTTagCompound compound, int arg1) {
+ return compound.toString();
+ }
+
+ @Override
+ public String toVariableNameString(net.minecraft.server.v1_7_R3.NBTTagCompound compound) {
+ return compound.toString();
+ }
+ }));
+ }
+ if (Bukkit.getVersion().contains("(MC: 1.7.10)")) {
+ getLogger().info("Successfully found 1.7.10! Registering version specific expressions...");
+ exprAmount += 3;
+ typeAmount += 1;
+ Skript.registerExpression(ExprNBTv1_7_R4.class, net.minecraft.server.v1_7_R4.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
+ Skript.registerExpression(ExprItemNBTv1_7_R4.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
+ Skript.registerExpression(ExprTagOfv1_7_R4.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%");
+ //WARNING! HIGHLY EXPERIMENTAL, IT CAN CORRUPT WORLDS AT CURRENT VERSION, USE AT YOUR OWN RISK!
+ //Skript.registerExpression(ExprFileNBTv1_7_R4.class, net.minecraft.server.v1_7_R4.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%");
+ Classes.registerClass(new ClassInfo(net.minecraft.server.v1_7_R4.NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser() {
+
+ @Override
+ public String getVariableNamePattern() {
+ return ".+";
+ }
+
+ @Override
+ @Nullable
+ public net.minecraft.server.v1_7_R4.NBTTagCompound parse(String s, ParseContext context) {
+ net.minecraft.server.v1_7_R4.NBTTagCompound NBT = new net.minecraft.server.v1_7_R4.NBTTagCompound();
+ net.minecraft.server.v1_7_R4.NBTTagCompound NBT1 = (net.minecraft.server.v1_7_R4.NBTTagCompound) net.minecraft.server.v1_7_R4.MojangsonParser.parse(s);
+ NBT.set("", NBT1);
+ if (NBT.isEmpty() || NBT == null) {
+ return null;
+ }
+ return NBT;
+ }
+
+ @Override
+ public String toString(net.minecraft.server.v1_7_R4.NBTTagCompound compound, int arg1) {
+ return compound.toString();
+ }
+
+ @Override
+ public String toVariableNameString(net.minecraft.server.v1_7_R4.NBTTagCompound compound) {
+ return compound.toString();
+ }
+ }));
+ }
+ if (Bukkit.getVersion().contains("(MC: 1.8)")) {
getLogger().info("Successfully found 1.8! Registering version specific expressions...");
exprAmount += 4;
typeAmount += 1;
@@ -80,7 +245,7 @@ public class SkStuff extends JavaPlugin {
public NBTTagCompound parse(String s, ParseContext context) {
NBTTagCompound NBT = new NBTTagCompound();
NBTTagCompound NBT1 = MojangsonParser.parse(s);
- NBT1.a(NBT);
+ NBT.a(NBT1);
if (NBT.isEmpty() || NBT == null) {
return null;
}
@@ -98,7 +263,7 @@ public class SkStuff extends JavaPlugin {
}
}));
}
- if (Bukkit.getVersion().contains("(MC: 1.8.3)")){
+ if (Bukkit.getVersion().contains("(MC: 1.8.3)")) {
getLogger().info("Successfully found 1.8.3! Registering version specific expressions...");
exprAmount += 4;
typeAmount += 1;
diff --git a/src/me/TheBukor/conditions/CondSelectionContains.java b/src/me/TheBukor/conditions/CondSelectionContains.java
index 4715d71..5f31926 100644
--- a/src/me/TheBukor/conditions/CondSelectionContains.java
+++ b/src/me/TheBukor/conditions/CondSelectionContains.java
@@ -34,8 +34,8 @@ public class CondSelectionContains extends Condition {
}
@Override
- public boolean check(Event e) {
- WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
+ public boolean check(final Event e) {
+ final WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (we.getSelection(player.getSingle(e)) == null) {
return false;
}
diff --git a/src/me/TheBukor/expressions/ExprFileNBTv1_8_R3.java b/src/me/TheBukor/expressions/ExprFileNBTv1_8_R3.java
index 4318e03..5209cf2 100644
--- a/src/me/TheBukor/expressions/ExprFileNBTv1_8_R3.java
+++ b/src/me/TheBukor/expressions/ExprFileNBTv1_8_R3.java
@@ -11,6 +11,7 @@ import java.util.zip.ZipException;
import javax.annotation.Nullable;
+import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import ch.njol.skript.Skript;
@@ -85,6 +86,7 @@ public class ExprFileNBTv1_8_R3 extends SimpleExpression {
NBTTagCompound NBT1 = MojangsonParser.parse(tags);
NBT.a(NBT1);
NBTCompressedStreamTools.a(NBT, os);
+ Bukkit.broadcastMessage("First - " + NBT.toString() + "\n\nSecond: " + NBT1.toString());
fis.close();
os.close();
} catch (EOFException ex) {
@@ -100,9 +102,11 @@ public class ExprFileNBTv1_8_R3 extends SimpleExpression {
try {
InputStream fis = new FileInputStream(file);
NBTTagCompound NBT = NBTCompressedStreamTools.a(fis);
+ Bukkit.broadcastMessage("First - " + NBT.toString());
OutputStream os = new FileOutputStream(file);
NBT.remove(tags);
NBTCompressedStreamTools.a(NBT, os);
+ Bukkit.broadcastMessage("\n\nSecond: " + NBT.toString());
fis.close();
os.close();
} catch (EOFException ex) {
diff --git a/src/me/TheBukor/expressions/ExprItemNBTv1_7_R1.java b/src/me/TheBukor/expressions/ExprItemNBTv1_7_R1.java
new file mode 100644
index 0000000..b8d0c35
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprItemNBTv1_7_R1.java
@@ -0,0 +1,61 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.util.Kleenean;
+import net.minecraft.server.v1_7_R1.MojangsonParser;
+import net.minecraft.server.v1_7_R1.NBTTagCompound;
+
+public class ExprItemNBTv1_7_R1 extends SimpleExpression {
+ private Expression itemStack;
+ private Expression string;
+
+ @Override
+ public Class extends ItemStack> getReturnType() {
+ return ItemStack.class;
+ }
+
+ @Override
+ public boolean isSingle() {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
+ itemStack = (Expression) expr[0];
+ string = (Expression) expr[1];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean arg1) {
+ return itemStack.toString(e, false) + " with custom NBT";
+ }
+
+ @Override
+ @Nullable
+ public ItemStack[] get(Event e) {
+ ItemStack item = itemStack.getSingle(e);
+ String newTags = string.getSingle(e);
+ if (item.getType() == Material.AIR || item == null) {
+ return null;
+ }
+ net.minecraft.server.v1_7_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ NBTTagCompound NBT = (NBTTagCompound) MojangsonParser.a(newTags);
+ if (NBT == null || NBT.isEmpty()) {
+ return new ItemStack[] { item };
+ }
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ return new ItemStack[] { newItem };
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/expressions/ExprItemNBTv1_7_R2.java b/src/me/TheBukor/expressions/ExprItemNBTv1_7_R2.java
new file mode 100644
index 0000000..1ef7f86
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprItemNBTv1_7_R2.java
@@ -0,0 +1,61 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.v1_7_R2.inventory.CraftItemStack;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.util.Kleenean;
+import net.minecraft.server.v1_7_R2.MojangsonParser;
+import net.minecraft.server.v1_7_R2.NBTTagCompound;
+
+public class ExprItemNBTv1_7_R2 extends SimpleExpression {
+ private Expression itemStack;
+ private Expression string;
+
+ @Override
+ public Class extends ItemStack> getReturnType() {
+ return ItemStack.class;
+ }
+
+ @Override
+ public boolean isSingle() {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
+ itemStack = (Expression) expr[0];
+ string = (Expression) expr[1];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean arg1) {
+ return itemStack.toString(e, false) + " with custom NBT";
+ }
+
+ @Override
+ @Nullable
+ public ItemStack[] get(Event e) {
+ ItemStack item = itemStack.getSingle(e);
+ String newTags = string.getSingle(e);
+ if (item.getType() == Material.AIR || item == null) {
+ return null;
+ }
+ net.minecraft.server.v1_7_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ NBTTagCompound NBT = (NBTTagCompound) MojangsonParser.parse(newTags);
+ if (NBT == null || NBT.isEmpty()) {
+ return new ItemStack[] { item };
+ }
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ return new ItemStack[] { newItem };
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/expressions/ExprItemNBTv1_7_R3.java b/src/me/TheBukor/expressions/ExprItemNBTv1_7_R3.java
new file mode 100644
index 0000000..0d4806e
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprItemNBTv1_7_R3.java
@@ -0,0 +1,61 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.util.Kleenean;
+import net.minecraft.server.v1_7_R3.MojangsonParser;
+import net.minecraft.server.v1_7_R3.NBTTagCompound;
+
+public class ExprItemNBTv1_7_R3 extends SimpleExpression {
+ private Expression itemStack;
+ private Expression string;
+
+ @Override
+ public Class extends ItemStack> getReturnType() {
+ return ItemStack.class;
+ }
+
+ @Override
+ public boolean isSingle() {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
+ itemStack = (Expression) expr[0];
+ string = (Expression) expr[1];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean arg1) {
+ return itemStack.toString(e, false) + " with custom NBT";
+ }
+
+ @Override
+ @Nullable
+ public ItemStack[] get(Event e) {
+ ItemStack item = itemStack.getSingle(e);
+ String newTags = string.getSingle(e);
+ if (item.getType() == Material.AIR || item == null) {
+ return null;
+ }
+ net.minecraft.server.v1_7_R3.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ NBTTagCompound NBT = (NBTTagCompound) MojangsonParser.parse(newTags);
+ if (NBT == null || NBT.isEmpty()) {
+ return new ItemStack[] { item };
+ }
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ return new ItemStack[] { newItem };
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/expressions/ExprItemNBTv1_7_R4.java b/src/me/TheBukor/expressions/ExprItemNBTv1_7_R4.java
new file mode 100644
index 0000000..e195129
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprItemNBTv1_7_R4.java
@@ -0,0 +1,61 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.util.Kleenean;
+import net.minecraft.server.v1_7_R4.MojangsonParser;
+import net.minecraft.server.v1_7_R4.NBTTagCompound;
+
+public class ExprItemNBTv1_7_R4 extends SimpleExpression {
+ private Expression itemStack;
+ private Expression string;
+
+ @Override
+ public Class extends ItemStack> getReturnType() {
+ return ItemStack.class;
+ }
+
+ @Override
+ public boolean isSingle() {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
+ itemStack = (Expression) expr[0];
+ string = (Expression) expr[1];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean arg1) {
+ return itemStack.toString(e, false) + " with custom NBT";
+ }
+
+ @Override
+ @Nullable
+ public ItemStack[] get(Event e) {
+ ItemStack item = itemStack.getSingle(e);
+ String newTags = string.getSingle(e);
+ if (item.getType() == Material.AIR || item == null) {
+ return null;
+ }
+ net.minecraft.server.v1_7_R4.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ NBTTagCompound NBT = (NBTTagCompound) MojangsonParser.parse(newTags);
+ if (NBT == null || NBT.isEmpty()) {
+ return new ItemStack[] { item };
+ }
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ return new ItemStack[] { newItem };
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/expressions/ExprNBTv1_7_R1.java b/src/me/TheBukor/expressions/ExprNBTv1_7_R1.java
new file mode 100644
index 0000000..0472291
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprNBTv1_7_R1.java
@@ -0,0 +1,194 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
+import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
+import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import ch.njol.skript.classes.Changer.ChangeMode;
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.skript.util.Slot;
+import ch.njol.util.Kleenean;
+import ch.njol.util.coll.CollectionUtils;
+import net.minecraft.server.v1_7_R1.MojangsonParser;
+import net.minecraft.server.v1_7_R1.NBTTagCompound;
+import net.minecraft.server.v1_7_R1.TileEntity;
+
+public class ExprNBTv1_7_R1 extends SimpleExpression {
+ private Expression> target;
+ private NBTTagCompound[] returned;
+
+ @Override
+ public Class extends NBTTagCompound> getReturnType() {
+ return NBTTagCompound.class;
+ }
+
+ @Override
+ public boolean isSingle() {
+ return true;
+ }
+
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
+ target = expr[0];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean arg1) {
+ return "the NBT of " + target.toString(e, false);
+ }
+
+ @Override
+ @Nullable
+ public NBTTagCompound[] get(Event e) {
+ Object tar = target.getSingle(e);
+ if (tar instanceof Entity) {
+ CraftEntity ent = (CraftEntity) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ ent.getHandle().e(NBT);
+ returned = new NBTTagCompound[] { NBT };
+
+ } else if (tar instanceof Block) {
+ Block block = (Block) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ TileEntity tileEntity = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ());
+ if (tileEntity == null) {
+ return null;
+ }
+ tileEntity.b(NBT);
+ returned = new NBTTagCompound[] { NBT };
+
+ } else if (tar instanceof ItemStack) {
+ ItemStack item = (ItemStack) tar;
+ if (item.getType() == Material.AIR) {
+ return null;
+ }
+ NBTTagCompound NBT = CraftItemStack.asNMSCopy(item).getTag();
+ if (NBT == null || NBT.isEmpty()) {
+ return null;
+ }
+ returned = new NBTTagCompound[] { NBT };
+ }
+ return returned;
+ }
+
+ @Override
+ public void change(Event e, Object[] delta, ChangeMode mode) {
+ Object tar = target.getSingle(e);
+ if (tar instanceof Entity) {
+ CraftEntity ent = (CraftEntity) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ ent.getHandle().e(NBT);
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.a(newTags);
+ NBT1.remove("UUIDMost");
+ NBT1.remove("UUIDLeast");
+ NBT1.remove("WorldUUIDLeast");
+ NBT1.remove("WorldUUIDMost");
+ NBT1.remove("Bukkit.updateLevel");
+ NBT.set("", NBT1);
+ ent.getHandle().f(NBT);
+ } else if (mode == ChangeMode.REMOVE) {
+ ent.getHandle().e(NBT);
+ for (Object s : delta) {
+ if (s != "UUIDMost" || s != "UUIDLeast" || s != "WorldUUIDMost" || s != "WorldUUIDLeast"
+ || s != "Bukkit.updateLevel") {
+ NBT.remove((String) s);
+ ent.getHandle().f(NBT);
+ }
+ }
+ }
+ } else if (tar instanceof Block) {
+ Block block = (Block) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ TileEntity tileEntity = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ());
+ if (tileEntity == null) {
+ return;
+ }
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ tileEntity.b(NBT);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.a(newTags);
+ NBT.set("", NBT1);;
+ NBT.setInt("x", block.getX());
+ NBT.setInt("y", block.getY());
+ NBT.setInt("z", block.getZ());
+ tileEntity.a(NBT);
+ tileEntity.update();
+ ((CraftWorld) block.getWorld()).getHandle().notify(tileEntity.x, tileEntity.y, tileEntity.z);;
+ } else if (mode == ChangeMode.REMOVE) {
+ tileEntity.b(NBT);
+ for (Object s : delta) {
+ if (s != "x" || s != "y" || s != "z" || s != "id") {
+ NBT.remove((String) s);
+ tileEntity.a(NBT);
+ tileEntity.update();
+ ((CraftWorld) block.getWorld()).getHandle().notify(tileEntity.x, tileEntity.y, tileEntity.z);
+ }
+ }
+ }
+ } else if (tar instanceof ItemStack) {
+ ItemStack item = (ItemStack) tar;
+ if (item.getType() == Material.AIR) {
+ return;
+ }
+ net.minecraft.server.v1_7_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ NBTTagCompound NBT = nmsItem.getTag();
+ if (NBT == null) {
+ NBT = new NBTTagCompound();
+ }
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.a(newTags);
+ NBT.set("", NBT1);
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ if (!(slot[0] instanceof Slot)) {
+ return;
+ }
+ ((Slot) slot[0]).setItem(newItem);
+ } else if (mode == ChangeMode.REMOVE) {
+ NBT = nmsItem.getTag();
+ if (NBT == null || NBT.isEmpty()) {
+ return;
+ }
+ for (Object s : delta) {
+ NBT.remove((String) s);
+ }
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ ((Slot) slot[0]).setItem(newItem);
+ } else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
+ nmsItem.setTag(new NBTTagCompound());
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ if (!(slot[0] instanceof Slot)) {
+ return;
+ }
+ ((Slot) slot[0]).setItem(newItem);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class>[] acceptChange(final ChangeMode mode) {
+ if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.DELETE
+ || mode == ChangeMode.RESET) {
+ return CollectionUtils.array(String.class);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/expressions/ExprNBTv1_7_R2.java b/src/me/TheBukor/expressions/ExprNBTv1_7_R2.java
new file mode 100644
index 0000000..f374e41
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprNBTv1_7_R2.java
@@ -0,0 +1,194 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.craftbukkit.v1_7_R2.CraftWorld;
+import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
+import org.bukkit.craftbukkit.v1_7_R2.inventory.CraftItemStack;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import ch.njol.skript.classes.Changer.ChangeMode;
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.skript.util.Slot;
+import ch.njol.util.Kleenean;
+import ch.njol.util.coll.CollectionUtils;
+import net.minecraft.server.v1_7_R2.MojangsonParser;
+import net.minecraft.server.v1_7_R2.NBTTagCompound;
+import net.minecraft.server.v1_7_R2.TileEntity;
+
+public class ExprNBTv1_7_R2 extends SimpleExpression {
+ private Expression> target;
+ private NBTTagCompound[] returned;
+
+ @Override
+ public Class extends NBTTagCompound> getReturnType() {
+ return NBTTagCompound.class;
+ }
+
+ @Override
+ public boolean isSingle() {
+ return true;
+ }
+
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
+ target = expr[0];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean arg1) {
+ return "the NBT of " + target.toString(e, false);
+ }
+
+ @Override
+ @Nullable
+ public NBTTagCompound[] get(Event e) {
+ Object tar = target.getSingle(e);
+ if (tar instanceof Entity) {
+ CraftEntity ent = (CraftEntity) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ ent.getHandle().e(NBT);
+ returned = new NBTTagCompound[] { NBT };
+
+ } else if (tar instanceof Block) {
+ Block block = (Block) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ TileEntity tileEntity = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ());
+ if (tileEntity == null) {
+ return null;
+ }
+ tileEntity.b(NBT);
+ returned = new NBTTagCompound[] { NBT };
+
+ } else if (tar instanceof ItemStack) {
+ ItemStack item = (ItemStack) tar;
+ if (item.getType() == Material.AIR) {
+ return null;
+ }
+ NBTTagCompound NBT = CraftItemStack.asNMSCopy(item).getTag();
+ if (NBT == null || NBT.isEmpty()) {
+ return null;
+ }
+ returned = new NBTTagCompound[] { NBT };
+ }
+ return returned;
+ }
+
+ @Override
+ public void change(Event e, Object[] delta, ChangeMode mode) {
+ Object tar = target.getSingle(e);
+ if (tar instanceof Entity) {
+ CraftEntity ent = (CraftEntity) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ ent.getHandle().e(NBT);
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT1.remove("UUIDMost");
+ NBT1.remove("UUIDLeast");
+ NBT1.remove("WorldUUIDLeast");
+ NBT1.remove("WorldUUIDMost");
+ NBT1.remove("Bukkit.updateLevel");
+ NBT.set("", NBT1);
+ ent.getHandle().f(NBT);
+ } else if (mode == ChangeMode.REMOVE) {
+ ent.getHandle().e(NBT);
+ for (Object s : delta) {
+ if (s != "UUIDMost" || s != "UUIDLeast" || s != "WorldUUIDMost" || s != "WorldUUIDLeast"
+ || s != "Bukkit.updateLevel") {
+ NBT.remove((String) s);
+ ent.getHandle().f(NBT);
+ }
+ }
+ }
+ } else if (tar instanceof Block) {
+ Block block = (Block) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ TileEntity tileEntity = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ());
+ if (tileEntity == null) {
+ return;
+ }
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ tileEntity.b(NBT);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT.set("", NBT1);;
+ NBT.setInt("x", block.getX());
+ NBT.setInt("y", block.getY());
+ NBT.setInt("z", block.getZ());
+ tileEntity.a(NBT);
+ tileEntity.update();
+ ((CraftWorld) block.getWorld()).getHandle().notify(tileEntity.x, tileEntity.y, tileEntity.z);;
+ } else if (mode == ChangeMode.REMOVE) {
+ tileEntity.b(NBT);
+ for (Object s : delta) {
+ if (s != "x" || s != "y" || s != "z" || s != "id") {
+ NBT.remove((String) s);
+ tileEntity.a(NBT);
+ tileEntity.update();
+ ((CraftWorld) block.getWorld()).getHandle().notify(tileEntity.x, tileEntity.y, tileEntity.z);
+ }
+ }
+ }
+ } else if (tar instanceof ItemStack) {
+ ItemStack item = (ItemStack) tar;
+ if (item.getType() == Material.AIR) {
+ return;
+ }
+ net.minecraft.server.v1_7_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ NBTTagCompound NBT = nmsItem.getTag();
+ if (NBT == null) {
+ NBT = new NBTTagCompound();
+ }
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT.set("", NBT1);
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ if (!(slot[0] instanceof Slot)) {
+ return;
+ }
+ ((Slot) slot[0]).setItem(newItem);
+ } else if (mode == ChangeMode.REMOVE) {
+ NBT = nmsItem.getTag();
+ if (NBT == null || NBT.isEmpty()) {
+ return;
+ }
+ for (Object s : delta) {
+ NBT.remove((String) s);
+ }
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ ((Slot) slot[0]).setItem(newItem);
+ } else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
+ nmsItem.setTag(new NBTTagCompound());
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ if (!(slot[0] instanceof Slot)) {
+ return;
+ }
+ ((Slot) slot[0]).setItem(newItem);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class>[] acceptChange(final ChangeMode mode) {
+ if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.DELETE
+ || mode == ChangeMode.RESET) {
+ return CollectionUtils.array(String.class);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/expressions/ExprNBTv1_7_R3.java b/src/me/TheBukor/expressions/ExprNBTv1_7_R3.java
new file mode 100644
index 0000000..abdfe5d
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprNBTv1_7_R3.java
@@ -0,0 +1,194 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
+import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
+import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import ch.njol.skript.classes.Changer.ChangeMode;
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.skript.util.Slot;
+import ch.njol.util.Kleenean;
+import ch.njol.util.coll.CollectionUtils;
+import net.minecraft.server.v1_7_R3.MojangsonParser;
+import net.minecraft.server.v1_7_R3.NBTTagCompound;
+import net.minecraft.server.v1_7_R3.TileEntity;
+
+public class ExprNBTv1_7_R3 extends SimpleExpression {
+ private Expression> target;
+ private NBTTagCompound[] returned;
+
+ @Override
+ public Class extends NBTTagCompound> getReturnType() {
+ return NBTTagCompound.class;
+ }
+
+ @Override
+ public boolean isSingle() {
+ return true;
+ }
+
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
+ target = expr[0];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean arg1) {
+ return "the NBT of " + target.toString(e, false);
+ }
+
+ @Override
+ @Nullable
+ public NBTTagCompound[] get(Event e) {
+ Object tar = target.getSingle(e);
+ if (tar instanceof Entity) {
+ CraftEntity ent = (CraftEntity) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ ent.getHandle().e(NBT);
+ returned = new NBTTagCompound[] { NBT };
+
+ } else if (tar instanceof Block) {
+ Block block = (Block) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ TileEntity tileEntity = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ());
+ if (tileEntity == null) {
+ return null;
+ }
+ tileEntity.b(NBT);
+ returned = new NBTTagCompound[] { NBT };
+
+ } else if (tar instanceof ItemStack) {
+ ItemStack item = (ItemStack) tar;
+ if (item.getType() == Material.AIR) {
+ return null;
+ }
+ NBTTagCompound NBT = CraftItemStack.asNMSCopy(item).getTag();
+ if (NBT == null || NBT.isEmpty()) {
+ return null;
+ }
+ returned = new NBTTagCompound[] { NBT };
+ }
+ return returned;
+ }
+
+ @Override
+ public void change(Event e, Object[] delta, ChangeMode mode) {
+ Object tar = target.getSingle(e);
+ if (tar instanceof Entity) {
+ CraftEntity ent = (CraftEntity) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ ent.getHandle().e(NBT);
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT1.remove("UUIDMost");
+ NBT1.remove("UUIDLeast");
+ NBT1.remove("WorldUUIDLeast");
+ NBT1.remove("WorldUUIDMost");
+ NBT1.remove("Bukkit.updateLevel");
+ NBT.set("", NBT1);
+ ent.getHandle().f(NBT);
+ } else if (mode == ChangeMode.REMOVE) {
+ ent.getHandle().e(NBT);
+ for (Object s : delta) {
+ if (s != "UUIDMost" || s != "UUIDLeast" || s != "WorldUUIDMost" || s != "WorldUUIDLeast"
+ || s != "Bukkit.updateLevel") {
+ NBT.remove((String) s);
+ ent.getHandle().f(NBT);
+ }
+ }
+ }
+ } else if (tar instanceof Block) {
+ Block block = (Block) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ TileEntity tileEntity = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ());
+ if (tileEntity == null) {
+ return;
+ }
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ tileEntity.b(NBT);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT.set("", NBT1);;
+ NBT.setInt("x", block.getX());
+ NBT.setInt("y", block.getY());
+ NBT.setInt("z", block.getZ());
+ tileEntity.a(NBT);
+ tileEntity.update();
+ ((CraftWorld) block.getWorld()).getHandle().notify(tileEntity.x, tileEntity.y, tileEntity.z);;
+ } else if (mode == ChangeMode.REMOVE) {
+ tileEntity.b(NBT);
+ for (Object s : delta) {
+ if (s != "x" || s != "y" || s != "z" || s != "id") {
+ NBT.remove((String) s);
+ tileEntity.a(NBT);
+ tileEntity.update();
+ ((CraftWorld) block.getWorld()).getHandle().notify(tileEntity.x, tileEntity.y, tileEntity.z);
+ }
+ }
+ }
+ } else if (tar instanceof ItemStack) {
+ ItemStack item = (ItemStack) tar;
+ if (item.getType() == Material.AIR) {
+ return;
+ }
+ net.minecraft.server.v1_7_R3.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ net.minecraft.server.v1_7_R3.NBTTagCompound NBT = nmsItem.getTag();
+ if (NBT == null) {
+ NBT = new NBTTagCompound();
+ }
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT.set("", NBT1);
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ if (!(slot[0] instanceof Slot)) {
+ return;
+ }
+ ((Slot) slot[0]).setItem(newItem);
+ } else if (mode == ChangeMode.REMOVE) {
+ NBT = nmsItem.getTag();
+ if (NBT == null || NBT.isEmpty()) {
+ return;
+ }
+ for (Object s : delta) {
+ NBT.remove((String) s);
+ }
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ ((Slot) slot[0]).setItem(newItem);
+ } else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
+ nmsItem.setTag(new NBTTagCompound());
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ if (!(slot[0] instanceof Slot)) {
+ return;
+ }
+ ((Slot) slot[0]).setItem(newItem);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class>[] acceptChange(final ChangeMode mode) {
+ if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.DELETE
+ || mode == ChangeMode.RESET) {
+ return CollectionUtils.array(String.class);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/expressions/ExprNBTv1_7_R4.java b/src/me/TheBukor/expressions/ExprNBTv1_7_R4.java
new file mode 100644
index 0000000..2d44eef
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprNBTv1_7_R4.java
@@ -0,0 +1,194 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
+import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
+import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import ch.njol.skript.classes.Changer.ChangeMode;
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.skript.util.Slot;
+import ch.njol.util.Kleenean;
+import ch.njol.util.coll.CollectionUtils;
+import net.minecraft.server.v1_7_R4.MojangsonParser;
+import net.minecraft.server.v1_7_R4.NBTTagCompound;
+import net.minecraft.server.v1_7_R4.TileEntity;
+
+public class ExprNBTv1_7_R4 extends SimpleExpression {
+ private Expression> target;
+ private NBTTagCompound[] returned;
+
+ @Override
+ public Class extends NBTTagCompound> getReturnType() {
+ return NBTTagCompound.class;
+ }
+
+ @Override
+ public boolean isSingle() {
+ return true;
+ }
+
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
+ target = expr[0];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean arg1) {
+ return "the NBT of " + target.toString(e, false);
+ }
+
+ @Override
+ @Nullable
+ public NBTTagCompound[] get(Event e) {
+ Object tar = target.getSingle(e);
+ if (tar instanceof Entity) {
+ CraftEntity ent = (CraftEntity) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ ent.getHandle().e(NBT);
+ returned = new NBTTagCompound[] { NBT };
+
+ } else if (tar instanceof Block) {
+ Block block = (Block) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ TileEntity tileEntity = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ());
+ if (tileEntity == null) {
+ return null;
+ }
+ tileEntity.b(NBT);
+ returned = new NBTTagCompound[] { NBT };
+
+ } else if (tar instanceof ItemStack) {
+ ItemStack item = (ItemStack) tar;
+ if (item.getType() == Material.AIR) {
+ return null;
+ }
+ NBTTagCompound NBT = CraftItemStack.asNMSCopy(item).getTag();
+ if (NBT == null || NBT.isEmpty()) {
+ return null;
+ }
+ returned = new NBTTagCompound[] { NBT };
+ }
+ return returned;
+ }
+
+ @Override
+ public void change(Event e, Object[] delta, ChangeMode mode) {
+ Object tar = target.getSingle(e);
+ if (tar instanceof Entity) {
+ CraftEntity ent = (CraftEntity) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ ent.getHandle().e(NBT);
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT1.remove("UUIDMost");
+ NBT1.remove("UUIDLeast");
+ NBT1.remove("WorldUUIDLeast");
+ NBT1.remove("WorldUUIDMost");
+ NBT1.remove("Bukkit.updateLevel");
+ NBT.set("", NBT1);
+ ent.getHandle().f(NBT);
+ } else if (mode == ChangeMode.REMOVE) {
+ ent.getHandle().e(NBT);
+ for (Object s : delta) {
+ if (s != "UUIDMost" || s != "UUIDLeast" || s != "WorldUUIDMost" || s != "WorldUUIDLeast"
+ || s != "Bukkit.updateLevel") {
+ NBT.remove((String) s);
+ ent.getHandle().f(NBT);
+ }
+ }
+ }
+ } else if (tar instanceof Block) {
+ Block block = (Block) tar;
+ NBTTagCompound NBT = new NBTTagCompound();
+ TileEntity tileEntity = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(block.getX(), block.getY(), block.getZ());
+ if (tileEntity == null) {
+ return;
+ }
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ tileEntity.b(NBT);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT.set("", NBT1);;
+ NBT.setInt("x", block.getX());
+ NBT.setInt("y", block.getY());
+ NBT.setInt("z", block.getZ());
+ tileEntity.a(NBT);
+ tileEntity.update();
+ ((CraftWorld) block.getWorld()).getHandle().notify(tileEntity.x, tileEntity.y, tileEntity.z);;
+ } else if (mode == ChangeMode.REMOVE) {
+ tileEntity.b(NBT);
+ for (Object s : delta) {
+ if (s != "x" || s != "y" || s != "z" || s != "id") {
+ NBT.remove((String) s);
+ tileEntity.a(NBT);
+ tileEntity.update();
+ ((CraftWorld) block.getWorld()).getHandle().notify(tileEntity.x, tileEntity.y, tileEntity.z);
+ }
+ }
+ }
+ } else if (tar instanceof ItemStack) {
+ ItemStack item = (ItemStack) tar;
+ if (item.getType() == Material.AIR) {
+ return;
+ }
+ net.minecraft.server.v1_7_R4.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ NBTTagCompound NBT = nmsItem.getTag();
+ if (NBT == null) {
+ NBT = new NBTTagCompound();
+ }
+ if (mode == ChangeMode.ADD) {
+ String newTags = (String) (delta[0]);
+ NBTTagCompound NBT1 = (NBTTagCompound) MojangsonParser.parse(newTags);
+ NBT.set("", NBT1);
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ if (!(slot[0] instanceof Slot)) {
+ return;
+ }
+ ((Slot) slot[0]).setItem(newItem);
+ } else if (mode == ChangeMode.REMOVE) {
+ NBT = nmsItem.getTag();
+ if (NBT == null || NBT.isEmpty()) {
+ return;
+ }
+ for (Object s : delta) {
+ NBT.remove((String) s);
+ }
+ nmsItem.setTag(NBT);
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ ((Slot) slot[0]).setItem(newItem);
+ } else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
+ nmsItem.setTag(new NBTTagCompound());
+ ItemStack newItem = CraftItemStack.asCraftMirror(nmsItem);
+ Object[] slot = target.getSource().getAll(e);
+ if (!(slot[0] instanceof Slot)) {
+ return;
+ }
+ ((Slot) slot[0]).setItem(newItem);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class>[] acceptChange(final ChangeMode mode) {
+ if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.DELETE
+ || mode == ChangeMode.RESET) {
+ return CollectionUtils.array(String.class);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/expressions/ExprTagOfv1_7_R1.java b/src/me/TheBukor/expressions/ExprTagOfv1_7_R1.java
new file mode 100644
index 0000000..431adca
--- /dev/null
+++ b/src/me/TheBukor/expressions/ExprTagOfv1_7_R1.java
@@ -0,0 +1,83 @@
+package me.TheBukor.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.event.Event;
+
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.util.Kleenean;
+import net.minecraft.server.v1_7_R1.NBTTagCompound;
+import net.minecraft.server.v1_7_R1.NBTTagList;
+
+public class ExprTagOfv1_7_R1 extends SimpleExpression