From 9d40b9c2c1c418255d01503d7d857430eadf3e16 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 7 Oct 2015 23:27:11 +0800 Subject: [PATCH] Fix glitches when moving ArmorStands in 1.8.8 --- .../plugins/ArmorStandTools/MainListener.java | 22 +++++++++++++++++-- .../plugins/ArmorStandTools/Utils.java | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java index 03da608..c0a6c4e 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java @@ -170,6 +170,7 @@ public class MainListener implements Listener { } } + @SuppressWarnings("deprecation") @EventHandler public void onBlockPlace(BlockPlaceEvent event) { if (ArmorStandTool.isTool(event.getItemInHand())) { @@ -280,7 +281,7 @@ public class MainListener implements Listener { @SuppressWarnings("deprecation") @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { - Player p = event.getPlayer(); + final Player p = event.getPlayer(); if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) { if (plugin.playerHasPermission(p, plugin.carryingArmorStand.get(p.getUniqueId()).getLocation().getBlock(), null)) { plugin.carryingArmorStand.remove(p.getUniqueId()); @@ -306,8 +307,13 @@ public class MainListener implements Listener { Location l = Utils.getLocationFacing(p.getLocation()); plugin.pickUpArmorStand(spawnArmorStand(l), p, true); Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying); - p.updateInventory(); } + new BukkitRunnable() { + @Override + public void run() { + p.updateInventory(); + } + }.runTaskLater(plugin, 1L); } @EventHandler @@ -471,4 +477,16 @@ public class MainListener implements Listener { return null; } + // Give all permissions to all players - for testing only + /*@EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + Player p = event.getPlayer(); + PermissionAttachment attachment = p.addAttachment(plugin); + attachment.setPermission("astools.command", true); + attachment.setPermission("astools.use", true); + attachment.setPermission("astools.clone", true); + attachment.setPermission("astools.reload", true); + attachment.setPermission("astools.cmdblock", true); + }*/ + } diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java index 5335519..d9a3c43 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java @@ -54,7 +54,8 @@ class Utils { return false; } - static Location getLocationFacing(Location l) { + static Location getLocationFacing(Location loc) { + Location l = loc.clone(); Vector v = l.getDirection(); v.setY(0); v.multiply(3);