From 1e7b60f79b0b5c36cf462bc6ae60c10d0573ec40 Mon Sep 17 00:00:00 2001 From: asofold Date: Sat, 3 Nov 2012 09:55:50 +0100 Subject: [PATCH] Prefer the set-back location from passable, but still check it first. --- .../checks/moving/MovingListener.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index 12d8a0f2..e01ef852 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -387,13 +387,18 @@ public class MovingListener implements Listener { } - Location newTo = null; - - if (passable.isEnabled(player)) newTo = passable.check(player, pFrom, pTo, data, cc); + Location newTo = null; + + final Location passableTo; + // Check passable in any case (!) + if (passable.isEnabled(player)) { + // Passable is checked first to get the original set-back locations from the other checks, if needed. + passableTo = passable.check(player, pFrom, pTo, data, cc); + } + else passableTo = null; // Optimized checking, giving creativefly permission precedence over survivalfly. - if (newTo != null); - else if (!player.hasPermission(Permissions.MOVING_CREATIVEFLY)){ + if (!player.hasPermission(Permissions.MOVING_CREATIVEFLY)){ // Either survivalfly or speed check. if ((cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && (cc.ignoreAllowFlight || !player.getAllowFlight()) && cc.survivalFlyCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) && !player.hasPermission(Permissions.MOVING_SURVIVALFLY)){ @@ -412,13 +417,16 @@ public class MovingListener implements Listener { } else data.clearFlyData(); - if (newTo == null - && cc.morePacketsCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_MOREPACKETS) && !player.hasPermission(Permissions.MOVING_MOREPACKETS)) - // If he hasn't been stopped by any other check and is handled by the more packets check, execute it. - newTo = morePackets.check(player, pFrom, pTo, data, cc); - else - // Otherwise we need to clear his data. - data.clearMorePacketsData(); + if (newTo == null && cc.morePacketsCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_MOREPACKETS) && !player.hasPermission(Permissions.MOVING_MOREPACKETS)) { + // If he hasn't been stopped by any other check and is handled by the more packets check, execute it. + newTo = morePackets.check(player, pFrom, pTo, data, cc); + } else { + // Otherwise we need to clear his data. + data.clearMorePacketsData(); + } + + // Prefer the location returned by passable. + if (passableTo != null) newTo = passableTo; // Did one of the checks decide we need a new "to"-location? if (newTo != null) { @@ -428,13 +436,16 @@ public class MovingListener implements Listener { // Remember where we send the player to. data.teleported = newTo; } + // Set positions. + // TODO: Should these be set on monitor ? data.fromX = from.getX(); data.fromY = from.getY(); data.fromZ = from.getZ(); data.toX = to.getX(); data.toY = to.getY(); data.toZ = to.getZ(); + // Cleanup. moveInfo.cleanup(); parkedInfo.add(moveInfo);