diff options
author | ementalo <ementalodev@gmx.co.uk> | 2012-07-17 12:26:55 +0100 |
---|---|---|
committer | ementalo <ementalodev@gmx.co.uk> | 2012-07-17 14:21:03 +0100 |
commit | a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3 (patch) | |
tree | 2aa10b6300f6c8d3cb2b298c124180fade74857a /EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java | |
parent | 3c385e69271dfe8530fadc3f67e13ee495e4b0e1 (diff) | |
parent | 9f05e43ecf8e6e1a8fcaef757678e762f0d82573 (diff) | |
download | Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.gz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.lz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.xz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.zip |
Merge of server-layer branch
Diffstat (limited to 'EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java')
-rw-r--r-- | EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java deleted file mode 100644 index 6896e36c9..000000000 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceCheckListener.java +++ /dev/null @@ -1,96 +0,0 @@ -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; - - -/** - * Central location to listen to Block-related events and dispatching them to checks - * - */ -public class BlockPlaceCheckListener implements Listener, EventManager -{ - private final ReachCheck reachCheck; - private final DirectionCheck directionCheck; - private final NoCheat plugin; - - public BlockPlaceCheckListener(NoCheat plugin) - { - - this.plugin = plugin; - - reachCheck = new ReachCheck(plugin); - directionCheck = new DirectionCheck(plugin); - } - - /** - * We listen to BlockPlace events for obvious reasons - * - * @param event the BlockPlace event - */ - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - protected void handleBlockPlaceEvent(BlockPlaceEvent event) - { - if (event.getBlock() == null || event.getBlockAgainst() == null) - { - return; - } - - boolean cancelled = false; - - final NoCheatPlayer player = plugin.getPlayer(event.getPlayer()); - final BlockPlaceConfig cc = BlockPlaceCheck.getConfig(player); - final BlockPlaceData data = BlockPlaceCheck.getData(player); - - // Remember these locations and put them in a simpler "format" - data.blockPlaced.set(event.getBlock()); - data.blockPlacedAgainst.set(event.getBlockAgainst()); - - // Now do the actual checks - - // First the reach check - if (cc.reachCheck && !player.hasPermission(Permissions.BLOCKPLACE_REACH)) - { - cancelled = reachCheck.check(player, data, cc); - } - - // Second the direction check - if (!cancelled && cc.directionCheck && !player.hasPermission(Permissions.BLOCKPLACE_DIRECTION)) - { - cancelled = directionCheck.check(player, data, cc); - } - - // If one of the checks requested to cancel the event, do so - if (cancelled) - { - event.setCancelled(cancelled); - } - } - - public List<String> getActiveChecks(ConfigurationCacheStore cc) - { - LinkedList<String> s = new LinkedList<String>(); - - BlockPlaceConfig bp = BlockPlaceCheck.getConfig(cc); - - if (bp.reachCheck) - { - s.add("blockplace.reach"); - } - if (bp.directionCheck) - { - s.add("blockplace.direction"); - } - - return s; - } -} |