mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-27 01:41:28 +01:00
Ensure no fall distance remains for leaving players who could fly.
This commit is contained in:
parent
c27c03cf8e
commit
6767bd7eec
@ -211,14 +211,17 @@ public class NoFall extends Check {
|
|||||||
final MovingData data = MovingData.getData(player);
|
final MovingData data = MovingData.getData(player);
|
||||||
final float fallDistance = player.getFallDistance();
|
final float fallDistance = player.getFallDistance();
|
||||||
if (data.noFallFallDistance - fallDistance > 0.0) {
|
if (data.noFallFallDistance - fallDistance > 0.0) {
|
||||||
|
final double playerY = player.getLocation(useLoc).getY();
|
||||||
|
useLoc.setWorld(null);
|
||||||
if (player.getAllowFlight() || player.isFlying() || player.getGameMode() == GameMode.CREATIVE) {
|
if (player.getAllowFlight() || player.isFlying() || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
// Forestall potential issues with flying plugins.
|
// Forestall potential issues with flying plugins.
|
||||||
player.setFallDistance(0f);
|
player.setFallDistance(0f);
|
||||||
|
data.noFallFallDistance = 0f;
|
||||||
|
data.noFallMaxY = playerY;
|
||||||
} else {
|
} else {
|
||||||
// Might use tolerance, might log, might use method (compare: MovingListener.onEntityDamage).
|
// Might use tolerance, might log, might use method (compare: MovingListener.onEntityDamage).
|
||||||
// Might consider triggering violations here as well.
|
// Might consider triggering violations here as well.
|
||||||
final float yDiff = (float) (data.noFallMaxY - player.getLocation(useLoc).getY());
|
final float yDiff = (float) (data.noFallMaxY - playerY);
|
||||||
useLoc.setWorld(null);
|
|
||||||
final float maxDist = Math.max(yDiff, Math.max(data.noFallFallDistance, fallDistance));
|
final float maxDist = Math.max(yDiff, Math.max(data.noFallFallDistance, fallDistance));
|
||||||
player.setFallDistance(maxDist);
|
player.setFallDistance(maxDist);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user