From 34a70251aa033daa4b9dd677fbce677fd443bad5 Mon Sep 17 00:00:00 2001 From: asofold Date: Mon, 24 Sep 2012 12:55:07 +0200 Subject: [PATCH] Ensure improbable check is bound to other checks being enabled for the player. --- .../checks/blockbreak/BlockBreakConfig.java | 2 -- .../checks/blockbreak/FastBreak.java | 5 --- .../nocheatplus/checks/blockbreak/Reach.java | 6 ---- .../checks/fight/FightListener.java | 6 ---- .../checks/inventory/InventoryListener.java | 33 +++++++++++-------- .../nocheatplus/config/ConfPaths.java | 4 +-- .../nocheatplus/config/DefaultConfig.java | 2 +- 7 files changed, 23 insertions(+), 35 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java index 10bdd586..5a9731a4 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java @@ -143,8 +143,6 @@ public class BlockBreakConfig extends ACheckConfig { frequencyShortTermTicks = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_SHORTTERM_TICKS); frequencyActions = data.getActionList(ConfPaths.BLOCKBREAK_FREQUENCY_ACTIONS, Permissions.BLOCKBREAK_FREQUENCY); - improbableFastBreakCheck = data.getBoolean(ConfPaths.COMBINED_IMPROBABLE_FASTBREAK_CHECK); - noSwingCheck = data.getBoolean(ConfPaths.BLOCKBREAK_NOSWING_CHECK); noSwingActions = data.getActionList(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, Permissions.BLOCKBREAK_NOSWING); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java index b938779d..1c1aac98 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java @@ -97,11 +97,6 @@ public class FastBreak extends Check { } // (The break time is set in the listener). - -// // Combined speed: -// // TODO: use some value corresponding to allowed block breaking speed ! -// if (cc.improbableFastBreakCheck && Improbable.check(player, 1f, now)) // <- the weight should reflect needed duration -// cancel = true; return cancel; } diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/Reach.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/Reach.java index 79e70afa..de906edf 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/Reach.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/Reach.java @@ -72,12 +72,6 @@ public class Reach extends Check { } else{ // Player passed the check, reward him. data.reachVL *= 0.9D; - -// // Check if improbable -// if (distance > -0.1){ -// if (Improbable.check(player, 1.0f, System.currentTimeMillis())) -// cancel = true; -// } } return cancel; diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/FightListener.java b/src/fr/neatmonster/nocheatplus/checks/fight/FightListener.java index f9bd3750..c72a8aad 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/FightListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/FightListener.java @@ -108,12 +108,6 @@ public class FightListener implements Listener { final Player damagedPlayer = (Player) cbEntity; if (selfHit.isEnabled(player) && selfHit.check(player, damagedPlayer, data, cc)) cancelled = true; - else{ -// // Check if improbable -// if (Improbable.check(player, 2.0f, System.currentTimeMillis())) -// cancelled = true; -// CombinedData.getData((Player) cbEntity).improbableCount.add(System.currentTimeMillis(), -2.0f); - } } if (cc.cancelDead){ diff --git a/src/fr/neatmonster/nocheatplus/checks/inventory/InventoryListener.java b/src/fr/neatmonster/nocheatplus/checks/inventory/InventoryListener.java index 77ce09ef..6acb6568 100644 --- a/src/fr/neatmonster/nocheatplus/checks/inventory/InventoryListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/inventory/InventoryListener.java @@ -72,13 +72,14 @@ public class InventoryListener implements Listener { // Only if a player shot the arrow. if (event.getEntity() instanceof Player) { final Player player = (Player) event.getEntity(); - if (instantBow.isEnabled(player) && instantBow.check(player, event.getForce())) - // The check requested the event to be cancelled. - event.setCancelled(true); - else - // Combined speed: - if (Improbable.check(player, 1f, System.currentTimeMillis())) + if (instantBow.isEnabled(player)){ + if (instantBow.check(player, event.getForce())) + // The check requested the event to be cancelled. + event.setCancelled(true); + if (Improbable.check(player, 1f, System.currentTimeMillis())) + // COmbined fighting speed. event.setCancelled(true); + } } } @@ -161,14 +162,20 @@ public class InventoryListener implements Listener { if (event.getPlayer().isDead()) return; - if (drop.isEnabled(event.getPlayer()) && drop.check(event.getPlayer())) - // Cancelling drop events is not save (in certain circumstances items will disappear completely). So don't - // do it and kick players instead by default. - event.setCancelled(true); - else - // Combined speed: - if (Improbable.check(event.getPlayer(), 1f, System.currentTimeMillis())) + if (drop.isEnabled(event.getPlayer())){ + if (drop.check(event.getPlayer())){ + // TODO: Is the following command still correct? If so, adapt actions. + // Cancelling drop events is not save (in certain circumstances items will disappear completely). So don't + // do it and kick players instead by default. + event.setCancelled(true); + } + else if (Improbable.check(event.getPlayer(), 1f, System.currentTimeMillis())){ + // Combined speed event.setCancelled(true); + } + } + + } /** diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index a405b663..7c7b65e4 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -306,8 +306,8 @@ public abstract class ConfPaths { public static final String COMBINED_IMPROBABLE_CHECK = COMBINED_IMPROBABLE + "active"; public static final String COMBINED_IMPROBABLE_LEVEL = COMBINED_IMPROBABLE + "level"; - private static final String COMBINED_IMPROBABLE_CHECKS = COMBINED_IMPROBABLE + "options."; - public static final String COMBINED_IMPROBABLE_FASTBREAK_CHECK = COMBINED_IMPROBABLE_CHECKS + "fastbreak"; +// private static final String COMBINED_IMPROBABLE_CHECKS = COMBINED_IMPROBABLE + "options."; +// public static final String COMBINED_IMPROBABLE_FASTBREAK_CHECK = COMBINED_IMPROBABLE_CHECKS + "fastbreak"; public static final String COMBINED_IMPROBABLE_ACTIONS = COMBINED_IMPROBABLE + "actions"; diff --git a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java index 129ee464..f4cb00c3 100644 --- a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -233,7 +233,7 @@ public class DefaultConfig extends ConfigFile { */ set(ConfPaths.COMBINED_IMPROBABLE_CHECK , true); set(ConfPaths.COMBINED_IMPROBABLE_LEVEL, 300); - set(ConfPaths.COMBINED_IMPROBABLE_FASTBREAK_CHECK, false); +// set(ConfPaths.COMBINED_IMPROBABLE_FASTBREAK_CHECK, false); set(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, "cancel log:improbable:2:8:if"); set(ConfPaths.COMBINED_YAWRATE_RATE , 380);