Add reroll command and associated help messages
A new 'reroll' command has been added for players to get a new quest. This feature is now reflected in the help messages. Furthermore, messages have been introduced to inform the player about successful reroll, or if the rerolling option is on cooldown.
This commit is contained in:
parent
379ba6d624
commit
8a22f5188e
|
|
@ -36,7 +36,9 @@ public class CommandManager implements CommandExecutor, TabExecutor {
|
|||
new CommandTurnIn(),
|
||||
new CommandSetQuest(),
|
||||
new CommandGetReward(),
|
||||
new CommandProgress());
|
||||
new CommandProgress(),
|
||||
new CommandReRoll()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
package com.alttd.altitudequests.commands.subcommands;
|
||||
|
||||
import com.alttd.altitudequests.commands.SubCommand;
|
||||
import com.alttd.altitudequests.config.MessagesConfig;
|
||||
import com.alttd.altitudequests.objects.Quest;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandReRoll extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
if (!(commandSender instanceof Player player)) {
|
||||
commandSender.sendMiniMessage(MessagesConfig.NO_CONSOLE, null);
|
||||
return true;
|
||||
}
|
||||
if (player.hasPermission("aquest.reroll.on-cooldown")) {
|
||||
commandSender.sendMiniMessage(MessagesConfig.NO_RE_ROLL_YET, 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");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reroll";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return MessagesConfig.RE_ROLL_HELP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldTabComplete() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ public class MessagesConfig extends AbstractConfig{
|
|||
public static String RELOAD_HELP_MESSAGE = "<green>Reload configs: <gold>/aquest reload</gold></green>";
|
||||
public static String CREATE_SCRUFF_MESSAGE = "<green>Create Scruff: <gold>/aquest createscruff <x> <y> <z> <yaw> <pitch> <world></gold></green>";
|
||||
public static String SET_QUEST_HELP = "<green>Set quest: <gold>/aquest setquest <player> <quest> <variant></gold></green>";
|
||||
public static String RE_ROLL_HELP = "<green>Get a new quest: <gold>/aquest reroll</gold></green>";
|
||||
|
||||
private static void loadHelp() {
|
||||
HELP_MESSAGE_WRAPPER = config.getString("help.help-wrapper", HELP_MESSAGE_WRAPPER);
|
||||
|
|
@ -38,6 +39,8 @@ public class MessagesConfig extends AbstractConfig{
|
|||
public static String REWARD_SENT = "<white>[<gold>Mascot</gold>] <light_purple>Scruff</light_purple><gray>:</gray> <green>Thank you for completing the quest! Your reward has been sent!</green></white>";
|
||||
public static String FINISHED_QUEST = "<white>[<gold>Mascot</gold>] <light_purple>Scruff</light_purple><gray>:</gray> <green>You finished your quest! Don't forget to collect your reward at the end of the quest book!</green></white>";
|
||||
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>";
|
||||
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);
|
||||
|
|
@ -46,6 +49,8 @@ public class MessagesConfig extends AbstractConfig{
|
|||
FINISHED_QUEST = config.getString("messages.finished-quest", FINISHED_QUEST);
|
||||
REWARD_SENT = config.getString("messages.reward-send", REWARD_SENT);
|
||||
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);
|
||||
}
|
||||
|
||||
public static String NO_PERMISSION = "<red>You do not have permission to do that.</red>";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user