Make the new "aggressive mode" nofall check respect configuration

settings.
This commit is contained in:
Evenprime 2012-02-05 21:39:02 +01:00
parent c4861eeed9
commit adf3a4c9a3
6 changed files with 20 additions and 5 deletions

View File

@ -147,6 +147,9 @@ checks:
checknofall:
Should players be checked for a common type of "nofall" hack, that allows them to
avoid taking damage when falling.
nofallaggressivemode:
Enable improved version of nofall check, that will catch additional types of
"nofall" hacks and deal damage to players directly (experimental).
nofallactions:
What should happen if a player is considered to be using a "nofall" hack. Default
is to log a message and encourage Bukkit to deal fall damage anyway ("cancel" the

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cc.co.evenprime.bukkit</groupId>
<artifactId>NoCheat</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<packaging>jar</packaging>
<name>NoCheat</name>
<properties>

View File

@ -29,6 +29,7 @@ public class MovingConfig implements ConfigItem {
public final ActionList flyingActions;
public final boolean nofallCheck;
public final boolean nofallaggressive;
public final float nofallMultiplier;
public final ActionList nofallActions;
@ -59,6 +60,7 @@ public class MovingConfig implements ConfigItem {
nofallCheck = data.getBoolean(ConfPaths.MOVING_RUNFLY_CHECKNOFALL);
nofallMultiplier = ((float) 200) / 100F;
nofallaggressive = data.getBoolean(ConfPaths.MOVING_RUNFLY_NOFALLAGGRESSIVE);
nofallActions = data.getActionList(ConfPaths.MOVING_RUNFLY_NOFALLACTIONS);
morePacketsCheck = data.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK);

View File

@ -31,15 +31,23 @@ public class NoFallCheck extends MovingCheck {
data.lastAddedFallDistance = 0F;
return null;
}
// This check is pretty much always a step behind for technical reasons.
if(data.fromOnOrInGround) {
// Start with zero fall distance
data.fallDistance = 0F;
}
if(data.fromOnOrInGround && data.toOnOrInGround && data.from.y <= data.to.y && player.getPlayer().getFallDistance() > 2.0F) {
player.dealFallDamage();
if(cc.nofallaggressive && data.fromOnOrInGround && data.toOnOrInGround && data.from.y <= data.to.y && player.getPlayer().getFallDistance() > 3.0F) {
data.fallDistance = player.getPlayer().getFallDistance();
data.nofallVL += data.fallDistance;
data.nofallTotalVL += data.fallDistance;
data.nofallFailed++;
final boolean cancel = executeActions(player, cc.nofallActions.getActions(data.nofallVL));
if(cancel) {
player.dealFallDamage();
}
data.fallDistance = 0F;
}
// If we increased fall height before for no good reason, reduce now by

View File

@ -31,6 +31,7 @@ public abstract class ConfPaths {
public final static String MOVING_RUNFLY_ACTIONS = MOVING_RUNFLY + "actions";
public final static String MOVING_RUNFLY_CHECKNOFALL = MOVING_RUNFLY + "checknofall";
public final static String MOVING_RUNFLY_NOFALLAGGRESSIVE = MOVING_RUNFLY + "nofallaggressivemode";
public final static String MOVING_RUNFLY_NOFALLACTIONS = MOVING_RUNFLY + "nofallactions";
private final static String MOVING_RUNFLY_FLYING = MOVING_RUNFLY + "flying.";

View File

@ -36,6 +36,7 @@ public class DefaultConfiguration extends NoCheatConfiguration {
set(ConfPaths.MOVING_RUNFLY_ACTIONS, "log:moveshort:3:5:f cancel vl>100 log:moveshort:0:5:if cancel vl>400 log:movelong:0:5:cif cancel");
set(ConfPaths.MOVING_RUNFLY_CHECKNOFALL, true);
set(ConfPaths.MOVING_RUNFLY_NOFALLAGGRESSIVE, true);
set(ConfPaths.MOVING_RUNFLY_NOFALLACTIONS, "log:nofall:0:5:cif cancel");
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS, false);