From f04be42eb2d8680ffb8af8cb804be4f7b9de0ffb Mon Sep 17 00:00:00 2001 From: Evenprime Date: Sun, 6 Nov 2011 11:27:06 +0100 Subject: [PATCH] Removed "onliquid" check --- plugin.yml | 2 - .../checks/blockplace/BlockPlaceCheck.java | 7 --- .../checks/blockplace/OnLiquidCheck.java | 57 ------------------- .../bukkit/nocheat/config/Permissions.java | 1 - .../nocheat/config/cache/CCBlockPlace.java | 5 -- .../events/BlockPlaceEventManager.java | 2 - 6 files changed, 74 deletions(-) delete mode 100644 src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/OnLiquidCheck.java diff --git a/plugin.yml b/plugin.yml index defd504d..150c2c2f 100644 --- a/plugin.yml +++ b/plugin.yml @@ -60,8 +60,6 @@ permissions: children: nocheat.checks.blockplace.reach: description: Allow a player to place blocks at maximum range (about 6-7 blocks) - nocheat.checks.blockplace.onliquid: - description: Allow a player to place non-liquid blocks on liquids nocheat.checks.blockplace.direction: description: Allow a player to place blocks outside their line of view nocheat.checks.chat: diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/BlockPlaceCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/BlockPlaceCheck.java index 72982f99..120f031b 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/BlockPlaceCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/BlockPlaceCheck.java @@ -14,7 +14,6 @@ import cc.co.evenprime.bukkit.nocheat.data.BaseData; public class BlockPlaceCheck { private final ReachCheck reachCheck; - private final OnLiquidCheck onLiquidCheck; private final DirectionCheck directionCheck; private final NoCheat plugin; @@ -23,7 +22,6 @@ public class BlockPlaceCheck { this.plugin = plugin; reachCheck = new ReachCheck(plugin); - onLiquidCheck = new OnLiquidCheck(plugin); directionCheck = new DirectionCheck(plugin); } @@ -32,7 +30,6 @@ public class BlockPlaceCheck { boolean cancel = false; // Which checks are going to be executed? - final boolean onliquid = cc.blockplace.onliquidCheck && !player.hasPermission(Permissions.BLOCKPLACE_ONLIQUID); final boolean reach = cc.blockplace.reachCheck && !player.hasPermission(Permissions.BLOCKPLACE_REACH); final boolean direction = cc.blockplace.directionCheck && !player.hasPermission(Permissions.BLOCKPLACE_DIRECTION); @@ -50,10 +47,6 @@ public class BlockPlaceCheck { if(!cancel && reach) { cancel = reachCheck.check(player, data, cc); } - - if(!cancel && onliquid) { - cancel = onLiquidCheck.check(player, data, cc); - } } return cancel; diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/OnLiquidCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/OnLiquidCheck.java deleted file mode 100644 index 6a17f828..00000000 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/OnLiquidCheck.java +++ /dev/null @@ -1,57 +0,0 @@ -package cc.co.evenprime.bukkit.nocheat.checks.blockplace; - -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import cc.co.evenprime.bukkit.nocheat.NoCheat; -import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache; -import cc.co.evenprime.bukkit.nocheat.data.BaseData; -import cc.co.evenprime.bukkit.nocheat.data.BlockPlaceData; -import cc.co.evenprime.bukkit.nocheat.data.LogData; -import cc.co.evenprime.bukkit.nocheat.data.SimpleLocation; - -/** - * - */ -public class OnLiquidCheck { - - private final NoCheat plugin; - - public OnLiquidCheck(NoCheat plugin) { - this.plugin = plugin; - } - - public boolean check(final Player player, final BaseData data, final ConfigurationCache cc) { - - boolean cancel = false; - - final BlockPlaceData blockplace = data.blockplace; - final SimpleLocation blockplaced = blockplace.blockPlaced; - final LogData log = data.log; - - if(isSolid(blockplace.placedType.getId())) { - // all ok - } else if(nextToSolid(player.getWorld(), blockplaced.x, blockplaced.y, blockplaced.z)) { - // all ok - } else { - blockplace.onliquidViolationLevel += 1; - log.check = "blockplace.onliquid"; - - cancel = plugin.execute(player, cc.blockplace.onliquidActions, (int) blockplace.onliquidViolationLevel, blockplace.history, cc); - } - - blockplace.onliquidViolationLevel *= 0.95D; // Reduce level over - // time - - return cancel; - } - - private static final boolean nextToSolid(final World world, final int x, final int y, final int z) { - return isSolid(world.getBlockTypeIdAt(x, y - 1, z)) || isSolid(world.getBlockTypeIdAt(x - 1, y, z)) || isSolid(world.getBlockTypeIdAt(x + 1, y, z)) || isSolid(world.getBlockTypeIdAt(x, y, z + 1)) || isSolid(world.getBlockTypeIdAt(x, y, z - 1)) || isSolid(world.getBlockTypeIdAt(x, y + 1, z)); - } - - private static final boolean isSolid(int id) { - return !((id == Material.AIR.getId()) || (id == Material.WATER.getId()) || (id == Material.STATIONARY_WATER.getId()) || (id == Material.LAVA.getId()) || (id == Material.STATIONARY_LAVA.getId())); - } -} diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/Permissions.java b/src/cc/co/evenprime/bukkit/nocheat/config/Permissions.java index 6d4478e8..7cc08804 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/Permissions.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/Permissions.java @@ -24,7 +24,6 @@ public class Permissions { public static final String BLOCKBREAK_NOSWING = BLOCKBREAK + ".noswing"; public final static String BLOCKPLACE = CHECKS + ".blockplace"; - public final static String BLOCKPLACE_ONLIQUID = BLOCKPLACE + ".onliquid"; public final static String BLOCKPLACE_REACH = BLOCKPLACE + ".reach"; public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction"; diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCBlockPlace.java b/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCBlockPlace.java index 250be542..b0a93a8c 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCBlockPlace.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCBlockPlace.java @@ -9,8 +9,6 @@ import cc.co.evenprime.bukkit.nocheat.config.util.ActionList; public class CCBlockPlace { public final boolean check; - public final boolean onliquidCheck; - public final ActionList onliquidActions; public final boolean reachCheck; public final double reachDistance; @@ -25,9 +23,6 @@ public class CCBlockPlace { check = data.getBoolean(Configuration.BLOCKPLACE_CHECK); - onliquidCheck = data.getBoolean(Configuration.BLOCKPLACE_ONLIQUID_CHECK); - onliquidActions = data.getActionList(Configuration.BLOCKPLACE_ONLIQUID_ACTIONS); - reachCheck = data.getBoolean(Configuration.BLOCKPLACE_REACH_CHECK); reachDistance = data.getInteger(Configuration.BLOCKPLACE_REACH_LIMIT); reachActions = data.getActionList(Configuration.BLOCKPLACE_REACH_ACTIONS); diff --git a/src/cc/co/evenprime/bukkit/nocheat/events/BlockPlaceEventManager.java b/src/cc/co/evenprime/bukkit/nocheat/events/BlockPlaceEventManager.java index b60e35dc..f1c35254 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/events/BlockPlaceEventManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/events/BlockPlaceEventManager.java @@ -95,8 +95,6 @@ public class BlockPlaceEventManager extends BlockListener implements EventManage public List getActiveChecks(ConfigurationCache cc) { LinkedList s = new LinkedList(); - if(cc.blockplace.check && cc.blockplace.onliquidCheck) - s.add("blockplace.onliquid"); if(cc.blockplace.check && cc.blockplace.reachCheck) s.add("blockplace.reach");