From d1ecedebcafcf4542ad22154c1772d846802c6b7 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Wed, 31 Jul 2024 01:39:09 -0400 Subject: [PATCH] Delay quest command to retain order --- .../quest/BukkitQuestCommandHandler.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/me/pikamug/quests/commands/quest/BukkitQuestCommandHandler.java b/core/src/main/java/me/pikamug/quests/commands/quest/BukkitQuestCommandHandler.java index 895c9a20e..cc7373722 100644 --- a/core/src/main/java/me/pikamug/quests/commands/quest/BukkitQuestCommandHandler.java +++ b/core/src/main/java/me/pikamug/quests/commands/quest/BukkitQuestCommandHandler.java @@ -44,22 +44,28 @@ public class BukkitQuestCommandHandler { final Player player = (Player) cs; final Quester quester = plugin.getQuester(player.getUniqueId()); if (!quester.getCurrentQuests().isEmpty()) { + final int[] ticks = {1}; for (final Quest q : quester.getCurrentQuests().keySet()) { final Stage stage = quester.getCurrentStage(q); q.updateCompass(quester, stage); - if (plugin.getQuester(player.getUniqueId()).getQuestProgressOrDefault(q).getDelayStartTime() == 0 - || plugin.getQuester(player.getUniqueId()).getStageTime(q) < 0L) { + if (quester.getQuestProgressOrDefault(q).getDelayStartTime() == 0 + || quester.getStageTime(q) < 0L) { final String msg = BukkitLang.get(player, "questObjectivesTitle") .replace("", q.getName()); - BukkitLang.send(player, ChatColor.GOLD + msg); - quester.showCurrentObjectives(q, quester, false); + plugin.getServer().getScheduler().runTaskLater(plugin, () -> { + BukkitLang.send(player, ChatColor.GOLD + msg); + quester.showCurrentObjectives(q, quester, false); + ticks[0]++; + }, ticks[0]); } else { - final long time = plugin.getQuester(player.getUniqueId()).getStageTime(q); - String msg = ChatColor.YELLOW + "(" + BukkitLang.get(player, "delay") + ") " + ChatColor.RED - + BukkitLang.get(player, "plnTooEarly"); - msg = msg.replace("", q.getName()); - msg = msg.replace("