Make tolerance for step check configurable. Adds to ConfigFile. Use

maximum for vDistanceAboveLimit.
This commit is contained in:
asofold 2012-09-08 21:48:36 +02:00
parent 1b9b83efc8
commit 39fb4c4b91
4 changed files with 29 additions and 14 deletions

View File

@ -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)

View File

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

View File

@ -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,

View File

@ -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.