From 9e6904b564b2eafc5d649b6bece609fd78c47de8 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Thu, 18 Apr 2013 11:09:31 +0200 Subject: [PATCH] Make use of ignoreCancelled = true --- .../listeners/FactionsEntityListener.java | 19 +++++-------------- .../listeners/FactionsPlayerListener.java | 19 +++++-------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index 431f7689..009538df 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -92,11 +92,9 @@ public class FactionsEntityListener implements Listener } } - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { - if (event.isCancelled()) return; - if (event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event; @@ -173,11 +171,9 @@ public class FactionsEntityListener implements Listener PotionEffectType.WITHER )); - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPotionSplashEvent(PotionSplashEvent event) { - if (event.isCancelled()) return; - // see if the potion has a harmful effect boolean badjuju = false; for (PotionEffect effect : event.getPotion().getEffects()) @@ -337,10 +333,9 @@ public class FactionsEntityListener implements Listener return true; } - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { - if (event.isCancelled()) return; if (event.getLocation() == null) return; PS ps = PS.valueOf(event.getLocation()); @@ -352,11 +347,9 @@ public class FactionsEntityListener implements Listener event.setCancelled(true); } - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityTarget(EntityTargetEvent event) { - if (event.isCancelled()) return; - // if there is a target Entity target = event.getTarget(); if (target == null) return; @@ -382,11 +375,9 @@ public class FactionsEntityListener implements Listener - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityChangeBlock(EntityChangeBlockEvent event) { - if (event.isCancelled()) return; - Entity entity = event.getEntity(); // for now, only interested in Enderman and Wither boss tomfoolery diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index c991d7ec..7d19c67c 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -129,10 +129,9 @@ public class FactionsPlayerListener implements Listener } } - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { - if (event.isCancelled()) return; // only need to check right-clicks and physical as of MC 1.4+; good performance boost if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) return; @@ -227,11 +226,9 @@ public class FactionsPlayerListener implements Listener // For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected), // but these separate bucket events below always fire without fail - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { - if (event.isCancelled()) return; - Block block = event.getBlockClicked(); Player player = event.getPlayer(); @@ -241,11 +238,9 @@ public class FactionsPlayerListener implements Listener return; } } - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerBucketFill(PlayerBucketFillEvent event) { - if (event.isCancelled()) return; - Block block = event.getBlockClicked(); Player player = event.getPlayer(); @@ -315,11 +310,9 @@ public class FactionsPlayerListener implements Listener return false; } - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerKick(PlayerKickEvent event) { - if (event.isCancelled()) return; - FPlayer badGuy = FPlayerColl.get().get(event.getPlayer()); if (badGuy == null) { @@ -342,11 +335,9 @@ public class FactionsPlayerListener implements Listener // VisualizeUtil // -------------------------------------------- // - @EventHandler(priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMoveClearVisualizations(PlayerMoveEvent event) { - if (event.isCancelled()) return; - Block blockFrom = event.getFrom().getBlock(); Block blockTo = event.getTo().getBlock(); if (blockFrom.equals(blockTo)) return;