diff options
author | md_5 <md_5@bigpond.com> | 2012-04-14 15:07:10 +1000 |
---|---|---|
committer | md_5 <md_5@bigpond.com> | 2012-04-14 15:07:10 +1000 |
commit | 2624c403baa6089f52257325e01d562c86fb34bc (patch) | |
tree | ca49420a3765e517e89cd17c7cb355d5c9c1ae13 | |
parent | 48b670d8c6a8ea93a3a4f56b666fa00c5dd3f583 (diff) | |
download | Essentials-2624c403baa6089f52257325e01d562c86fb34bc.tar Essentials-2624c403baa6089f52257325e01d562c86fb34bc.tar.gz Essentials-2624c403baa6089f52257325e01d562c86fb34bc.tar.lz Essentials-2624c403baa6089f52257325e01d562c86fb34bc.tar.xz Essentials-2624c403baa6089f52257325e01d562c86fb34bc.zip |
Change some ordering and clean pmd warnings
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 38243cf76..9a257bd68 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -31,13 +31,11 @@ import org.bukkit.inventory.ItemStack; public class EssentialsPlayerListener implements Listener { private static final Logger LOGGER = Logger.getLogger("Minecraft"); - private final transient Server server; private final transient IEssentials ess; public EssentialsPlayerListener(final IEssentials parent) { this.ess = parent; - this.server = parent.getServer(); } @EventHandler(priority = EventPriority.NORMAL) @@ -217,7 +215,7 @@ public class EssentialsPlayerListener implements Listener return; } - User user = ess.getUser(event.getPlayer()); + final User user = ess.getUser(event.getPlayer()); if (user.isNPC()) { user.setNPC(false); @@ -246,8 +244,8 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerTeleport(final PlayerTeleportEvent event) { - boolean backListener = ess.getSettings().registerBackInListener(); - boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability(); + final boolean backListener = ess.getSettings().registerBackInListener(); + final boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability(); if (backListener || teleportInvulnerability) { final User user = ess.getUser(event.getPlayer()); @@ -319,19 +317,16 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.MONITOR) public void onPlayerChangedWorld(final PlayerChangedWorldEvent event) { - final User user = ess.getUser(event.getPlayer()); + final User user = ess.getUser(event.getPlayer()); final String newWorld = event.getPlayer().getLocation().getWorld().getName(); user.setDisplayNick(); updateCompass(user); - if (ess.getSettings().getNoGodWorlds().contains(newWorld)) + if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw()) { - if (user.isGodModeEnabledRaw()) - { - user.sendMessage(_("noGodWorldWarning")); - } + user.sendMessage(_("noGodWorldWarning")); } - - if(!event.getPlayer().getWorld().getName().equals(newWorld)) + + if (!event.getPlayer().getWorld().getName().equals(newWorld)) { user.sendMessage(_("currentWorld", newWorld)); } @@ -343,11 +338,7 @@ public class EssentialsPlayerListener implements Listener switch (event.getAction()) { case RIGHT_CLICK_BLOCK: - if (event.isCancelled()) - { - return; - } - if (event.getClickedBlock().getTypeId() == Material.BED_BLOCK.getId() && ess.getSettings().getUpdateBedAtDaytime()) + if (!event.isCancelled() && event.getClickedBlock().getTypeId() == Material.BED_BLOCK.getId() && ess.getSettings().getUpdateBedAtDaytime()) { event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation()); } @@ -408,14 +399,12 @@ public class EssentialsPlayerListener implements Listener @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerPickupItem(final PlayerPickupItemEvent event) { - if (!ess.getSettings().getDisableItemPickupWhileAfk()) + if (ess.getSettings().getDisableItemPickupWhileAfk()) { - return; - } - final User user = ess.getUser(event.getPlayer()); - if (user.isAfk()) - { - event.setCancelled(true); + if (ess.getUser(event.getPlayer()).isAfk()) + { + event.setCancelled(true); + } } } |