diff options
author | md_5 <md_5@bigpond.com> | 2012-03-17 17:02:19 +1100 |
---|---|---|
committer | md_5 <md_5@bigpond.com> | 2012-03-17 17:02:19 +1100 |
commit | 00756132236c63420eaa9303a338bf81171139f7 (patch) | |
tree | 795b26c9493bc6c6f4b29d780351b098d7836818 /EssentialsAntiCheat/src/com/earth2me | |
parent | 60ae0559bc332ebb974c2314205de201e539ca20 (diff) | |
download | Essentials-00756132236c63420eaa9303a338bf81171139f7.tar Essentials-00756132236c63420eaa9303a338bf81171139f7.tar.gz Essentials-00756132236c63420eaa9303a338bf81171139f7.tar.lz Essentials-00756132236c63420eaa9303a338bf81171139f7.tar.xz Essentials-00756132236c63420eaa9303a338bf81171139f7.zip |
[EAC] small cleanup regarding events
Diffstat (limited to 'EssentialsAntiCheat/src/com/earth2me')
4 files changed, 27 insertions, 64 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockbreak/BlockBreakCheckListener.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockbreak/BlockBreakCheckListener.java index 2e56adb68..f59ed481c 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockbreak/BlockBreakCheckListener.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockbreak/BlockBreakCheckListener.java @@ -1,5 +1,10 @@ package com.earth2me.essentials.anticheat.checks.blockbreak; +import com.earth2me.essentials.anticheat.EventManager; +import com.earth2me.essentials.anticheat.NoCheat; +import com.earth2me.essentials.anticheat.NoCheatPlayer; +import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; +import com.earth2me.essentials.anticheat.config.Permissions; import java.util.LinkedList; import java.util.List; import org.bukkit.event.EventHandler; @@ -9,11 +14,6 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerInteractEvent; -import com.earth2me.essentials.anticheat.EventManager; -import com.earth2me.essentials.anticheat.NoCheat; -import com.earth2me.essentials.anticheat.NoCheatPlayer; -import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; -import com.earth2me.essentials.anticheat.config.Permissions; /** @@ -42,15 +42,9 @@ public class BlockBreakCheckListener implements Listener, EventManager * * @param event The blockbreak event */ - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void blockBreak(final BlockBreakEvent event) { - - if (event.isCancelled()) - { - return; - } - boolean cancelled = false; final NoCheatPlayer player = plugin.getPlayer(event.getPlayer()); @@ -105,15 +99,9 @@ public class BlockBreakCheckListener implements Listener, EventManager * * @param event The BlockDamage event */ - @EventHandler(priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void blockHit(final BlockDamageEvent event) { - - if (event.isCancelled()) - { - return; - } - NoCheatPlayer player = plugin.getPlayer(event.getPlayer()); BlockBreakData data = BlockBreakCheck.getData(player); diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java index 253982bd1..6896e36c9 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java @@ -1,16 +1,16 @@ package com.earth2me.essentials.anticheat.checks.blockplace; +import com.earth2me.essentials.anticheat.EventManager; +import com.earth2me.essentials.anticheat.NoCheat; +import com.earth2me.essentials.anticheat.NoCheatPlayer; +import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; +import com.earth2me.essentials.anticheat.config.Permissions; import java.util.LinkedList; import java.util.List; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; -import com.earth2me.essentials.anticheat.EventManager; -import com.earth2me.essentials.anticheat.NoCheat; -import com.earth2me.essentials.anticheat.NoCheatPlayer; -import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; -import com.earth2me.essentials.anticheat.config.Permissions; /** @@ -37,11 +37,10 @@ public class BlockPlaceCheckListener implements Listener, EventManager * * @param event the BlockPlace event */ - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) protected void handleBlockPlaceEvent(BlockPlaceEvent event) { - - if (event.isCancelled() || event.getBlock() == null || event.getBlockAgainst() == null) + if (event.getBlock() == null || event.getBlockAgainst() == null) { return; } diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/fight/FightCheckListener.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/fight/FightCheckListener.java index fc1ea160c..05a9b1701 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/fight/FightCheckListener.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/fight/FightCheckListener.java @@ -1,5 +1,10 @@ package com.earth2me.essentials.anticheat.checks.fight; +import com.earth2me.essentials.anticheat.EventManager; +import com.earth2me.essentials.anticheat.NoCheat; +import com.earth2me.essentials.anticheat.NoCheatPlayer; +import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; +import java.util.AbstractList; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -17,10 +22,6 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.player.PlayerAnimationEvent; -import com.earth2me.essentials.anticheat.EventManager; -import com.earth2me.essentials.anticheat.NoCheat; -import com.earth2me.essentials.anticheat.NoCheatPlayer; -import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; /** @@ -29,16 +30,13 @@ import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; */ public class FightCheckListener implements Listener, EventManager { - private final List<FightCheck> checks; + private final List<FightCheck> checks = new ArrayList<FightCheck>(); private final GodmodeCheck godmodeCheck; private final InstanthealCheck instanthealCheck; private final NoCheat plugin; public FightCheckListener(NoCheat plugin) { - - this.checks = new ArrayList<FightCheck>(4); - // Keep these in a list, because they can be executed in a bundle this.checks.add(new SpeedCheck(plugin)); this.checks.add(new NoswingCheck(plugin)); @@ -87,15 +85,9 @@ public class FightCheckListener implements Listener, EventManager * * @param event The EntityDamage Event */ - @EventHandler(priority = EventPriority.LOW) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void entityDamageForGodmodeCheck(final EntityDamageEvent event) { - - if (event.isCancelled()) - { - return; - } - // Filter unwanted events right here final Entity entity = event.getEntity(); if (!(entity instanceof Player) || entity.isDead()) @@ -130,11 +122,11 @@ public class FightCheckListener implements Listener, EventManager * * @param event The EntityRegainHealth Event */ - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void satiatedRegen(final EntityRegainHealthEvent event) { - if (!(event.getEntity() instanceof Player) || event.isCancelled() || event.getRegainReason() != RegainReason.SATIATED) + if (!(event.getEntity() instanceof Player) || event.getRegainReason() != RegainReason.SATIATED) { return; } @@ -223,8 +215,6 @@ public class FightCheckListener implements Listener, EventManager // Skip the next damage event, because it is with high probability // something from the Heroes plugin data.skipNext = true; - - return; } /** diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/moving/MovingCheckListener.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/moving/MovingCheckListener.java index 3b35e0c33..31ef7c84e 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/moving/MovingCheckListener.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/moving/MovingCheckListener.java @@ -48,16 +48,9 @@ public class MovingCheckListener implements Listener, EventManager * * @param event The BlockPlaceEvent */ - @EventHandler(priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void blockPlace(final BlockPlaceEvent event) { - - // Block wasn't placed, so we don't care - if (event.isCancelled()) - { - return; - } - final NoCheatPlayer player = plugin.getPlayer(event.getPlayer()); final MovingConfig config = MovingCheck.getConfig(player); @@ -136,8 +129,6 @@ public class MovingCheckListener implements Listener, EventManager // after teleports. Always! data.teleportTo.reset(); data.clearRunFlyData(); - - return; } /** @@ -187,12 +178,12 @@ public class MovingCheckListener implements Listener, EventManager * * @param event The PlayerMoveEvent */ - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void move(final PlayerMoveEvent event) { // Don't care for vehicles - if (event.isCancelled() || event.getPlayer().isInsideVehicle()) + if (event.getPlayer().isInsideVehicle()) { return; } @@ -310,14 +301,9 @@ public class MovingCheckListener implements Listener, EventManager * * @param event The PlayerVelocityEvent */ - @EventHandler(priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void velocity(final PlayerVelocityEvent event) { - if (event.isCancelled()) - { - return; - } - final MovingData data = MovingCheck.getData(plugin.getPlayer(event.getPlayer())); final Vector v = event.getVelocity(); |