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]
This commit is contained in:
asofold 2012-11-03 04:24:43 +01:00
parent 81ec563474
commit 6c610c490b

View File

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