Fix NoFall issues on Spigot/MC 1.7.10.

Changes contain:
* MCAccess.dealFallDamageFiresAnEvent -> true
* Always log basic data on (handled) fall damage events.
* Add a tag for the cancel reason with NoFall. Alter the default alert
message.
* Move 3.0 to Magic.
* Set the skipping flag correctly on allowFlight being set.
This commit is contained in:
asofold 2017-01-22 23:31:28 +01:00
parent b0a9f35f2d
commit 8237fbca57
5 changed files with 34 additions and 17 deletions

View File

@ -200,7 +200,7 @@ public class MCAccessCB3100 implements MCAccess{
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
return AlmostBoolean.YES;
}
// @Override

View File

@ -1689,7 +1689,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// (Set fall distance if set to not reset.)
player.setFallDistance((float) fallDistance);
}
else if (fallDistance >= 3.0) {
else if (fallDistance >= Magic.FALL_DAMAGE_DIST) {
data.noFallSkipAirCheck = true;
}
}
@ -1776,6 +1776,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
float fallDistance = player.getFallDistance();
final float yDiff = (float) (data.noFallMaxY - loc.getY());
final double damage = BridgeHealth.getDamage(event);
if (data.debug) {
debug(player, "Damage(FALL/PRE): " + damage + " / mc=" + player.getFallDistance() + " nf=" + data.noFallFallDistance + " yDiff=" + yDiff);
}
// NoFall bypass checks.
if (!data.noFallSkipAirCheck) {
// Cheat: let Minecraft gather and deal fall damage.
@ -1787,8 +1790,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final float dataDist = Math.max(yDiff, data.noFallFallDistance);
final double dataDamage = NoFall.getDamage(dataDist);
if (damage > dataDamage + 0.5 || dataDamage <= 0.0) {
data.noFallVL += 1.0;
if (noFall.executeActions(player, data.noFallVL, 1.0, cc.noFallActions).willCancel()) {
if (noFallVL(player, "fakefall", data, cc)) {
// NOTE: Double violations are possible with the in-air check below.
// TODO: Differing sub checks, once cancel action...
player.setFallDistance(dataDist);
@ -1815,8 +1817,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// TODO: Account for liquid too?
if (!pLoc.isOnGround(1.0, 0.3, 0.1) && !pLoc.isResetCond() && !pLoc.isAboveLadder() && !pLoc.isAboveStairs()) {
// Likely: force damage in mid-air by setting on-ground to true.
data.noFallVL += 1.0;
if (noFall.executeActions(player, data.noFallVL, 1.0, cc.noFallActions).willCancel() && data.hasSetBack()) {
if (noFallVL(player, "fakeground", data, cc) && data.hasSetBack()) {
// Cancel the event and restore fall distance.
// NoFall data will not be reset
allowReset = false;
@ -1831,11 +1832,8 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
}
}
aux.returnPlayerMoveInfo(moveInfo);
if (data.debug) {
debug(player, "Damage(FALL): " + damage + " / dist=" + player.getFallDistance() + " nf=" + data.noFallFallDistance + " yDiff=" + yDiff);
}
// Fall-back check.
final double maxD = NoFall.getDamage(Math.max(yDiff, Math.max(data.noFallFallDistance, fallDistance))) + (allowReset ? 0.0 : 3.0);
final double maxD = NoFall.getDamage(Math.max(yDiff, Math.max(data.noFallFallDistance, fallDistance))) + (allowReset ? 0.0 : Magic.FALL_DAMAGE_DIST);
if (maxD > damage) {
// TODO: respect dealDamage ?
BridgeHealth.setDamage(event, maxD);
@ -1846,6 +1844,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
if (allowReset) {
// Normal fall damage, reset data.
data.clearNoFallData();
if (data.debug) {
debug(player, "Reset NoFall data on fall damage.");
}
}
else {
// Minecraft/NCP bug or cheating.
@ -1864,6 +1865,17 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
useLoc.setWorld(null);
}
private final boolean noFallVL(final Player player, final String tag,
final MovingData data, final MovingConfig cc) {
data.noFallVL += 1.0;
//if (noFall.executeActions(player, data.noFallVL, 1.0, cc.noFallActions).willCancel()
final ViolationData vd = new ViolationData(noFall, player, data.noFallVL, 1.0, cc.noFallActions);
if (tag != null) {
vd.setParameter(ParameterName.TAGS, tag);
}
return noFall.executeActions(vd).willCancel();
}
/**
* When a player respawns, all information related to the moving checks
* becomes invalid.

View File

@ -90,6 +90,9 @@ public class Magic {
public static final double Y_ON_GROUND_DEFAULT = 0.016; // Jump upwards, while placing blocks.
// public static final double Y_ON_GROUND_DEFAULT = 0.029; // Bounce off slime blocks.
/** The lower bound of fall distance for taking fall damage. */
public static final double FALL_DAMAGE_DIST = 3.0;
/**
* The maximum distance that can be achieved with bouncing back from slime
* blocks.

View File

@ -25,6 +25,7 @@ import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.magic.Magic;
import fr.neatmonster.nocheatplus.checks.moving.model.LocationData;
import fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
@ -53,7 +54,7 @@ public class NoFall extends Check {
* @return
*/
public static final double getDamage(final float fallDistance) {
return fallDistance - 3.0;
return fallDistance - Magic.FALL_DAMAGE_DIST;
}
/**
@ -71,8 +72,8 @@ public class NoFall extends Check {
if (maxD >= 1.0) {
// Check skipping conditions.
if (cc.noFallSkipAllowFlight && player.getAllowFlight()) {
data.noFallSkipAirCheck = true;
data.clearNoFallData();
data.noFallSkipAirCheck = true;
// Not resetting the fall distance here, let Minecraft or the issue tracker deal with that.
}
else {
@ -81,6 +82,7 @@ public class NoFall extends Check {
debug(player, "NoFall deal damage" + (reallyOnGround ? "" : "violation") + ": " + maxD);
}
// TODO: might not be necessary: if (mcPlayer.invulnerableTicks <= 0) [no damage event for resetting]
// TODO: Detect fake fall distance accumulation here as well.
data.noFallSkipAirCheck = true;
dealFallDamage(player, maxD);
}
@ -113,10 +115,10 @@ public class NoFall extends Check {
*/
private void adjustFallDistance(final Player player, final double minY, final boolean reallyOnGround, final MovingData data, final MovingConfig cc) {
final float noFallFallDistance = Math.max(data.noFallFallDistance, (float) (data.noFallMaxY - minY));
if (noFallFallDistance >= 3.0) {
if (noFallFallDistance >= Magic.FALL_DAMAGE_DIST) {
final float fallDistance = player.getFallDistance();
if (noFallFallDistance - fallDistance >= 0.5f // TODO: Why not always adjust, if greater?
|| noFallFallDistance >= 3.5f && fallDistance < 3.5f // Ensure damage.
|| noFallFallDistance >= Magic.FALL_DAMAGE_DIST && fallDistance < Magic.FALL_DAMAGE_DIST // Ensure damage.
) {
player.setFallDistance(noFallFallDistance);
}
@ -196,7 +198,7 @@ public class NoFall extends Check {
// Just reset.
data.clearNoFallData();
// Ensure very big/strange moves don't yield violations.
if (toY - fromY <= -3.0) {
if (toY - fromY <= -Magic.FALL_DAMAGE_DIST) {
data.noFallSkipAirCheck = true;
}
}
@ -209,7 +211,7 @@ public class NoFall extends Check {
adjustFallDistance(player, minY, true, data, cc);
}
// Ensure very big/strange moves don't yield violations.
if (toY - fromY <= -3.0) {
if (toY - fromY <= -Magic.FALL_DAMAGE_DIST) {
data.noFallSkipAirCheck = true;
}
}

View File

@ -581,7 +581,7 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.STRINGS + ".morepackets", start + "sent too many moves ([packets] [tags])" + end);
set(ConfPaths.STRINGS + ".msgtempdenylogin", "You are temporarily denied to join this server.");
set(ConfPaths.STRINGS + ".munchhausen", start + "almost made it off the pit" + end);
set(ConfPaths.STRINGS + ".nofall", start + "tried to avoid fall damage" + end);
set(ConfPaths.STRINGS + ".nofall", start + "tried to alter fall damage ([tags])" + end, 1057);
set(ConfPaths.STRINGS + ".chatfast", start + "acted like spamming (IP: [ip])" + end);
set(ConfPaths.STRINGS + ".noswing", start + "didn't swing arm" + end);
set(ConfPaths.STRINGS + ".passable", start + "moved into a block ([blockid]) from [locationfrom] to [locationto] distance [distance] " + end);