Send teleportation cancellation message immediately on movement, rather than after the timer has finished. This fixes PS-33.

This commit is contained in:
Alexander Söderberg 2020-07-09 16:45:25 +02:00
parent 904f5485ab
commit 6b07f38cff
No known key found for this signature in database
GPG Key ID: C0207FF7EA146678
2 changed files with 7 additions and 5 deletions

View File

@ -822,7 +822,9 @@ public class PlayerEvents extends PlotListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
BukkitPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) {
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
}
// Set last location // Set last location
Location location = BukkitUtil.getLocation(to); Location location = BukkitUtil.getLocation(to);
pp.setMeta(PlotPlayer.META_LOCATION, location); pp.setMeta(PlotPlayer.META_LOCATION, location);
@ -882,7 +884,9 @@ public class PlayerEvents extends PlotListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
BukkitPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) {
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
}
// Set last location // Set last location
Location location = BukkitUtil.getLocation(to); Location location = BukkitUtil.getLocation(to);
pp.setMeta(PlotPlayer.META_LOCATION, location); pp.setMeta(PlotPlayer.META_LOCATION, location);

View File

@ -3010,11 +3010,9 @@ public class Plot {
final String name = player.getName(); final String name = player.getName();
TaskManager.TELEPORT_QUEUE.add(name); TaskManager.TELEPORT_QUEUE.add(name);
TaskManager.runTaskLater(() -> { TaskManager.runTaskLater(() -> {
if (!TaskManager.TELEPORT_QUEUE.contains(name)) { if (!TaskManager.TELEPORT_QUEUE.remove(name)) {
MainUtil.sendMessage(player, Captions.TELEPORT_FAILED);
return; return;
} }
TaskManager.TELEPORT_QUEUE.remove(name);
if (player.isOnline()) { if (player.isOnline()) {
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT); MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
player.teleport(location, cause); player.teleport(location, cause);