From f13d121919272c7b438a7fb12db46a5411e73b9c Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 19 May 2016 01:32:57 +0800 Subject: [PATCH] v2.1.3 --- .../St3venAU/plugins/ArmorStandTools/Main.java | 12 +++++++++--- .../plugins/ArmorStandTools/MainListener.java | 13 +++++++++---- .../gmail/St3venAU/plugins/ArmorStandTools/NBT.java | 4 ++-- src/config.yml | 2 +- src/language.yml | 2 +- src/plugin.yml | 2 +- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java index 8efc502..43e5346 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java @@ -26,13 +26,14 @@ public class Main extends JavaPlugin { public final HashMap savedInventories = new HashMap(); private final EulerAngle zero = new EulerAngle(0D, 0D, 0D); static String NMS_VERSION; - static boolean oneNine; + static boolean oneNine, oneNineFour; @Override public void onEnable() { NMS_VERSION = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; oneNine = NMS_VERSION.startsWith("v1_9"); - getServer().getPluginManager().registerEvents(new MainListener(this), this); + oneNineFour = NMS_VERSION.startsWith("v1_9_R2"); + getServer().getPluginManager().registerEvents(new MainListener(this), this); CommandExecutor ce = new Commands(this); getCommand("astools").setExecutor(ce); Config.reload(this); @@ -183,7 +184,12 @@ public class Main extends JavaPlugin { clone.setChestplate(as.getChestplate()); clone.setLeggings(as.getLeggings()); clone.setBoots(as.getBoots()); - clone.setItemInHand(as.getItemInHand()); + if(oneNine) { + clone.getEquipment().setItemInMainHand(as.getEquipment().getItemInMainHand()); + clone.getEquipment().setItemInOffHand(as.getEquipment().getItemInOffHand()); + } else { + clone.setItemInHand(as.getItemInHand()); + } clone.setHeadPose(as.getHeadPose()); clone.setBodyPose(as.getBodyPose()); clone.setLeftArmPose(as.getLeftArmPose()); diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java index 242a96b..86846d5 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java @@ -332,10 +332,15 @@ public class MainListener implements Listener { @EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - if(event.getEntity() instanceof ArmorStand && event.getDamager() instanceof Player && ArmorStandTool.isHoldingTool((Player) event.getDamager())) { - event.setCancelled(true); - if (noCooldown(event.getDamager())) { - Utils.cycleInventory((Player) event.getDamager()); + if(event.getEntity() instanceof ArmorStand) { + if(NBT.isInvulnerable((ArmorStand) event.getEntity())) { + event.setCancelled(true); + } + if(event.getDamager() instanceof Player && ArmorStandTool.isHoldingTool((Player) event.getDamager())) { + event.setCancelled(true); + if(noCooldown(event.getDamager())) { + Utils.cycleInventory((Player) event.getDamager()); + } } } } diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/NBT.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/NBT.java index be5c41f..5a564cc 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/NBT.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/NBT.java @@ -24,7 +24,7 @@ class NBT { if(Main.oneNine) { Field f; try { - f = nmsEntity.getClass().getDeclaredField("bz"); + f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : "bz"); } catch (NoSuchFieldException e) { e.printStackTrace(); return 0; @@ -49,7 +49,7 @@ class NBT { if(Main.oneNine) { Field f; try { - f = nmsEntity.getClass().getDeclaredField("bz"); + f = nmsEntity.getClass().getDeclaredField(Main.oneNineFour ? "bA" : "bz"); } catch (NoSuchFieldException e) { e.printStackTrace(); return; diff --git a/src/config.yml b/src/config.yml index eae1c82..a846db7 100644 --- a/src/config.yml +++ b/src/config.yml @@ -4,7 +4,7 @@ # # Main Config # -# File generated by: v2.1.2 +# File generated by: v2.1.3 # (If this is not the version you are running, consider deleting this # config to allow it to be re-created. There may be new config options) # diff --git a/src/language.yml b/src/language.yml index 55cd48a..028a5ab 100644 --- a/src/language.yml +++ b/src/language.yml @@ -4,7 +4,7 @@ # # Language Config # -# File generated by: v2.1.2 +# File generated by: v2.1.3 # (If this is not the version you are running, consider deleting this # config to allow it to be re-created. There may be new config options) # diff --git a/src/plugin.yml b/src/plugin.yml index 99eb85f..f30919f 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ main: com.gmail.St3venAU.plugins.ArmorStandTools.Main name: ArmorStandTools -version: 2.1.2 +version: 2.1.3 author: St3venAU description: Armor stand manipulation tools softdepend: [WorldGuard, PlotSquared]