From 1bb1dd8a89104d91701091cd6ddf07eeadc099c3 Mon Sep 17 00:00:00 2001 From: asofold <asofold@web.de> Date: Sun, 7 Oct 2012 00:17:49 +0200 Subject: [PATCH] Add permission for breaking fluids. --- plugin.yml | 5 +++++ .../nocheatplus/checks/blockbreak/BlockBreakListener.java | 7 +++++++ src/fr/neatmonster/nocheatplus/players/Permissions.java | 2 ++ 3 files changed, 14 insertions(+) diff --git a/plugin.yml b/plugin.yml index 16327524..daf2620e 100644 --- a/plugin.yml +++ b/plugin.yml @@ -72,6 +72,11 @@ permissions: nocheatplus.checks.blockbreak: description: Allow the player to bypass all BlockBreak checks. children: + nocheatplus.checks.blockbreak.break: + description: Allow the player to break special blocks. + children: + nocheatplus.checks.blockbreak.break.fluid: + description: Allow players to break fluids. nocheatplus.checks.blockbreak.direction: description: Allow the player to bypass to Direction check. nocheatplus.checks.blockbreak.fastbreak: diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java index 6470ae45..a1a79116 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java @@ -13,6 +13,8 @@ import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerInteractEvent; +import fr.neatmonster.nocheatplus.players.Permissions; +import fr.neatmonster.nocheatplus.utilities.BlockProperties; import fr.neatmonster.nocheatplus.utilities.TickTask; /* @@ -121,6 +123,11 @@ public class BlockBreakListener implements Listener { // Did the player look at the block at all? if (!cancelled && direction.isEnabled(player) && direction.check(player, block.getLocation(), data)) cancelled = true; + + // Destroying liquid blocks. + if (!cancelled && BlockProperties.isLiquid(block.getTypeId()) && !player.hasPermission(Permissions.BLOCKBREAK_BREAK_LIQUID)){ + cancelled = true; + } // At least one check failed and demanded to cancel the event. if (cancelled){ diff --git a/src/fr/neatmonster/nocheatplus/players/Permissions.java b/src/fr/neatmonster/nocheatplus/players/Permissions.java index 1430e1cf..49c32b8c 100644 --- a/src/fr/neatmonster/nocheatplus/players/Permissions.java +++ b/src/fr/neatmonster/nocheatplus/players/Permissions.java @@ -62,6 +62,8 @@ public class Permissions { * 888 88P' 888 "88 88" "88,e8' 888 8b 888 88P' 888 "YeeP" "88 888 888 8b */ private static final String BLOCKBREAK = CHECKS + ".blockbreak"; + public static final String BLOCKBREAK_BREAK = BLOCKBREAK + ".break"; + public static final String BLOCKBREAK_BREAK_LIQUID = BLOCKBREAK_BREAK + ".liquid"; public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction"; public static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + ".fastbreak"; public static final String BLOCKBREAK_FREQUENCY = BLOCKBREAK + ".frequency";