From 6b07f38cff49aae77fdcab615eb43b6faff5fb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 9 Jul 2020 16:45:25 +0200 Subject: [PATCH] Send teleportation cancellation message immediately on movement, rather than after the timer has finished. This fixes PS-33. --- .../com/plotsquared/bukkit/listener/PlayerEvents.java | 8 ++++++-- Core/src/main/java/com/plotsquared/core/plot/Plot.java | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index d81f24fa6..8cd72da47 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -822,7 +822,9 @@ public class PlayerEvents extends PlotListener implements Listener { Player player = event.getPlayer(); BukkitPlayer pp = BukkitUtil.getPlayer(player); // Cancel teleport - TaskManager.TELEPORT_QUEUE.remove(pp.getName()); + if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) { + MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED); + } // Set last location Location location = BukkitUtil.getLocation(to); pp.setMeta(PlotPlayer.META_LOCATION, location); @@ -882,7 +884,9 @@ public class PlayerEvents extends PlotListener implements Listener { Player player = event.getPlayer(); BukkitPlayer pp = BukkitUtil.getPlayer(player); // Cancel teleport - TaskManager.TELEPORT_QUEUE.remove(pp.getName()); + if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) { + MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED); + } // Set last location Location location = BukkitUtil.getLocation(to); pp.setMeta(PlotPlayer.META_LOCATION, location); diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 46ce9f24c..2adca5334 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -3010,11 +3010,9 @@ public class Plot { final String name = player.getName(); TaskManager.TELEPORT_QUEUE.add(name); TaskManager.runTaskLater(() -> { - if (!TaskManager.TELEPORT_QUEUE.contains(name)) { - MainUtil.sendMessage(player, Captions.TELEPORT_FAILED); + if (!TaskManager.TELEPORT_QUEUE.remove(name)) { return; } - TaskManager.TELEPORT_QUEUE.remove(name); if (player.isOnline()) { MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT); player.teleport(location, cause);