Set fall distance to 0, if the player could fly or is in creative mode.

This commit is contained in:
asofold 2014-03-21 10:11:47 +01:00
parent f1342fd021
commit 520e7bab74

View File

@ -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);
}
}
}