From 7d938de2912e41e0c731d734a77805cedf202301 Mon Sep 17 00:00:00 2001 From: TheBukor Date: Tue, 22 Mar 2016 21:17:36 -0300 Subject: [PATCH] Fixes, two new features. Fixed the new Follow pathfinder goals. Added new optional syntax to NBTListIndex. Removed unused code in NBTOf. Added new NMS Method: makeClientSay. Added ClientChat effect. Added ResourcePackSound effect (1.9). --- .settings/org.eclipse.jdt.core.prefs | 1 + src/me/TheBukor/SkStuff/SkStuff.java | 19 ++++++++------- .../SkStuff/expressions/ExprGlideState.java | 2 +- .../SkStuff/expressions/ExprNBTListIndex.java | 11 ++++++--- .../SkStuff/expressions/ExprNBTOf.java | 24 ++----------------- .../PathfinderGoalFollow_v1_8_R3.java | 7 +++++- .../PathfinderGoalFollow_v1_9_R1.java | 7 +++++- .../TheBukor/SkStuff/util/NMSInterface.java | 3 +++ src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java | 20 +++++++++++----- src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java | 11 +++++++++ src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java | 11 ++++++++- 11 files changed, 72 insertions(+), 44 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 838bd9d..980b98c 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,6 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 diff --git a/src/me/TheBukor/SkStuff/SkStuff.java b/src/me/TheBukor/SkStuff/SkStuff.java index 553eb8e..370db1d 100644 --- a/src/me/TheBukor/SkStuff/SkStuff.java +++ b/src/me/TheBukor/SkStuff/SkStuff.java @@ -32,6 +32,7 @@ import ch.njol.skript.registrations.EventValues; import ch.njol.skript.util.Getter; import me.TheBukor.SkStuff.conditions.CondSelectionContains; import me.TheBukor.SkStuff.effects.EffClearPathGoals; +import me.TheBukor.SkStuff.effects.EffClientChat; import me.TheBukor.SkStuff.effects.EffDrainLiquid; import me.TheBukor.SkStuff.effects.EffDrawLineWE; import me.TheBukor.SkStuff.effects.EffGZipFile; @@ -45,7 +46,7 @@ import me.TheBukor.SkStuff.effects.EffPasteSchematic; import me.TheBukor.SkStuff.effects.EffRememberChanges; import me.TheBukor.SkStuff.effects.EffRemovePathGoal; import me.TheBukor.SkStuff.effects.EffReplaceBlocksWE; -import me.TheBukor.SkStuff.effects.EffRestoreInv; +import me.TheBukor.SkStuff.effects.EffResourceSound; import me.TheBukor.SkStuff.effects.EffSetBlocksWE; import me.TheBukor.SkStuff.effects.EffSetPathGoal; import me.TheBukor.SkStuff.effects.EffShowEntityEffect; @@ -63,6 +64,7 @@ import me.TheBukor.SkStuff.expressions.ExprFireProof; import me.TheBukor.SkStuff.expressions.ExprFlagOfWGRegion; import me.TheBukor.SkStuff.expressions.ExprFlagsOfWGRegion; import me.TheBukor.SkStuff.expressions.ExprGlideState; +import me.TheBukor.SkStuff.expressions.ExprInventoryOwner; import me.TheBukor.SkStuff.expressions.ExprItemNBT; import me.TheBukor.SkStuff.expressions.ExprMCIdOf; import me.TheBukor.SkStuff.expressions.ExprMCIdToItem; @@ -75,7 +77,6 @@ import me.TheBukor.SkStuff.expressions.ExprSchematicArea; import me.TheBukor.SkStuff.expressions.ExprSelectionArea; import me.TheBukor.SkStuff.expressions.ExprSelectionOfPlayer; import me.TheBukor.SkStuff.expressions.ExprSelectionPos; -import me.TheBukor.SkStuff.expressions.ExprSerializedInv; import me.TheBukor.SkStuff.expressions.ExprTagOf; import me.TheBukor.SkStuff.expressions.ExprTimespanToNumber; import me.TheBukor.SkStuff.expressions.ExprToLowerCase; @@ -104,20 +105,19 @@ public class SkStuff extends JavaPlugin { getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!"); getLogger().info("Registering general non version specific stuff..."); Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0¦firework[s] explo(de|sion)|1¦hurt|2¦[[iron] golem] (give|offer) (rose|poppy)|3¦[sheep] eat grass|4¦wolf shake) at %entity%"); - Skript.registerEffect(EffRestoreInv.class, "[(skstuff|1.9)] restore %inventory% (to|from) [serialized [inventory [conents]]] %string%"); Skript.registerExpression(ExprToUpperCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] (cap[ital]s|upper[ ]case)", "convert %string% to [all] (cap[ital]s|upper[ ]case)", "capitalize [all] [char[acter]s (of|in)] %string%"); Skript.registerExpression(ExprToLowerCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] lower[ ]case", "convert %string% to [all] lower[ ]case", "un[( |-)]capitalize [all] [char[acter]s (of|in)] %string%"); Skript.registerExpression(ExprWordsToUpperCase.class, String.class, ExpressionType.SIMPLE, "(first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% [converted] to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "convert (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "capitalize (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])"); Skript.registerExpression(ExprTimespanToNumber.class, Number.class, ExpressionType.SIMPLE, "%timespan% [converted] [in]to (0¦ticks|1¦sec[ond]s|2¦min[ute]s|3¦hours|4¦days)"); Skript.registerExpression(ExprClickedInventory.class, Inventory.class, ExpressionType.SIMPLE, "[skstuff] clicked inventory"); - Skript.registerExpression(ExprSerializedInv.class, String.class, ExpressionType.PROPERTY, "[(skstuff|1.9)] serialized [contents of] %inventory%"); - effAmount += 2; + Skript.registerExpression(ExprInventoryOwner.class, Object.class, ExpressionType.PROPERTY, "[inventory] (owner|holder) of %inventory%", "%inventory%'s [inventory] (owner|holder)"); + effAmount += 1; exprAmount += 6; if (Skript.isRunningMinecraft(1, 9)) { - getLogger().info("WOW! You're using Minecraft 1.9! Lemme register some cool elytra stuff right away!"); + getLogger().info("WOW! You're using Minecraft 1.9! Lemme register some cool stuff and fixes right away!"); + Skript.registerEffect(EffResourceSound.class, "play [raw] [([resource[ ]]pack)] sound %string% for %players% at %location% [[with] (0¦volume|1¦pitch) %-number%[[(,| and)] (0¦pitch|1¦volume) %-number%]]"); Skript.registerEvent("Elytra glide toggle", SimpleEvent.class, EntityToggleGlideEvent.class, "[entity] elytra (fl(y|ight)|glid(e|ing)) toggl(e|ing)", "[entity] toggle elytra (fl(y|ight)|glid(e|ing))"); Skript.registerExpression(ExprGlideState.class, Boolean.class, ExpressionType.PROPERTY, "elytra (fl(y|ight)|glid(e|ing)) state of %livingentity%", "%livingentity%'s elytra (fl(y|ight)|glid(e|ing)) state"); - EventValues.registerEventValue(EntityToggleGlideEvent.class, Entity.class, new Getter() { @Override @Nullable @@ -125,7 +125,7 @@ public class SkStuff extends JavaPlugin { return e.getEntity(); } }, 0); - + effAmount += 1; evtAmount += 1; exprAmount += 1; } @@ -136,6 +136,7 @@ public class SkStuff extends JavaPlugin { Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %*entitydatas%[, radius %-number%[, speed %-number%[, speed (if|when) (close|near) %-number%]]]|1¦break door[s]|2¦breed[,[move[ment]] speed %-number%]|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))[, [move[ment]] speed %-number%]|5¦(float (in[side]|on) water|swim)|6¦follow (owner|tamer)[, speed %-number%[, min[imum] distance %-number%[, max[imum] distance %-number%]]]|7¦follow (adult|parent)[s][, [move[ment]] speed %-number%]|8¦(fight back|react to|target) (damager|attacker) [[of] type] %*entitydatas%[, call ([for] help|reinforcement) %-boolean%]|9¦o(c|z)elot jump on blocks[, [move[ment]] speed %-number%]|10¦leap at target[, [leap] height %-number%]|11¦look at %*entitydatas%[, (radius|max[imum] distance) %-number%]|12¦melee attack %*entitydatas%[, [move[ment]] speed %-number%[, (memorize|do('nt| not) forget) target [for [a] long[er] time] %-boolean%]]|13¦move to[wards] target[, [move[ment]] speed %-number%[, (radius|max[imum] distance) %-number%]]|14¦target nearest [entity [of] type] %*entitydatas%[, check sight %-boolean%]|15¦o(c|z)elot attack|16¦open door[s]|17¦(panic|flee)[, [move[ment]] speed %-number%]|18¦look around randomly|19¦(walk around randomly|wander)[, [move[ment]] speed %-number%[, min[imum] [of] %-timespan% between mov(e[ment][s]|ing)]]|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim around|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦((call|summon|wake) [other] [hidden] silverfish[es])|26¦[enderman] pick[[ ]up] block[s]|27¦[enderman] place block[s]|28¦[enderman] attack player (staring|looking) at [their] eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) %-itemstack%[, [move[ment]] speed %number%[, scared of player movement %-boolean%]]|32¦target [random] %*entitydatas% (if|when) (not |un)tamed|33¦guardian attack [entities]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow %*entitydatas%[, radius %-number%[, speed %-number%[, [custom[ ]]name[d] %-string%]]]) to %livingentities%"); Skript.registerEffect(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump"); Skript.registerEffect(EffGZipFile.class, "create [a] gzip[ped] file [at] [path] %string%"); + Skript.registerEffect(EffClientChat.class, "make %player% (say|chat) %string% client[( |-)]side", "force %player% to (say|chat) %string% client[( |-)]side"); Skript.registerExpression(ExprNBTOf.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %~object%", "%~object%'s nbt[[ ]tag[s]]"); Skript.registerExpression(ExprItemNBT.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%"); Skript.registerExpression(ExprTagOf.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]]tag %string% of [[nbt] compound] %compound%"); @@ -149,7 +150,7 @@ public class SkStuff extends JavaPlugin { Skript.registerExpression(ExprMCIdToItem.class, ItemStack.class, ExpressionType.SIMPLE, "item[[ ](stack|type)] (of|from) (mc|minecraft) [(string|native)] id %string%"); nmsMethods.registerCompoundClassInfo(); nmsMethods.registerNBTListClassInfo(); - effAmount += 5; + effAmount += 6; exprAmount += 11; typeAmount += 2; } diff --git a/src/me/TheBukor/SkStuff/expressions/ExprGlideState.java b/src/me/TheBukor/SkStuff/expressions/ExprGlideState.java index 6d5383f..db74d15 100644 --- a/src/me/TheBukor/SkStuff/expressions/ExprGlideState.java +++ b/src/me/TheBukor/SkStuff/expressions/ExprGlideState.java @@ -44,7 +44,7 @@ public class ExprGlideState extends SimpleExpression { protected Boolean[] get(Event e) { LivingEntity ent = entity.getSingle(e); EntityLiving nmsEntity = ((CraftLivingEntity) ent).getHandle(); - return new Boolean[] { nmsEntity.cB() }; + return new Boolean[] { nmsEntity.getFlag(7) }; } @SuppressWarnings("unchecked") diff --git a/src/me/TheBukor/SkStuff/expressions/ExprNBTListIndex.java b/src/me/TheBukor/SkStuff/expressions/ExprNBTListIndex.java index 3afdd3d..aa675d1 100644 --- a/src/me/TheBukor/SkStuff/expressions/ExprNBTListIndex.java +++ b/src/me/TheBukor/SkStuff/expressions/ExprNBTListIndex.java @@ -32,14 +32,19 @@ public class ExprNBTListIndex extends SimpleExpression { @SuppressWarnings("unchecked") @Override public boolean init(Expression[] expr, int matchedPattern, Kleenean arg2, ParseResult result) { - nbtList = (Expression) expr[0]; - index = (Expression) expr[1]; + if (matchedPattern == 0) { + nbtList = (Expression) expr[0]; + index = (Expression) expr[1]; + } else { + index = (Expression) expr[0]; + nbtList = (Expression) expr[1]; + } return true; } @Override public String toString(@Nullable Event e, boolean debug) { - return "NBT list" + nbtList.toString(e, debug) + " index " + index.toString(e, debug); + return "index " + index.toString(e, debug) + " from nbt list " + nbtList.toString(e, debug); } @Override diff --git a/src/me/TheBukor/SkStuff/expressions/ExprNBTOf.java b/src/me/TheBukor/SkStuff/expressions/ExprNBTOf.java index d96ac42..d32e63f 100644 --- a/src/me/TheBukor/SkStuff/expressions/ExprNBTOf.java +++ b/src/me/TheBukor/SkStuff/expressions/ExprNBTOf.java @@ -104,28 +104,8 @@ public class ExprNBTOf extends SimpleExpression { SkStuff.getNMSMethods().setTileNBT((Block) tar, blockNBT); } } else if (tar instanceof ItemStack) { - Object itemNBT = SkStuff.getNMSMethods().getItemNBT((ItemStack) tar); - if (mode == ChangeMode.ADD) { - SkStuff.getNMSMethods().addToCompound(itemNBT, parsedNBT); - ItemStack newItem = SkStuff.getNMSMethods().getItemWithNBT((ItemStack) tar, itemNBT); - Object slot = target.getSource().getSingle(e); - if (slot instanceof Slot) { - ((Slot) slot).setItem(newItem); - } - } else if (mode == ChangeMode.REMOVE) { - String[] toRemove = Arrays.copyOf(delta, delta.length, String[].class); - SkStuff.getNMSMethods().removeFromCompound(itemNBT, toRemove); - ItemStack newItem = SkStuff.getNMSMethods().getItemWithNBT((ItemStack) tar, itemNBT); - Object slot = target.getSource().getSingle(e); - if (slot instanceof Slot) { - ((Slot) slot).setItem(newItem); - } - } else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) { - ItemStack newItem = SkStuff.getNMSMethods().getItemWithNBT((ItemStack) tar, null); - Object slot = target.getSource().getSingle(e); - if (slot instanceof Slot) { - ((Slot) slot).setItem(newItem); - } + if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.DELETE || mode == ChangeMode.RESET) { + Skript.warning("Failed to change the NBT of an item: Itemstack didn't have any slot attached to it."); } } else if (tar instanceof Slot) { ItemStack slotItem = ((Slot) tar).getItem(); diff --git a/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_8_R3.java b/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_8_R3.java index af47b46..92b9837 100644 --- a/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_8_R3.java +++ b/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_8_R3.java @@ -53,9 +53,14 @@ public class PathfinderGoalFollow_v1_8_R3 extends PathfinderGoal { @Override public boolean b() { if (followed.dead) { + followed = null; return false; + } else if (followed.h(follower) < 9.0D || followed.h(follower) > Math.pow(radius, 2)) { // h() = distanceSquaredFrom() + return false; // if 3 blocks away or not in radius, stop moving. + //Maybe I'll add a teleport feature later. } else if (isByName) { if (!followed.getCustomName().equals(customName)) { + followed = null; return false; } } @@ -65,6 +70,6 @@ public class PathfinderGoalFollow_v1_8_R3 extends PathfinderGoal { // c() is execute() @Override public void c() { - follower.getNavigation().a(followed, speed); + follower.getNavigation().a(followed, speed); // a() means moveTo() } } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_9_R1.java b/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_9_R1.java index 08445ba..8348660 100644 --- a/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_9_R1.java +++ b/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_9_R1.java @@ -53,9 +53,14 @@ public class PathfinderGoalFollow_v1_9_R1 extends PathfinderGoal { @Override public boolean b() { if (followed.dead) { + followed = null; return false; + } else if (followed.h(follower) < 9.0D || followed.h(follower) > Math.pow(radius, 2)) { // h() = distanceSquaredFrom() + return false; // if 3 blocks away or not in radius, stop moving. + //Maybe I'll add a teleport feature later. } else if (isByName) { if (!followed.getCustomName().equals(customName)) { + followed = null; return false; } } @@ -65,6 +70,6 @@ public class PathfinderGoalFollow_v1_9_R1 extends PathfinderGoal { // c() is execute() @Override public void c() { - follower.getNavigation().a(followed, speed); + follower.getNavigation().a(followed, speed); // a() means moveTo() } } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/util/NMSInterface.java b/src/me/TheBukor/SkStuff/util/NMSInterface.java index dcf265c..b0c9158 100644 --- a/src/me/TheBukor/SkStuff/util/NMSInterface.java +++ b/src/me/TheBukor/SkStuff/util/NMSInterface.java @@ -4,6 +4,7 @@ import java.io.File; import org.bukkit.block.Block; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public interface NMSInterface { @@ -57,4 +58,6 @@ public interface NMSInterface { public String getMCId(ItemStack itemStack); public ItemStack getItemFromMcId(String mcId); + + void makeClientSay(String msg, Player p); } 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 bbe17e0..216a4ae 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java @@ -22,7 +22,9 @@ 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.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import ch.njol.skript.Skript; @@ -49,7 +51,7 @@ import net.minecraft.server.v1_7_R4.NBTTagShort; import net.minecraft.server.v1_7_R4.NBTTagString; import net.minecraft.server.v1_7_R4.TileEntity; import net.minecraft.server.v1_7_R4.World; -import net.minecraft.server.v1_9_R1.MinecraftKey; +import net.minecraft.server.v1_7_R4.PacketPlayInChat; public class NMS_v1_7_R4 implements NMSInterface { @@ -358,8 +360,10 @@ public class NMS_v1_7_R4 implements NMSInterface { public NBTTagCompound getItemNBT(ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) return null; - NBTTagCompound NBT = CraftItemStack.asNMSCopy(itemStack).getTag(); - return NBT; + NBTTagCompound itemNBT = CraftItemStack.asNMSCopy(itemStack).getTag(); + if (itemNBT == null || itemNBT.isEmpty()) + itemNBT = null; + return itemNBT; } @Override @@ -488,8 +492,12 @@ public class NMS_v1_7_R4 implements NMSInterface { @Override public ItemStack getItemFromMcId(String mcId) { - MinecraftKey mcKey = new MinecraftKey(mcId); - Item nmsItem = (Item) Item.REGISTRY.get(mcKey); - return CraftItemStack.asNewCraftStack(nmsItem); + return null; //Not supported in 1.7 + } + + @Override + public void makeClientSay(String msg, Player p) { + PacketPlayInChat chatPacket = new PacketPlayInChat(msg); + ((CraftPlayer) p).getHandle().playerConnection.a(chatPacket); } } \ No newline at end of file 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 c1ea172..ddd6f24 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java @@ -19,7 +19,9 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import ch.njol.skript.Skript; @@ -52,6 +54,7 @@ import net.minecraft.server.v1_8_R3.PathfinderGoal; import net.minecraft.server.v1_8_R3.PathfinderGoalSelector; import net.minecraft.server.v1_8_R3.TileEntity; import net.minecraft.server.v1_8_R3.World; +import net.minecraft.server.v1_8_R3.PacketPlayInChat; public class NMS_v1_8_R3 implements NMSInterface { @@ -409,6 +412,8 @@ public class NMS_v1_8_R3 implements NMSInterface { if (itemStack == null || itemStack.getType() == Material.AIR) return null; NBTTagCompound itemNBT = CraftItemStack.asNMSCopy(itemStack).getTag(); + if (itemNBT == null || itemNBT.isEmpty()) + itemNBT = null; return itemNBT; } @@ -531,4 +536,10 @@ public class NMS_v1_8_R3 implements NMSInterface { Item nmsItem = (Item) Item.REGISTRY.get(mcKey); return CraftItemStack.asNewCraftStack(nmsItem); } + + @Override + public void makeClientSay(String msg, Player p) { + PacketPlayInChat chatPacket = new PacketPlayInChat(msg); + ((CraftPlayer) p).getHandle().playerConnection.a(chatPacket); + } } \ No newline at end of file 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 269ed3f..2a9589f 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java @@ -18,8 +18,10 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import ch.njol.skript.Skript; @@ -49,6 +51,7 @@ import net.minecraft.server.v1_9_R1.NBTTagList; import net.minecraft.server.v1_9_R1.NBTTagLong; import net.minecraft.server.v1_9_R1.NBTTagShort; import net.minecraft.server.v1_9_R1.NBTTagString; +import net.minecraft.server.v1_9_R1.PacketPlayInChat; import net.minecraft.server.v1_9_R1.PathfinderGoal; import net.minecraft.server.v1_9_R1.PathfinderGoalSelector; import net.minecraft.server.v1_9_R1.TileEntity; @@ -410,7 +413,7 @@ public class NMS_v1_9_R1 implements NMSInterface { if (itemStack == null || itemStack.getType() == Material.AIR) return null; NBTTagCompound itemNBT = CraftItemStack.asNMSCopy(itemStack).getTag(); - if (itemNBT.isEmpty()) + if (itemNBT == null || itemNBT.isEmpty()) itemNBT = null; return itemNBT; } @@ -536,4 +539,10 @@ public class NMS_v1_9_R1 implements NMSInterface { Item nmsItem = (Item) Item.REGISTRY.get(mcKey); return CraftItemStack.asNewCraftStack(nmsItem); } + + @Override + public void makeClientSay(String msg, Player p) { + PacketPlayInChat chatPacket = new PacketPlayInChat(msg); + ((CraftPlayer) p).getHandle().playerConnection.a(chatPacket); + } } \ No newline at end of file