diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-03-29 03:06:52 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-03-29 03:06:52 +0100 |
commit | c09ada201c7652d2881f23e523f21fe9372ceb7c (patch) | |
tree | fa4fcd17318b4425594871a35f4153441545c2bb | |
parent | d7139cb16cc4d3a85ee9290bb6c8e328edeebcb3 (diff) | |
download | Essentials-c09ada201c7652d2881f23e523f21fe9372ceb7c.tar Essentials-c09ada201c7652d2881f23e523f21fe9372ceb7c.tar.gz Essentials-c09ada201c7652d2881f23e523f21fe9372ceb7c.tar.lz Essentials-c09ada201c7652d2881f23e523f21fe9372ceb7c.tar.xz Essentials-c09ada201c7652d2881f23e523f21fe9372ceb7c.zip |
Interact event cleanup
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index eb21aea39..36adf37e2 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -19,7 +19,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryType; @@ -228,6 +227,7 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerTeleport(final PlayerTeleportEvent event) { + //TODO: Don't fetch user unless one of these features are enabled. final User user = ess.getUser(event.getPlayer()); //There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports. if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener()) @@ -318,19 +318,16 @@ public class EssentialsPlayerListener implements Listener { return; } - if (ess.getSettings().getUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK) + if (event.getClickedBlock().getType() == Material.BED_BLOCK && ess.getSettings().getUpdateBedAtDaytime()) { event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation()); } break; - case LEFT_CLICK_AIR: case LEFT_CLICK_BLOCK: - if (user.hasPowerTools() && user.arePowerToolsEnabled()) + case LEFT_CLICK_AIR: + if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem())) { - if (usePowertools(user)) - { - event.setCancelled(true); - } + event.setCancelled(true); } break; default: @@ -338,9 +335,8 @@ public class EssentialsPlayerListener implements Listener } } - private boolean usePowertools(final User user) + private boolean usePowertools(final User user, final ItemStack is) { - final ItemStack is = user.getItemInHand(); int id; if (is == null || (id = is.getTypeId()) == 0) { |