From 39fb4c4b91869302c82e15ae4fad0601430e5baa Mon Sep 17 00:00:00 2001 From: asofold Date: Sat, 8 Sep 2012 21:48:36 +0200 Subject: [PATCH] Make tolerance for step check configurable. Adds to ConfigFile. Use maximum for vDistanceAboveLimit. --- .../checks/moving/MovingConfig.java | 21 ++++++++----------- .../checks/moving/SurvivalFly.java | 4 ++-- .../nocheatplus/config/ConfPaths.java | 1 + .../nocheatplus/config/ConfigFile.java | 17 +++++++++++++++ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java index 40c2bd3d..e98da637 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java @@ -86,11 +86,11 @@ public class MovingConfig extends ACheckConfig { public final int survivalFlyWalkingSpeed; public final ActionList survivalFlyActions; - public final double noFallyOnGround; - public final double yOnGround; - - - + // Special tolerance values: + public final double noFallyOnGround; + public final double yOnGround; + public final double yStep; + /** * Instantiates a new moving configuration. @@ -125,15 +125,12 @@ public class MovingConfig extends ACheckConfig { survivalFlyWalkingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_WALKINGSPEED, 100); survivalFlyActions = data.getActionList(ConfPaths.MOVING_SURVIVALFLY_ACTIONS, Permissions.MOVING_SURVIVALFLY); - yOnGround = readyOnGround(data, ConfPaths.MOVING_YONGROUND, 0.001); - noFallyOnGround = readyOnGround(data, ConfPaths.MOVING_NOFALL_YONGROUND, 0.3); + yOnGround = data.getDouble(ConfPaths.MOVING_YONGROUND, 0.001, 2.0, 0.001); + noFallyOnGround = data.getDouble(ConfPaths.MOVING_NOFALL_YONGROUND, 0.001, 2.0, 0.3); + yStep = data.getDouble(ConfPaths.MOVING_SURVIVALFLY_YSTEP, 0.001, 0.49, 0.1); } - private final double readyOnGround(final ConfigFile data, final String path, final double preset){ - final double yOnGround = data.getDouble(path, preset); - if (yOnGround < 0 || yOnGround > 2.0) return 2.0; - else return yOnGround; - } + /* (non-Javadoc) * @see fr.neatmonster.nocheatplus.checks.ICheckConfig#isEnabled(fr.neatmonster.nocheatplus.checks.CheckType) diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index b1579090..016e067d 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -201,9 +201,9 @@ public class SurvivalFly extends Check { double vDistanceAboveLimit = to.getY() - data.setBack.getY() - vAllowedDistance; // Step can also be blocked. - if (from.isOnGround() && to.isOnGround() && Math.abs(to.getY() - from.getY() - 1D) <= 0.1 && vDistanceAboveLimit <= 0D + if (from.isOnGround() && to.isOnGround() && Math.abs(to.getY() - from.getY() - 1D) <= cc.yStep && vDistanceAboveLimit <= 0D && !player.hasPermission(Permissions.MOVING_SURVIVALFLY_STEP)) - vDistanceAboveLimit = 1D; + vDistanceAboveLimit = Math.max(vDistanceAboveLimit, Math.abs(to.getY() - from.getY())); if (from.isOnGround() || to.isOnGround()) data.jumpAmplifier = 0D; diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index 3b78f905..aeafd4ef 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -379,6 +379,7 @@ public abstract class ConfPaths { // Special (to be sorted in or factored out). public static final String MOVING_NOFALL_YONGROUND = MOVING_NOFALL + "yonground"; public static final String MOVING_YONGROUND = MOVING + "yonground"; + public static final String MOVING_SURVIVALFLY_YSTEP = MOVING_SURVIVALFLY + "ystep"; /* * dP"8 d8 ,e, diff --git a/src/fr/neatmonster/nocheatplus/config/ConfigFile.java b/src/fr/neatmonster/nocheatplus/config/ConfigFile.java index dfcfeec5..3d6a3dbb 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfigFile.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfigFile.java @@ -41,6 +41,23 @@ public class ConfigFile extends YamlConfiguration { final String value = this.getString(path); return factory.createActionList(value, permission); } + + /** + * Return double within given bounds, with preset. Mainly used for hidden settings. + * + * @param data + * @param path + * @param min + * @param max + * @param preset + * @return + */ + public double getDouble(final String path, final double min, final double max, final double preset){ + final double value = getDouble(path, preset); + if (value < min) return min; + else if (value > max) return max; + else return value; + } /** * Do this after reading new data.