Add new responses to handle quest reroll situations

This commit fixes a bug where the quest reroll feature could be used repeatedly without restrictions. Now, appropriate responses will be given in cases where the quest is still loading or if the daily quest has already been completed. This ensures that the player cannot misuse the reroll functionality.
This commit is contained in:
Teriuihi 2024-04-18 20:49:05 +02:00
parent 34c5252db4
commit 81ed73fbd1
2 changed files with 17 additions and 1 deletions

View File

@ -21,10 +21,21 @@ public class CommandReRoll extends SubCommand {
commandSender.sendMiniMessage(MessagesConfig.NO_RE_ROLL_YET, null);
return true;
}
Quest dailyQuest = Quest.getDailyQuest(player.getUniqueId());
if (dailyQuest == null) {
commandSender.sendMiniMessage(MessagesConfig.WAIT_FOR_QUEST, null);
return true;
}
if (dailyQuest.isDone()) {
commandSender.sendMiniMessage(MessagesConfig.QUEST_ALREADY_FINISHED, null);
return true;
}
Quest.createDailyQuest(player);
commandSender.sendMiniMessage(MessagesConfig.QUEST_RE_ROLLED, null);
ConsoleCommandSender consoleSender = Bukkit.getConsoleSender();
Bukkit.dispatchCommand(consoleSender, "lp user %s permission settemp aquest.reroll.on-cooldown true 7d");
Bukkit.dispatchCommand(consoleSender, String.format("lp user %s permission settemp aquest.reroll.on-cooldown true 7d", player.getName()));
return true;
}

View File

@ -42,6 +42,9 @@ public class MessagesConfig extends AbstractConfig{
public static String NOT_FINISHED_QUEST = "<red>You have not finished this quest yet.</red>";
public static String QUEST_RE_ROLLED = "<white>[<gold>Mascot</gold>] <light_purple>Scruff</light_purple><gray>:</gray> <green>I see, that last quest was too much for you, that's okay I have given you another one!</green></white>";
public static String NO_RE_ROLL_YET = "<white>[<gold>Mascot</gold>] <light_purple>Scruff</light_purple><gray>:</gray> <green>Sorry, you already rerolled your quest within the last 7 days. I can't give you a different quest quite yet.</green></white>";
public static String WAIT_FOR_QUEST = "<white>[<gold>Mascot</gold>] <light_purple>Scruff</light_purple><gray>:</gray> <green>You don't seem to have any quest, please wait for it to load!</green></white>";
public static String QUEST_ALREADY_FINISHED = "<white>[<gold>Mascot</gold>] <light_purple>Scruff</light_purple><gray>:</gray> <green>You already finished your quest today. You will get a new one tomorrow.</green></white>";
private static void loadMessages() {
TOO_FAR_FROM_NPC = config.getString("messages.too-far-from-npc", TOO_FAR_FROM_NPC);
DAILY_ALREADY_DONE = config.getString("messages.daily-already-done", DAILY_ALREADY_DONE);
@ -52,6 +55,8 @@ public class MessagesConfig extends AbstractConfig{
NOT_FINISHED_QUEST = config.getString("messages.not-finished-quest", NOT_FINISHED_QUEST);
QUEST_RE_ROLLED = config.getString("messages.re-rolled-quest", QUEST_RE_ROLLED);
NO_RE_ROLL_YET = config.getString("messages.no-re-rolled-yet", NO_RE_ROLL_YET);
WAIT_FOR_QUEST = config.getString("messages.wait-for-yet", WAIT_FOR_QUEST);
QUEST_ALREADY_FINISHED = config.getString("messages.quest-already-finished", QUEST_ALREADY_FINISHED);
}
public static String NO_PERMISSION = "<red>You do not have permission to do that.</red>";