diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/java/com/leonardobishop/quests/commands/CommandQuests.java | 31 | ||||
| -rw-r--r-- | src/main/java/com/leonardobishop/quests/obj/Messages.java | 1 | ||||
| -rw-r--r-- | src/main/resources/config.yml | 1 |
3 files changed, 23 insertions, 10 deletions
diff --git a/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java b/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java index 69e975d6..0ea56759 100644 --- a/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java +++ b/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java @@ -277,20 +277,31 @@ public class CommandQuests implements CommandExecutor { showAdminHelp(sender, null); return true; } - if (sender instanceof Player && (args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("quests"))) { + if (sender instanceof Player && (args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("quests") || args[0].equalsIgnoreCase("quest"))) { Player player = (Player) sender; - if (args.length >= 2) { + if (args.length >= 3) { Quest quest = plugin.getQuestManager().getQuestById(args[1]); - if (quest == null) { - sender.sendMessage(Messages.COMMAND_QUEST_START_DOESNTEXIST.getMessage().replace("{quest}", args[1])); - } else { - QPlayer qPlayer = plugin.getPlayerManager().getPlayer(player.getUniqueId()); + QPlayer qPlayer = plugin.getPlayerManager().getPlayer(player.getUniqueId()); + + if (args[2].equalsIgnoreCase("s") || args[2].equalsIgnoreCase("start")) { + if (quest == null) { + sender.sendMessage(Messages.COMMAND_QUEST_START_DOESNTEXIST.getMessage().replace("{quest}", args[1])); + } else { + if (qPlayer == null) { + // shit + fan + sender.sendMessage(ChatColor.RED + "An error occurred finding your player."); //lazy? :) + } else { + qPlayer.getQuestProgressFile().startQuest(quest); + } + } + } else if (args[2].equalsIgnoreCase("c") || args[2].equalsIgnoreCase("cancel")) { if (qPlayer == null) { - // shit + fan - sender.sendMessage(ChatColor.RED + "An error occurred finding your player."); //lazy? :) + sender.sendMessage(ChatColor.RED + "An error occurred finding your player."); //lazy x2? ;) } else { - qPlayer.getQuestProgressFile().startQuest(quest); + qPlayer.getQuestProgressFile().cancelQuest(quest); } + } else { + sender.sendMessage(Messages.COMMAND_SUB_DOESNTEXIST.getMessage().replace("{sub}", args[2])); } return true; } @@ -326,7 +337,7 @@ public class CommandQuests implements CommandExecutor { sender.sendMessage(ChatColor.GRAY + "The following commands are available: "); sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests " + ChatColor.DARK_GRAY + ": show quests"); sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests c/category <categoryid> " + ChatColor.DARK_GRAY + ": open category by ID"); - sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests q/quest <questid> " + ChatColor.DARK_GRAY + ": start quest by ID"); + sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests q/quest <questid> <start/cancel>" + ChatColor.DARK_GRAY + ": start or cancel quest by ID"); sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.RED + "/quests a/admin " + ChatColor.DARK_GRAY + ": view help for admins"); sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "--------=[" + ChatColor.RED + " made with <3 by LMBishop " + ChatColor .GRAY.toString() + ChatColor.STRIKETHROUGH + "]=--------"); diff --git a/src/main/java/com/leonardobishop/quests/obj/Messages.java b/src/main/java/com/leonardobishop/quests/obj/Messages.java index 1d02e3ef..b3c9ceab 100644 --- a/src/main/java/com/leonardobishop/quests/obj/Messages.java +++ b/src/main/java/com/leonardobishop/quests/obj/Messages.java @@ -19,6 +19,7 @@ public enum Messages { QUEST_CATEGORY_PERMISSION("messages.quest-category-permission"), QUEST_CANCEL_NOTSTARTED("messages.quest-cancel-notstarted"), QUEST_UPDATER("messages.quest-updater"), + COMMAND_SUB_DOESNTEXIST("messages.command-sub-doesntexist"), COMMAND_QUEST_START_DOESNTEXIST("messages.command-quest-start-doesntexist"), COMMAND_QUEST_OPENCATEGORY_ADMIN_SUCCESS("messages.command-quest-opencategory-admin-success"), COMMAND_QUEST_OPENQUESTS_ADMIN_SUCCESS("messages.command-quest-openquests-admin-success"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 18283128..d21830e8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -190,6 +190,7 @@ messages: quest-category-quest-permission: "&7You do not have permission to start this quest since it is in a category you do not have permission to view." quest-cancel-notstarted: "&7You have not started this quest." quest-updater: "&cQuests > &7A new version &c{newver} &7was found on Spigot (your version: &c{oldver}&7). Please update me! <3 - Link: {link}" + command-sub-doesntexist: "&7The specified subcommand '&c{sub}' &7does not exist." command-quest-start-doesntexist: "&7The specified quest '&c{quest}&7' does not exist." command-category-open-disabled: "&7Categories are disabled." command-category-open-doesntexist: "&7The specified category '&c{category}&7' does not exist." |
