From acabe72db13fe77284b3c8e115c5e0f396175273 Mon Sep 17 00:00:00 2001 From: asofold Date: Mon, 3 Sep 2012 09:25:43 +0200 Subject: [PATCH] Add speedingspeed and permission (speeding) to survivalfly. --- .../checks/moving/MovingConfig.java | 3 +++ .../checks/moving/SurvivalFly.java | 23 +++++++++++-------- .../nocheatplus/config/ConfPaths.java | 1 + 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java index 662d5f73..cf9ee388 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java @@ -79,6 +79,7 @@ public class MovingConfig implements CheckConfig { public final boolean survivalFlyCheck; public final int survivalFlyBlockingSpeed; public final int survivalFlySneakingSpeed; + public final int survivalFlySpeedingSpeed; public final int survivalFlySprintingSpeed; public final int survivalFlySwimmingSpeed; public final int survivalFlyWalkingSpeed; @@ -87,6 +88,7 @@ public class MovingConfig implements CheckConfig { public final double noFallyOnGround; public final double yOnGround; + /** @@ -116,6 +118,7 @@ public class MovingConfig implements CheckConfig { // Default values are specified here because this settings aren't showed by default into the configuration file. survivalFlyBlockingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_BLOCKINGSPEED, 100); survivalFlySneakingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_SNEAKINGSPEED, 100); + survivalFlySpeedingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_SPEEDINGSPEED, 100); survivalFlySprintingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_SPRINTINGSPEED, 100); survivalFlySwimmingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_SWIMMINGSPEED, 100); survivalFlyWalkingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_WALKINGSPEED, 100); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index f7018670..b1579090 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -100,11 +100,20 @@ public class SurvivalFly extends Check { hAllowedDistance = 0.13D * cc.survivalFlySneakingSpeed / 100D; else if (player.isBlocking() && !player.hasPermission(Permissions.MOVING_SURVIVALFLY_BLOCKING)) hAllowedDistance = 0.16D * cc.survivalFlyBlockingSpeed / 100D; - else if (!sprinting) - hAllowedDistance = 0.22D * cc.survivalFlyWalkingSpeed / 100D; - else - hAllowedDistance = 0.35D * cc.survivalFlySprintingSpeed / 100D; - + else{ + if (!sprinting) + hAllowedDistance = 0.22D * cc.survivalFlyWalkingSpeed / 100D; + else + hAllowedDistance = 0.35D * cc.survivalFlySprintingSpeed / 100D; + + // Speeding bypass permission (can be combined with other bypasses). + // TODO: How exactly to bring it on finally. + if (player.hasPermission(Permissions.MOVING_SURVIVALFLY_SPEEDING)) + hAllowedDistance = hAllowedDistance * cc.survivalFlySpeedingSpeed/ 100D; + } + + // TODO: Optimize: maybe only do the permission checks and modifiers if the distance is too big. + // If the player is on ice, give him an higher maximum speed. if (data.survivalFlyOnIce > 0) hAllowedDistance *= 2.5D; @@ -198,10 +207,6 @@ public class SurvivalFly extends Check { if (from.isOnGround() || to.isOnGround()) data.jumpAmplifier = 0D; - - // Speeding bypass permission: - if (hDistanceAboveLimit > 0 && player.hasPermission(Permissions.MOVING_SURVIVALFLY_SPEEDING)) - hDistanceAboveLimit = 0D; final double result = (Math.max(hDistanceAboveLimit, 0D) + Math.max(vDistanceAboveLimit, 0D)) * 100D; diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index af856e15..52f3117a 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -338,6 +338,7 @@ public abstract class ConfPaths { public static final String MOVING_SURVIVALFLY_CHECK = MOVING_SURVIVALFLY + "active"; public static final String MOVING_SURVIVALFLY_BLOCKINGSPEED = MOVING_SURVIVALFLY + "blockingspeed"; public static final String MOVING_SURVIVALFLY_SNEAKINGSPEED = MOVING_SURVIVALFLY + "sneakingspeed"; + public static final String MOVING_SURVIVALFLY_SPEEDINGSPEED = MOVING_SURVIVALFLY + "speedingspeed"; public static final String MOVING_SURVIVALFLY_SPRINTINGSPEED = MOVING_SURVIVALFLY + "sprintingspeed"; public static final String MOVING_SURVIVALFLY_SWIMMINGSPEED = MOVING_SURVIVALFLY + "swimmingspeed"; public static final String MOVING_SURVIVALFLY_WALKINGSPEED = MOVING_SURVIVALFLY + "walkingspeed";