mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-10-03 00:47:25 +02:00
Add workaround for inexact login/respawn locations (vertical).
When the respawn/login location is obstructed, the respawn event shows that location, but the first move will start at several blocks above, without having a teleport event to rely on, thus this workaround.
This commit is contained in:
parent
4a81664101
commit
6d6f908512
@ -220,6 +220,8 @@ public class MovingData extends ACheckData {
|
||||
/** Inconsistency-flag. Set on moving inside of vehicles, reset on exiting properly. Workaround for VehicleLeaveEvent missing. */
|
||||
public boolean wasInVehicle = false;
|
||||
public MoveConsistency vehicleConsistency = MoveConsistency.INCONSISTENT;
|
||||
/** Set to true after login/respawn, only if the set-back is reset there. Reset in MovingListener after handling PlayerMoveEvent */
|
||||
public boolean joinOrRespawn = false;
|
||||
|
||||
public MovingData(final MovingConfig config) {
|
||||
super(config);
|
||||
|
@ -366,6 +366,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
// TODO: Reset positions? enforceLocation?
|
||||
event.setTo(newTo);
|
||||
}
|
||||
data.joinOrRespawn = false;
|
||||
return;
|
||||
}
|
||||
// newTo should be null here.
|
||||
@ -625,6 +626,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
data.joinOrRespawn = false;
|
||||
moveInfo.cleanup();
|
||||
parkedInfo.add(moveInfo);
|
||||
}
|
||||
@ -1285,6 +1287,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
data.clearFlyData();
|
||||
data.setSetBack(loc);
|
||||
data.resetPositions(loc);
|
||||
data.joinOrRespawn = true;
|
||||
} else {
|
||||
// TODO: Check consistency/distance.
|
||||
//final Location setBack = data.getSetBack(loc);
|
||||
|
@ -128,10 +128,21 @@ public class SurvivalFly extends Check {
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure we have a set-back location set.
|
||||
// Ensure we have a set-back location set, plus allow moving from upwards with respawn/login.
|
||||
if (!data.hasSetBack()) {
|
||||
data.setSetBack(from);
|
||||
}
|
||||
else if (data.joinOrRespawn && from.getY() > data.getSetBackY() &&
|
||||
TrigUtil.isSamePos(from.getX(), from.getZ(), data.getSetBackX(), data.getSetBackZ()) &&
|
||||
(from.isOnGround() || from.isResetCond())) {
|
||||
// TODO: Move most to a method?
|
||||
// TODO: Is a margin needed for from.isOnGround()? [bukkitapionly]
|
||||
if (cc.debug) {
|
||||
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " SurvivalFly\nAdjust set-back after join/respawn: " + from.getLocation());
|
||||
}
|
||||
data.setSetBack(from);
|
||||
data.resetPositions(from);
|
||||
}
|
||||
|
||||
// Set some flags.
|
||||
final boolean fromOnGround = from.isOnGround();
|
||||
@ -474,13 +485,13 @@ public class SurvivalFly extends Check {
|
||||
// TODO: Is above stairs ?
|
||||
}
|
||||
|
||||
// // Invalidation of vertical velocity.
|
||||
// // TODO: This invalidation is wrong in case of already jumped higher (can not be repaired?).
|
||||
// if (yDistance <= 0 && data.sfLastYDist > 0 && data.sfLastYDist != Double.MAX_VALUE
|
||||
// && data.invalidateVerVelGrace(cc.velocityGraceTicks, false)) {
|
||||
// // (Only prevent counting further up, leaves the freedom.)
|
||||
// tags.add("cap_vvel"); // TODO: Test / validate by logs.
|
||||
// }
|
||||
// // Invalidation of vertical velocity.
|
||||
// // TODO: This invalidation is wrong in case of already jumped higher (can not be repaired?).
|
||||
// if (yDistance <= 0 && data.sfLastYDist > 0 && data.sfLastYDist != Double.MAX_VALUE
|
||||
// && data.invalidateVerVelGrace(cc.velocityGraceTicks, false)) {
|
||||
// // (Only prevent counting further up, leaves the freedom.)
|
||||
// tags.add("cap_vvel"); // TODO: Test / validate by logs.
|
||||
// }
|
||||
|
||||
// Apply reset conditions.
|
||||
if (resetTo) {
|
||||
|
@ -522,6 +522,18 @@ public class TrigUtil {
|
||||
return x1 == x2 && y1 == y2 && z1 == z2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the coordinates represent the same position (2D).
|
||||
* @param x1
|
||||
* @param z1
|
||||
* @param x2
|
||||
* @param z2
|
||||
* @return
|
||||
*/
|
||||
public static boolean isSamePos(final double x1, final double z1, final double x2, final double z2){
|
||||
return x1 == x2 && z1 == z2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the given double-coordinates are on the same block as specified by the int-coordinates.
|
||||
* @param loc
|
||||
|
Loading…
Reference in New Issue
Block a user