From 520e7bab74ee66d6ae59de4642cdd5172ebb8380 Mon Sep 17 00:00:00 2001 From: asofold Date: Fri, 21 Mar 2014 10:11:47 +0100 Subject: [PATCH] Set fall distance to 0, if the player could fly or is in creative mode. --- .../nocheatplus/checks/moving/NoFall.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/NoFall.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/NoFall.java index a016aa67..2d2e26d8 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/NoFall.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/NoFall.java @@ -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); + } } }