mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-06 18:50:54 +01:00
Set fall distance to 0, if the player could fly or is in creative mode.
This commit is contained in:
parent
f1342fd021
commit
520e7bab74
@ -1,6 +1,7 @@
|
||||
package fr.neatmonster.nocheatplus.checks.moving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -209,13 +210,18 @@ public class NoFall extends Check {
|
||||
public void onLeave(final Player player) {
|
||||
final MovingData data = MovingData.getData(player);
|
||||
final float fallDistance = player.getFallDistance();
|
||||
if (data.noFallFallDistance - fallDistance > 0){
|
||||
// Might use tolerance, might log, might use method (compare: MovingListener.onEntityDamage).
|
||||
// Might consider triggering violations here as well.
|
||||
final float yDiff = (float) (data.noFallMaxY - player.getLocation(useLoc).getY());
|
||||
useLoc.setWorld(null);
|
||||
final float maxDist = Math.max(yDiff, Math.max(data.noFallFallDistance, fallDistance));
|
||||
player.setFallDistance(maxDist);
|
||||
if (data.noFallFallDistance - fallDistance > 0.0) {
|
||||
if (player.getAllowFlight() || player.isFlying() || player.getGameMode() == GameMode.CREATIVE) {
|
||||
// Forestall potential issues with flying plugins.
|
||||
player.setFallDistance(0f);
|
||||
} else {
|
||||
// Might use tolerance, might log, might use method (compare: MovingListener.onEntityDamage).
|
||||
// Might consider triggering violations here as well.
|
||||
final float yDiff = (float) (data.noFallMaxY - player.getLocation(useLoc).getY());
|
||||
useLoc.setWorld(null);
|
||||
final float maxDist = Math.max(yDiff, Math.max(data.noFallFallDistance, fallDistance));
|
||||
player.setFallDistance(maxDist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user