From 6c610c490b684ca57e18ec24b1258126fbeb512e Mon Sep 17 00:00:00 2001 From: asofold Date: Sat, 3 Nov 2012 04:24:43 +0100 Subject: [PATCH] Bleeding: Set setBack on player join. This avoids missing moving events that might go into blocks, for instance, the setBack location will either be set from before or get set on player join. [Still edge cases missing, world changes, world removal] --- .../checks/moving/MovingListener.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index 69fab1db..12d8a0f2 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -26,6 +26,7 @@ import org.bukkit.event.player.PlayerBedLeaveEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPortalEvent; @@ -715,6 +716,22 @@ public class MovingListener implements Listener { // Entity fall-distance should be reset elsewhere. } + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerJoin(final PlayerJoinEvent event) { + final Player player = event.getPlayer(); + if (survivalFly.isEnabled(player)){ + final MovingData data = MovingData.getData(player); + // TODO: on existing set back: detect world changes and loss of world on join (+ set up some paradigm). + if (data.setBack == null){ + data.setBack = player.getLocation(); + } + if (data.fromX == Double.MAX_VALUE && data.toX == Double.MAX_VALUE){ + // TODO: re-think: more fine grained reset? + data.resetPositions(data.setBack); + } + } + } + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerQuit(final PlayerQuitEvent event){ noFall.onLeave(event.getPlayer());