Allow disabling the stance check (checks.moving.ignorestance).

This commit is contained in:
asofold 2015-07-29 01:18:43 +02:00
parent 53021bba98
commit 7792f75564
7 changed files with 35 additions and 13 deletions

View File

@ -150,6 +150,7 @@ public class MovingConfig extends ACheckConfig {
public final double yOnGround;
// General things.
public final boolean ignoreStance;
public final boolean tempKickIllegal;
public final boolean loadChunksOnJoin;
public final long sprintingGrace;
@ -243,6 +244,8 @@ public class MovingConfig extends ACheckConfig {
yOnGround = config.getDouble(ConfPaths.MOVING_YONGROUND, 0.001, 2.0, 0.0626); // sqrt(1/256), see: NetServerHandler.
noFallyOnGround = config.getDouble(ConfPaths.MOVING_NOFALL_YONGROUND, 0.001, 2.0, yOnGround);
// TODO: Ignore the stance, once it is known that the server catches such.
ignoreStance = config.getAlmostBoolean(ConfPaths.MOVING_IGNORESTANCE, AlmostBoolean.NO).decide();
tempKickIllegal = config.getBoolean(ConfPaths.MOVING_TEMPKICKILLEGAL);
loadChunksOnJoin = config.getBoolean(ConfPaths.MOVING_LOADCHUNKS_JOIN);
sprintingGrace = Math.max(0L, (long) (config.getDouble(ConfPaths.MOVING_SPRINTINGGRACE) * 1000.0)); // Config: seconds.

View File

@ -390,8 +390,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
DebugUtil.outputMoveDebug(player, moveInfo.from, moveInfo.to, Math.max(cc.noFallyOnGround, cc.yOnGround), mcAccess);
}
// Check for illegal move and bounding box etc.
if (moveInfo.from.isIllegal() || moveInfo.to.isIllegal()) {
MovingUtil.handleIllegalMove(event, player, data);
if ((moveInfo.from.hasIllegalCoords() || moveInfo.to.hasIllegalCoords()) ||
!cc.ignoreStance && (moveInfo.from.hasIllegalStance() || moveInfo.to.hasIllegalStance())) {
MovingUtil.handleIllegalMove(event, player, data, cc);
moveInfo.cleanup();
parkedInfo.add(moveInfo);
return;

View File

@ -54,7 +54,7 @@ public class MovingUtil {
* @param player
* @param data
*/
public static void handleIllegalMove(final PlayerMoveEvent event, final Player player, final MovingData data)
public static void handleIllegalMove(final PlayerMoveEvent event, final Player player, final MovingData data, final MovingConfig cc)
{
// This might get extended to a check-like thing.
boolean restored = false;
@ -64,7 +64,7 @@ public class MovingUtil {
if (!restored && data.hasSetBack()) {
final Location setBack = data.getSetBack(loc);
pLoc.set(setBack, player);
if (!pLoc.isIllegal()) {
if (!pLoc.hasIllegalCoords() && (cc.ignoreStance || !pLoc.hasIllegalStance())) {
event.setFrom(setBack);
event.setTo(setBack);
restored = true;
@ -75,7 +75,7 @@ public class MovingUtil {
}
if (!restored) {
pLoc.set(loc, player);
if (!pLoc.isIllegal()) {
if (!pLoc.hasIllegalCoords() && (cc.ignoreStance || !pLoc.hasIllegalStance())) {
event.setFrom(loc);
event.setTo(loc);
restored = true;

View File

@ -589,6 +589,8 @@ public abstract class ConfPaths {
// General.
public static final String MOVING_TEMPKICKILLEGAL = MOVING + "tempkickillegal";
public static final String MOVING_IGNORESTANCE = MOVING + "ignorestance";
// TODO: Might add a section for illegal move.
private static final String MOVING_LOADCHUNKS = MOVING + "loadchunks.";
public static final String MOVING_LOADCHUNKS_JOIN = MOVING_LOADCHUNKS + "join";
public static final String MOVING_SPRINTINGGRACE = MOVING + "sprintinggrace";

View File

@ -433,6 +433,7 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.MOVING_VELOCITY_STRICTINVALIDATION, true);
// General.
set(ConfPaths.MOVING_IGNORESTANCE, "default");
set(ConfPaths.MOVING_TEMPKICKILLEGAL, true);
set(ConfPaths.MOVING_LOADCHUNKS_JOIN, true);
set(ConfPaths.MOVING_SPRINTINGGRACE, 2.0);

View File

@ -109,7 +109,8 @@ public class CheckUtils {
*/
public static boolean isBadCoordinate(double ... doubles) {
for (int i = 0; i < doubles.length; i++) {
if (Double.isNaN(doubles[i]) || Double.isInfinite(doubles[i])) {
final double x = doubles[i];
if (Double.isNaN(x) || Double.isInfinite(x) || Math.abs(x) > 3.2E7D) {
return true;
}
}

View File

@ -6,7 +6,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
/**
@ -833,15 +832,30 @@ public class PlayerLocation {
* Attempt to check for some exploits (!).
*
* @return
* @deprecated Legacy method.
*/
public boolean isIllegal() {
final AlmostBoolean spec = mcAccess.isIllegalBounds(player);
if (spec != AlmostBoolean.MAYBE) {
return spec.decide();
if (hasIllegalCoords()) {
return true;
} else {
return hasIllegalStance();
}
else if (Math.abs(minX) > 3.2E7D || Math.abs(maxX) > 3.2E7D || Math.abs(minY) > 3.2E7D || Math.abs(maxY) > 3.2E7D || Math.abs(minZ) > 3.2E7D || Math.abs(maxZ) > 3.2E7D) return true;
// if (Math.abs(box.a) > 3.2E7D || Math.abs(box.b) > 3.2E7D || Math.abs(box.c) > 3.2E7D || Math.abs(box.d) > 3.2E7D || Math.abs(box.e) > 3.2E7D || Math.abs(box.f) > 3.2E7D) return true;
else return false;
}
/**
* Check for bounding box properties that might crash the server (if available, not the absolute coordinates).
* @return
*/
public boolean hasIllegalStance() {
return mcAccess.isIllegalBounds(player).decide(); // MAYBE = NO
}
/**
* Quick check for really bad coordinates (actual problem, if true is returned.).
* @return
*/
public boolean hasIllegalCoords() {
return CheckUtils.isBadCoordinate(minX, maxX, minY, maxY, minZ, maxZ);
}
/**