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,7 +210,11 @@ 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){
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());
@ -218,6 +223,7 @@ public class NoFall extends Check {
player.setFallDistance(maxDist);
}
}
}
/**
* This is called if a player fails a check and gets set back, to avoid using that to avoid fall damage the player might be dealt damage here.