mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-28 18:31:24 +01:00
[BLEEDING] Refine logging on logout. Actually set-back on logout.
* Always log location of logout if debug is set. * Also check inconsistent logout if manahattan distance is > 0. * Only perform "passable check" only if enabled and not dead/sleeping. * Try to actually set-back.
This commit is contained in:
parent
e12c2a2bfc
commit
b57d7745e4
@ -1353,28 +1353,42 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
|
||||
@Override
|
||||
public void playerLeaves(final Player player) {
|
||||
final MovingConfig cc = MovingConfig.getConfig(player);
|
||||
final MovingData data = MovingData.getData(player);
|
||||
// Check for missed moves.
|
||||
final Location loc = player.getLocation(useLoc);
|
||||
if (!BlockProperties.isPassable(loc)) {
|
||||
boolean warn = false;
|
||||
if (data.toX != Double.MAX_VALUE) {
|
||||
final Location refLoc = new Location(loc.getWorld(), data.toX, data.toY, data.toZ);
|
||||
final double d = refLoc.distanceSquared(loc);
|
||||
if (d > 0.0) {
|
||||
if (BlockProperties.isPassable(refLoc)) {
|
||||
warn = true;
|
||||
StringBuilder builder = new StringBuilder(128);
|
||||
DebugUtil.addMove(refLoc, loc, null, builder);
|
||||
LogUtil.logWarning("[NoCheatPlus] Potential exploit: Player " + player.getName() + " logs out having moved into a block: " + builder.toString());
|
||||
// Debug logout.
|
||||
if (cc.debug) {
|
||||
LogUtil.logInfo("[NoCheatPlus] Player " + player.getName() + " leaves at location: " + loc.toString());
|
||||
}
|
||||
if (!player.isSleeping() && !player.isDead()) {
|
||||
// Check for missed moves.
|
||||
// TODO: Consider to catch all, at least (debug-) logging-wise.
|
||||
if (!BlockProperties.isPassable(loc)) {
|
||||
if (data.toX != Double.MAX_VALUE) {
|
||||
final Location refLoc = new Location(loc.getWorld(), data.toX, data.toY, data.toZ);
|
||||
final double d = refLoc.distanceSquared(loc);
|
||||
if (d > 0.0) {
|
||||
// TODO: Consider to always set back here. Might skip on big distances.
|
||||
if (TrigUtil.manhattan(loc, refLoc) > 0 || BlockProperties.isPassable(refLoc)) {
|
||||
if (passable.isEnabled(player)) {
|
||||
LogUtil.logWarning("[NoCheatPlus] Potential exploit: Player " + player.getName() + " leaves, having moved into a block (not tracked by moving checks): " + player.getWorld().getName() + " / " + DebugUtil.formatMove(refLoc, loc));
|
||||
// TODO: Actually trigger a passable violation (+tag).
|
||||
if (d > 1.25) {
|
||||
LogUtil.logWarning("[NoCheatPlus] SKIP set-back for " + player.getName() + ", because distance is too high (risk of false positives): " + d);
|
||||
} else {
|
||||
LogUtil.logInfo("[NoCheatPlus] Set back player " + player.getName() + ": " + DebugUtil.formatLocation(refLoc));
|
||||
data.prepareSetBack(refLoc);
|
||||
if (!player.teleport(refLoc)) {
|
||||
LogUtil.logWarning("[NoCheatPlus] FAILED to set back player " + player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (warn) {
|
||||
// TODO: Additional debug info. Might include full moving trace ?
|
||||
}
|
||||
useLoc.setWorld(null);
|
||||
}
|
||||
useLoc.setWorld(null);
|
||||
// Adjust data.
|
||||
survivalFly.setReallySneaking(player, false);
|
||||
noFall.onLeave(player);
|
||||
|
@ -103,6 +103,7 @@ public class Passable extends Check {
|
||||
loc = null;
|
||||
tags += "into";
|
||||
} else if (BlockProperties.isPassable(from.getBlockCache(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(lbX, lbY, lbZ))) {
|
||||
// Keep loc.
|
||||
tags += "into_shift";
|
||||
}
|
||||
// } else if (BlockProperties.isPassableExact(from.getBlockCache(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(lbX, lbY, lbZ))) {
|
||||
|
@ -20,6 +20,29 @@ import fr.neatmonster.nocheatplus.utilities.build.BuildParameters;
|
||||
public class DebugUtil {
|
||||
|
||||
// TODO: Add useLoc1 and useLoc2.
|
||||
|
||||
/**
|
||||
* Just the coordinates.
|
||||
* @param loc
|
||||
* @return
|
||||
*/
|
||||
public static String formatLocation(final Location loc) {
|
||||
StringBuilder b = new StringBuilder(128);
|
||||
addLocation(loc, b);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Just the coordinates.
|
||||
* @param from
|
||||
* @param to
|
||||
* @return
|
||||
*/
|
||||
public static String formatMove(Location from, Location to) {
|
||||
StringBuilder builder = new StringBuilder(128);
|
||||
DebugUtil.addMove(from, to, null, builder);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static boolean isSamePos(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2){
|
||||
return x1 == x2 && y1 == y2 && z1 == z2;
|
||||
|
@ -5,7 +5,6 @@ import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user