Skip to content

Commit

Permalink
Reset the joinOrRespawn flag in more cases.
Browse files Browse the repository at this point in the history
* Vehicle leave, enter, move.
* Teleport.
  • Loading branch information
asofold committed May 31, 2015
1 parent 6d6f908 commit 431099c
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -874,6 +874,9 @@ public void onPlayerTeleport(final PlayerTeleportEvent event) {
final MovingData data = MovingData.getData(player);
final Location teleported = data.getTeleported();

// Invalidate first-move thing.
data.joinOrRespawn = false;

// If it was a teleport initialized by NoCheatPlus, do it anyway even if another plugin said "no".
Location to = event.getTo();
final Location ref;
Expand Down Expand Up @@ -1094,6 +1097,7 @@ public void onVehicleMove(final Entity vehicle, final Location from, final Locat
if (!from.getWorld().equals(to.getWorld())) return;

final MovingData data = MovingData.getData(player);
data.joinOrRespawn = false;
data.vehicleConsistency = MoveConsistency.getConsistency(from, to, player.getLocation(useLoc));
switch (data.vehicleConsistency) {
case FROM:
Expand Down Expand Up @@ -1400,7 +1404,9 @@ public void onWorldunload(final WorldUnloadEvent event) {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVehicleExit(final VehicleExitEvent event) {
final Entity entity = event.getExited();
if (!(entity instanceof Player)) return;
if (!(entity instanceof Player)) {
return;
}
onPlayerVehicleLeave((Player) entity, event.getVehicle());
}

Expand Down Expand Up @@ -1434,6 +1440,7 @@ public void onPlayerVehicleEnter(final VehicleEnterEvent event) {
}
final Player player = (Player) entity;
final MovingData data = MovingData.getData(player);
data.joinOrRespawn = false;
data.removeAllVelocity();
// Event should have a vehicle, in case check this last.
data.vehicleConsistency = MoveConsistency.getConsistency(event.getVehicle().getLocation(), null, player.getLocation(useLoc));
Expand All @@ -1449,6 +1456,7 @@ public void onPlayerVehicleEnter(final VehicleEnterEvent event) {
private void onPlayerVehicleLeave(final Player player, final Entity vehicle) {
final MovingData data = MovingData.getData(player);
data.wasInVehicle = false;
data.joinOrRespawn = false;
// if (data.morePacketsVehicleTaskId != -1) {
// // Await set-back.
// // TODO: might still set ordinary set-backs ?
Expand Down

0 comments on commit 431099c

Please sign in to comment.