mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-16 12:31:28 +01:00
Fixed Respawning
This commit is contained in:
parent
9406961f05
commit
8729400be5
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 1.07b
|
||||
version: 1.07c
|
||||
|
||||
softdepend: [ Permissions, CraftIRC ]
|
||||
|
||||
|
@ -384,6 +384,11 @@ public class MovingCheck extends Check {
|
||||
*/
|
||||
private boolean shouldBeIgnored(final Player player, final MovingData data, final Location from, final Location to) {
|
||||
|
||||
if(data.firstEventAfterRespawn) {
|
||||
data.firstEventAfterRespawn = false;
|
||||
data.teleportTo = from.clone();
|
||||
}
|
||||
|
||||
// Now it gets complicated: (a friendly reminder to myself why this actually works in CB 950+)
|
||||
|
||||
// data.teleportTo gets a location assigned if a teleport event is successfully executed.
|
||||
@ -411,7 +416,7 @@ public class MovingCheck extends Check {
|
||||
}
|
||||
// If the player moved between worlds between events, don't check (wouldn't make sense
|
||||
// to check coordinates between different worlds...)
|
||||
if(!from.getWorld().equals(data.lastLocation)) {
|
||||
if(!from.getWorld().equals(data.lastSeenInWorld)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -468,11 +473,13 @@ public class MovingCheck extends Check {
|
||||
}
|
||||
|
||||
if(!event.isCancelled()) {
|
||||
data.jumpPhase = 0;
|
||||
data.teleportTo = event.getTo().clone();
|
||||
data.setBackPoint = event.getTo().clone();
|
||||
//data.lastLocation = event.getTo().clone();
|
||||
}
|
||||
|
||||
// reset anyway - if another plugin cancelled our teleport it's no use to try and be precise
|
||||
data.jumpPhase = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -480,8 +487,10 @@ public class MovingCheck extends Check {
|
||||
* @param event
|
||||
*/
|
||||
public void respawned(PlayerRespawnEvent event) {
|
||||
//MovingData data = MovingData.get(event.getPlayer());
|
||||
//data.setBackPoint = event.getRespawnLocation().clone();
|
||||
MovingData data = MovingData.get(event.getPlayer());
|
||||
data.firstEventAfterRespawn = true;
|
||||
data.jumpPhase = 0;
|
||||
data.setBackPoint = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -750,5 +759,6 @@ public class MovingCheck extends Check {
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, movingPlayerMonitor, Priority.Monitor, plugin);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, new MovingEntityListener(this), Priority.Monitor, plugin);
|
||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, new MovingPlayerMonitor(this), Priority.Monitor, plugin);
|
||||
pm.registerEvent(Event.Type.PLAYER_RESPAWN, new MovingPlayerMonitor(this), Priority.Monitor, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,10 @@ public class MovingData {
|
||||
public Location teleportTo = null;
|
||||
|
||||
// Use to track the world the player is in
|
||||
public World lastLocation = null;
|
||||
public World lastSeenInWorld = null;
|
||||
|
||||
public Location teleportInitializedByMe = null;
|
||||
public boolean firstEventAfterRespawn = false;
|
||||
|
||||
|
||||
|
||||
@ -84,7 +85,7 @@ public class MovingData {
|
||||
|
||||
if(data.moving == null) {
|
||||
data.moving = new MovingData();
|
||||
data.moving.lastLocation = p.getLocation().getWorld();
|
||||
data.moving.lastSeenInWorld = p.getLocation().getWorld();
|
||||
}
|
||||
|
||||
return data.moving;
|
||||
|
@ -3,6 +3,7 @@ package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
||||
@ -26,6 +27,11 @@ public class MovingPlayerMonitor extends PlayerListener {
|
||||
check.teleported(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
this.check.respawned(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
check.updateVelocity(event.getPlayer().getVelocity(), MovingData.get(event.getPlayer()));
|
||||
@ -35,7 +41,7 @@ public class MovingPlayerMonitor extends PlayerListener {
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if(!event.isCancelled()) {
|
||||
MovingData data = MovingData.get(event.getPlayer());
|
||||
data.lastLocation = event.getPlayer().getLocation().getWorld();
|
||||
data.lastSeenInWorld = event.getPlayer().getLocation().getWorld();
|
||||
if( event.getPlayer().isInsideVehicle()) {
|
||||
data.setBackPoint = event.getTo();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user