mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 03:48:50 +01:00
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:
parent
81ec563474
commit
6c610c490b
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user