Delay quest command to retain order

This commit is contained in:
PikaMug 2024-07-31 01:39:09 -04:00
parent 4d451474a9
commit d1ecedebca

View File

@ -44,22 +44,28 @@ public class BukkitQuestCommandHandler {
final Player player = (Player) cs; final Player player = (Player) cs;
final Quester quester = plugin.getQuester(player.getUniqueId()); final Quester quester = plugin.getQuester(player.getUniqueId());
if (!quester.getCurrentQuests().isEmpty()) { if (!quester.getCurrentQuests().isEmpty()) {
final int[] ticks = {1};
for (final Quest q : quester.getCurrentQuests().keySet()) { for (final Quest q : quester.getCurrentQuests().keySet()) {
final Stage stage = quester.getCurrentStage(q); final Stage stage = quester.getCurrentStage(q);
q.updateCompass(quester, stage); q.updateCompass(quester, stage);
if (plugin.getQuester(player.getUniqueId()).getQuestProgressOrDefault(q).getDelayStartTime() == 0 if (quester.getQuestProgressOrDefault(q).getDelayStartTime() == 0
|| plugin.getQuester(player.getUniqueId()).getStageTime(q) < 0L) { || quester.getStageTime(q) < 0L) {
final String msg = BukkitLang.get(player, "questObjectivesTitle") final String msg = BukkitLang.get(player, "questObjectivesTitle")
.replace("<quest>", q.getName()); .replace("<quest>", q.getName());
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
BukkitLang.send(player, ChatColor.GOLD + msg); BukkitLang.send(player, ChatColor.GOLD + msg);
quester.showCurrentObjectives(q, quester, false); quester.showCurrentObjectives(q, quester, false);
ticks[0]++;
}, ticks[0]);
} else { } else {
final long time = plugin.getQuester(player.getUniqueId()).getStageTime(q); final long time = quester.getStageTime(q);
String msg = ChatColor.YELLOW + "(" + BukkitLang.get(player, "delay") + ") " + ChatColor.RED final String msg = ChatColor.YELLOW + "(" + BukkitLang.get(player, "delay") + ") "
+ BukkitLang.get(player, "plnTooEarly"); + ChatColor.RED + BukkitLang.get(player, "plnTooEarly")
msg = msg.replace("<quest>", q.getName()); .replace("<quest>", q.getName().replace("<time>", BukkitMiscUtil.getTime(time)));
msg = msg.replace("<time>", BukkitMiscUtil.getTime(time)); plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
BukkitLang.send(player, msg); BukkitLang.send(player, msg);
ticks[0]++;
}, ticks[0]);
} }
} }
} else { } else {