From 384c3483ca65170932d3a120ee4cd7ecd43a3fb1 Mon Sep 17 00:00:00 2001 From: asofold Date: Fri, 3 May 2013 11:13:53 +0200 Subject: [PATCH] Add configuration for ender-pearl checks to the combined section. --- .../checks/blockinteract/BlockInteractListener.java | 6 +++++- .../checks/blockplace/BlockPlaceListener.java | 7 ++++++- .../nocheatplus/checks/combined/CombinedConfig.java | 9 ++++++++- .../nocheatplus/checks/moving/MovingListener.java | 3 ++- .../fr/neatmonster/nocheatplus/config/ConfPaths.java | 4 ++++ .../fr/neatmonster/nocheatplus/config/DefaultConfig.java | 3 +++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractListener.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractListener.java index d69aa381..4dac86b8 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractListener.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractListener.java @@ -14,6 +14,7 @@ import org.bukkit.inventory.ItemStack; import fr.neatmonster.nocheatplus.checks.CheckListener; import fr.neatmonster.nocheatplus.checks.CheckType; +import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig; import fr.neatmonster.nocheatplus.utilities.BlockProperties; /* @@ -90,7 +91,10 @@ public class BlockInteractListener extends CheckListener { final ItemStack stack = player.getItemInHand(); if (stack != null && stack.getTypeId() == Material.ENDER_PEARL.getId()){ if (!BlockProperties.isPassable(block.getTypeId())){ - event.setUseItemInHand(Result.DENY); + final CombinedConfig ccc = CombinedConfig.getConfig(player); + if (ccc.enderPearlCheck && ccc.enderPearlPreventClickBlock){ + event.setUseItemInHand(Result.DENY); + } } } break; diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceListener.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceListener.java index c73967e1..69fe5374 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceListener.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceListener.java @@ -21,6 +21,7 @@ import org.bukkit.inventory.ItemStack; import fr.neatmonster.nocheatplus.checks.CheckListener; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.combined.Combined; +import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig; import fr.neatmonster.nocheatplus.checks.combined.Improbable; import fr.neatmonster.nocheatplus.checks.moving.MovingConfig; import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; @@ -326,7 +327,11 @@ public class BlockPlaceListener extends CheckListener { // Ender pearl glitch (ab-) use. if (!cancel && type == EntityType.ENDER_PEARL){ - if (!BlockProperties.isPassable(entity.getLocation())){ + if (!CombinedConfig.getConfig(player).enderPearlCheck){ + // Do nothing ! + // TODO: Might have further flags? + } + else if (!BlockProperties.isPassable(entity.getLocation())){ // Launch into a block. // TODO: This might be a general check later. cancel = true; diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java index d40f5ca0..f8e14b54 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java @@ -34,7 +34,7 @@ public class CombinedConfig extends ACheckConfig { private static final Map worldsMap = new HashMap(); - protected static CombinedConfig getConfig(final Player player) { + public static CombinedConfig getConfig(final Player player) { final String worldName = player.getWorld().getName(); CombinedConfig cc = worldsMap.get(worldName); if (cc == null){ @@ -48,6 +48,10 @@ public class CombinedConfig extends ACheckConfig { // Bedleave check. public final boolean bedLeaveCheck; public final ActionList bedLeaveActions; + + // Ender pearl + public final boolean enderPearlCheck; + public final boolean enderPearlPreventClickBlock; // Improbable check /** Do mind that this flag is not used by all components. */ @@ -80,6 +84,9 @@ public class CombinedConfig extends ACheckConfig { bedLeaveCheck = config.getBoolean(ConfPaths.COMBINED_BEDLEAVE_CHECK); bedLeaveActions = config.getOptimizedActionList(ConfPaths.COMBINED_BEDLEAVE_ACTIONS, Permissions.COMBINED_BEDLEAVE); + enderPearlCheck = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_CHECK); + enderPearlPreventClickBlock = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK); + improbableCheck = config.getBoolean(ConfPaths.COMBINED_IMPROBABLE_CHECK); improbableLevel = (float) config.getDouble(ConfPaths.COMBINED_IMPROBABLE_LEVEL); improbableActions = config.getOptimizedActionList(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, Permissions.COMBINED_IMPROBABLE); diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index 0651c82e..5c455692 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -43,6 +43,7 @@ import fr.neatmonster.nocheatplus.checks.CheckListener; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.combined.BedLeave; import fr.neatmonster.nocheatplus.checks.combined.Combined; +import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig; import fr.neatmonster.nocheatplus.checks.combined.CombinedData; import fr.neatmonster.nocheatplus.command.INotifyReload; import fr.neatmonster.nocheatplus.components.IData; @@ -903,7 +904,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo } } else if (cause == TeleportCause.ENDER_PEARL){ - if (!BlockProperties.isPassable(to)){ // || !BlockProperties.isOnGroundOrResetCond(player, to, 1.0)){ + if (CombinedConfig.getConfig(player). enderPearlCheck && !BlockProperties.isPassable(to)){ // || !BlockProperties.isOnGroundOrResetCond(player, to, 1.0)){ // Not check on-ground: Check the second throw. cancel = true; } diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java index 5f421de7..a66814c9 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -338,6 +338,10 @@ public abstract class ConfPaths { public static final String COMBINED_BEDLEAVE_CHECK = COMBINED_BEDLEAVE + "active"; public static final String COMBINED_BEDLEAVE_ACTIONS = COMBINED_BEDLEAVE + "actions"; + private static final String COMBINED_ENDERPEARL = COMBINED + "enderpearl."; + public static final String COMBINED_ENDERPEARL_CHECK = COMBINED_ENDERPEARL + "active"; + public static final String COMBINED_ENDERPEARL_PREVENTCLICKBLOCK = COMBINED_ENDERPEARL + "preventclickblock"; + private static final String COMBINED_IMPROBABLE = COMBINED + "improbable."; public static final String COMBINED_IMPROBABLE_CHECK = COMBINED_IMPROBABLE + "active"; public static final String COMBINED_IMPROBABLE_LEVEL = COMBINED_IMPROBABLE + "level"; diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java index e5dc409f..72209615 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -266,6 +266,9 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.COMBINED_BEDLEAVE_CHECK, true); set(ConfPaths.COMBINED_BEDLEAVE_ACTIONS, "cancel log:bedleave:0:5:if cmd:kickbedleave"); + set(ConfPaths.COMBINED_ENDERPEARL_CHECK, true); + set(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK, true); + set(ConfPaths.COMBINED_IMPROBABLE_CHECK , true); set(ConfPaths.COMBINED_IMPROBABLE_LEVEL, 300); // set(ConfPaths.COMBINED_IMPROBABLE_FASTBREAK_CHECK, false);