diff --git a/api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java b/api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java index 68fa276b1..18ec112a5 100644 --- a/api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java +++ b/api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java @@ -76,7 +76,7 @@ public abstract class QuestsNumericPrompt extends NumericPrompt { final Matcher matcher = NUMBER_PATTERN.matcher(ChatColor.stripColor(line)); final TextComponent lineComponent = new TextComponent(TextComponent.fromLegacyText(line)); if (matcher.find()) { - lineComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, matcher.group(1))); + lineComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice " + matcher.group(1))); } if (first) { first = false; diff --git a/api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java b/api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java index ad265181f..d1bf64d3d 100644 --- a/api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java +++ b/api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java @@ -71,7 +71,7 @@ public abstract class QuestsStringPrompt extends StringPrompt { for (int i = 0; i < list.size(); i++) { final TextComponent questName = new TextComponent(list.get(i)); questName.setColor(ChatColor.AQUA); - questName.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, ChatColor.stripColor(list.get(i)))); + questName.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice " + ChatColor.stripColor(list.get(i)))); component.addExtra(questName); if (i < (list.size() - 1)) { component.addExtra(separator); diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java b/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java index 325e7d722..8bde48c06 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java @@ -14,6 +14,7 @@ package me.blackvein.quests.commands.quests; import me.blackvein.quests.Quests; import me.blackvein.quests.commands.quests.subcommands.QuestsActionsCommand; +import me.blackvein.quests.commands.quests.subcommands.QuestsChoiceCommand; import me.blackvein.quests.commands.quests.subcommands.QuestsConditionsCommand; import me.blackvein.quests.commands.quests.subcommands.QuestsEditorCommand; import me.blackvein.quests.commands.quests.subcommands.QuestsInfoCommand; @@ -53,7 +54,8 @@ public class QuestsCommandHandler { new QuestsEditorCommand(plugin), new QuestsActionsCommand(plugin), new QuestsConditionsCommand(plugin), - new QuestsInfoCommand(plugin)) + new QuestsInfoCommand(plugin), + new QuestsChoiceCommand()) .collect(Collectors.toMap(QuestsSubCommand::getName, Function.identity())); } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsChoiceCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsChoiceCommand.java new file mode 100644 index 000000000..93326f62b --- /dev/null +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsChoiceCommand.java @@ -0,0 +1,62 @@ +package me.blackvein.quests.commands.quests.subcommands; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import me.blackvein.quests.commands.QuestsSubCommand; +import me.blackvein.quests.util.Lang; + +public class QuestsChoiceCommand extends QuestsSubCommand { + + @Override + public String getName() { + return "choice"; + } + + @Override + public String getNameI18N() { + return Lang.get("COMMAND_CHOICE"); + } + + @Override + public String getDescription() { + return Lang.get("COMMAND_CHOICE_HELP"); + } + + @Override + public String getPermission() { + return "quests.choice"; + } + + @Override + public String getSyntax() { + return "/quests choice"; + } + + @Override + public int getMaxArguments() { + return 2; + } + + @Override + public void execute(CommandSender cs, String[] args) { + if (assertNonPlayer(cs)) { + return; + } + Player player = (Player) cs; + if (!cs.hasPermission(getPermission())) { + Lang.send(player, ChatColor.RED + Lang.get(player, "noPermission")); + return; + } + if (!player.isConversing()) { + Lang.send(player, ChatColor.RED + Lang.get(player, "notConversing")); + return; + } + if (args.length == 1) { + return; + } + player.acceptConversationInput(concatArgArray(args, 1, args.length - 1, ' ')); + } + +} diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index 7af225b70..4aeb42766 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -58,6 +58,9 @@ permissions: quests.journal: description: Toggle the Quest Journal default: true + quests.choice: + description: Respond to a Quests prompt + default: true quests.compass: description: Use a Compass to target quests default: true diff --git a/core/src/main/resources/strings.yml b/core/src/main/resources/strings.yml index 9a55f4432..5c7bc4278 100644 --- a/core/src/main/resources/strings.yml +++ b/core/src/main/resources/strings.yml @@ -18,6 +18,8 @@ COMMAND_TOP: "top" COMMAND_TOP_HELP: " [number] - View plugin leaderboards" COMMAND_INFO: "info" COMMAND_INFO_HELP: " - View plugin information" +COMMAND_CHOICE: "choice" +COMMAND_CHOICE_HELP: " - Make a menu selection" COMMAND_QUEST_HELP: "- View current quest objectives" COMMAND_QUESTINFO_HELP: "[quest] - View information about a quest" COMMAND_QUESTADMIN_HELP: "- Display administrator help" @@ -805,4 +807,5 @@ duplicateEditor: "You are already using an editor!" difference: "The difference is ''." notInstalled: "Not installed" confirmDelete: "Are you sure?" -updateTo: "Update to : " \ No newline at end of file +updateTo: "Update to : " +notConversing: "You are not in a conversation!" \ No newline at end of file