Add speedingspeed and permission (speeding) to survivalfly.

This commit is contained in:
asofold 2012-09-03 09:25:43 +02:00
parent 7005b141cf
commit acabe72db1
3 changed files with 18 additions and 9 deletions

View File

@ -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;
@ -89,6 +90,7 @@ public class MovingConfig implements CheckConfig {
/**
* Instantiates a new moving configuration.
*
@ -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);

View File

@ -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)
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;
@ -199,10 +208,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;
data.survivalFlyJumpPhase++;

View File

@ -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";