From 6140580fd23882cac56f0cb24711890ec8d2b2f0 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Thu, 10 Mar 2022 17:22:11 -0500 Subject: [PATCH] NEW tab completion for commands --- .../blackvein/quests/quests/Requirements.java | 7 + .../me/blackvein/quests/quests/Rewards.java | 7 + .../main/java/me/blackvein/quests/Quest.java | 3 + .../main/java/me/blackvein/quests/Quests.java | 16 +- .../quests/commands/QuestsSubCommand.java | 5 + .../commands/quest/QuestCommandHandler.java | 193 ++++++++++-------- .../questadmin/QuestadminCommandHandler.java | 60 ++---- .../subcommands/QuestadminFinishCommand.java | 19 ++ .../subcommands/QuestadminGiveCommand.java | 19 ++ .../QuestadminGivepointsCommand.java | 10 + .../QuestadminNextstageCommand.java | 19 ++ .../subcommands/QuestadminPointsCommand.java | 10 + .../subcommands/QuestadminQuitCommand.java | 19 ++ .../subcommands/QuestadminRemoveCommand.java | 19 ++ .../subcommands/QuestadminResetCommand.java | 10 + .../QuestadminSetstageCommand.java | 43 ++++ .../subcommands/QuestadminStatsCommand.java | 10 + .../QuestadminTakepointsCommand.java | 10 + .../commands/quests/QuestsCommandHandler.java | 46 ++--- .../quests/subcommands/QuestsQuitCommand.java | 18 ++ .../quests/subcommands/QuestsTakeCommand.java | 18 ++ .../quests/listeners/CommandManager.java | 22 +- .../quests/quests/BukkitRequirements.java | 16 ++ .../quests/quests/BukkitRewards.java | 17 ++ 24 files changed, 459 insertions(+), 157 deletions(-) diff --git a/api/src/main/java/me/blackvein/quests/quests/Requirements.java b/api/src/main/java/me/blackvein/quests/quests/Requirements.java index 141c955b9..f90b7b348 100644 --- a/api/src/main/java/me/blackvein/quests/quests/Requirements.java +++ b/api/src/main/java/me/blackvein/quests/quests/Requirements.java @@ -69,4 +69,11 @@ public interface Requirements { List getDetailsOverride(); void setDetailsOverride(final List detailsOverride); + + /** + * Check if quest has at least one requirement + * + * @return true if quest contains an requirement + */ + boolean hasRequirement(); } diff --git a/api/src/main/java/me/blackvein/quests/quests/Rewards.java b/api/src/main/java/me/blackvein/quests/quests/Rewards.java index bcc3d89cb..c8e2e05df 100644 --- a/api/src/main/java/me/blackvein/quests/quests/Rewards.java +++ b/api/src/main/java/me/blackvein/quests/quests/Rewards.java @@ -50,4 +50,11 @@ public interface Rewards { void setCustomRewards(final Map> customRewards); List getDetailsOverride(); void setDetailsOverride(final List detailsOverride); + + /** + * Check if quest has at least one reward + * + * @return true if quest contains an reward + */ + boolean hasReward(); } diff --git a/core/src/main/java/me/blackvein/quests/Quest.java b/core/src/main/java/me/blackvein/quests/Quest.java index 499218199..33828162d 100644 --- a/core/src/main/java/me/blackvein/quests/Quest.java +++ b/core/src/main/java/me/blackvein/quests/Quest.java @@ -311,6 +311,9 @@ public class Quest implements IQuest { } final IStage currentStage = quester.getCurrentStage(this); final IStage nextStage = getStage(stage); + if (currentStage == null || nextStage == null) { + return; + } if (player.isOnline()) { final QuesterPreChangeStageEvent preEvent = new QuesterPreChangeStageEvent((Quester) quester, this, currentStage, nextStage); diff --git a/core/src/main/java/me/blackvein/quests/Quests.java b/core/src/main/java/me/blackvein/quests/Quests.java index 4d49221de..14ebe8bc1 100644 --- a/core/src/main/java/me/blackvein/quests/Quests.java +++ b/core/src/main/java/me/blackvein/quests/Quests.java @@ -83,6 +83,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.command.CommandExecutor; +import org.bukkit.command.TabExecutor; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; @@ -150,7 +151,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { private Collection actions = new ConcurrentSkipListSet<>(); private Collection conditions = new ConcurrentSkipListSet<>(); private LinkedList questNpcIds = new LinkedList<>(); - private CommandExecutor cmdExecutor; + private TabExecutor cmdExecutor; private ConversationFactory conversationFactory; private ConversationFactory npcConversationFactory; private QuestFactory questFactory; @@ -230,13 +231,16 @@ public class Quests extends JavaPlugin implements QuestsAPI { // 8 - Setup commands if (getCommand("quests") != null) { - Objects.requireNonNull(getCommand("quests")).setExecutor(getCommandExecutor()); + Objects.requireNonNull(getCommand("quests")).setExecutor(getTabExecutor()); + Objects.requireNonNull(getCommand("quests")).setTabCompleter(getTabExecutor()); } if (getCommand("questadmin") != null) { - Objects.requireNonNull(getCommand("questadmin")).setExecutor(getCommandExecutor()); + Objects.requireNonNull(getCommand("questadmin")).setExecutor(getTabExecutor()); + Objects.requireNonNull(getCommand("questadmin")).setTabCompleter(getTabExecutor()); } if (getCommand("quest") != null) { - Objects.requireNonNull(getCommand("quest")).setExecutor(getCommandExecutor()); + Objects.requireNonNull(getCommand("quest")).setExecutor(getTabExecutor()); + Objects.requireNonNull(getCommand("quest")).setTabCompleter(getTabExecutor()); } // 9 - Build conversation factories @@ -530,6 +534,10 @@ public class Quests extends JavaPlugin implements QuestsAPI { return cmdExecutor; } + public TabExecutor getTabExecutor() { + return cmdExecutor; + } + public ConversationFactory getConversationFactory() { return conversationFactory; } diff --git a/core/src/main/java/me/blackvein/quests/commands/QuestsSubCommand.java b/core/src/main/java/me/blackvein/quests/commands/QuestsSubCommand.java index f1332a547..71bc26d53 100644 --- a/core/src/main/java/me/blackvein/quests/commands/QuestsSubCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/QuestsSubCommand.java @@ -19,6 +19,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -38,6 +39,10 @@ public abstract class QuestsSubCommand { public abstract void execute(CommandSender commandSender, String[] args); + public List tabComplete(CommandSender commandSender, String[] args) { + return Collections.emptyList(); + } + public static boolean assertNonPlayer(CommandSender commandSender) { if (!(commandSender instanceof Player)) { commandSender.sendMessage(ChatColor.YELLOW + Lang.get("consoleError")); diff --git a/core/src/main/java/me/blackvein/quests/commands/quest/QuestCommandHandler.java b/core/src/main/java/me/blackvein/quests/commands/quest/QuestCommandHandler.java index d1d864b82..da7d77929 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quest/QuestCommandHandler.java +++ b/core/src/main/java/me/blackvein/quests/commands/quest/QuestCommandHandler.java @@ -25,6 +25,10 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class QuestCommandHandler { private final Quests plugin; @@ -74,6 +78,19 @@ public class QuestCommandHandler { return true; } + public List suggest(final CommandSender cs, final String[] args) { + if (args.length != 1) { + return Collections.emptyList(); + } + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[0].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } + private void showQuestDetails(final CommandSender cs, final String[] args) { if (cs.hasPermission("quests.questinfo")) { StringBuilder name = new StringBuilder(); @@ -105,105 +122,107 @@ public class QuestCommandHandler { } cs.sendMessage(" "); if (plugin.getSettings().canShowQuestReqs()) { - cs.sendMessage(ChatColor.GOLD + Lang.get("requirements")); final Requirements reqs = q.getRequirements(); - if (!reqs.getPermissions().isEmpty()) { - for (final String perm : reqs.getPermissions()) { - if (plugin.getDependencies().getVaultPermission().has(player, perm)) { - cs.sendMessage(ChatColor.GREEN + Lang.get("permissionDisplay") + " " + perm); - } else { - cs.sendMessage(ChatColor.RED + Lang.get("permissionDisplay") + " " + perm); + if (reqs.hasRequirement()) { + cs.sendMessage(ChatColor.GOLD + Lang.get("requirements")); + if (!reqs.getPermissions().isEmpty()) { + for (final String perm : reqs.getPermissions()) { + if (plugin.getDependencies().getVaultPermission().has(player, perm)) { + cs.sendMessage(ChatColor.GREEN + Lang.get("permissionDisplay") + " " + perm); + } else { + cs.sendMessage(ChatColor.RED + Lang.get("permissionDisplay") + " " + perm); + } } } - } - if (reqs.getHeroesPrimaryClass() != null) { - if (plugin.getDependencies() - .testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId())) { - cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesPrimaryClass() - + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass")); - } else { - cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesPrimaryClass() - + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass")); - } - } - if (reqs.getHeroesSecondaryClass() != null) { - if (plugin.getDependencies() - .testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId())) { - cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesSecondaryClass() - + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass")); - } else { - cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesSecondaryClass() - + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass")); - } - } - if (!reqs.getMcmmoSkills().isEmpty()) { - for (final String skill : reqs.getMcmmoSkills()) { - final int level = plugin.getDependencies().getMcmmoSkillLevel(Quests - .getMcMMOSkill(skill), player.getName()); - final int req = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(skill)); - final String skillName = MiscUtil.getCapitalized(skill); - if (level >= req) { - cs.sendMessage(ChatColor.GREEN + skillName + " " + Lang.get("mcMMOLevel") + " " + req); + if (reqs.getHeroesPrimaryClass() != null) { + if (plugin.getDependencies() + .testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId())) { + cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesPrimaryClass() + + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass")); } else { - cs.sendMessage(ChatColor.RED + skillName + " " + Lang.get("mcMMOLevel") + " " + req); + cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesPrimaryClass() + + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass")); } } - } - if (reqs.getQuestPoints() != 0) { - if (quester.getQuestPoints() >= reqs.getQuestPoints()) { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getQuestPoints() + " " - + Lang.get("questPoints")); - } else { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getQuestPoints() + " " - + Lang.get("questPoints")); - } - } - if (reqs.getMoney() != 0) { - if (plugin.getDependencies().getVaultEconomy() != null && plugin.getDependencies() - .getVaultEconomy().getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " " - + (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy() - .currencyNamePlural() : plugin.getDependencies().getVaultEconomy() - .currencyNameSingular())); - } else { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " " - + (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy() - .currencyNamePlural() : plugin.getDependencies().getVaultEconomy() - .currencyNameSingular())); - } - } - if (!reqs.getItems().isEmpty()) { - for (final ItemStack is : reqs.getItems()) { - if (plugin.getQuester(player.getUniqueId()).hasItem(is)) { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + ItemUtil.getString(is)); + if (reqs.getHeroesSecondaryClass() != null) { + if (plugin.getDependencies() + .testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId())) { + cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesSecondaryClass() + + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass")); } else { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + ItemUtil.getString(is)); + cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesSecondaryClass() + + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass")); } } - } - if (!reqs.getNeededQuests().isEmpty()) { - for (final IQuest quest : reqs.getNeededQuests()) { - if (quester.getCompletedQuestsTemp().contains(quest)) { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " " - + ChatColor.ITALIC + quest.getName()); - } else { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + Lang.get("complete") + " " - + ChatColor.ITALIC + quest.getName()); + if (!reqs.getMcmmoSkills().isEmpty()) { + for (final String skill : reqs.getMcmmoSkills()) { + final int level = plugin.getDependencies().getMcmmoSkillLevel(Quests + .getMcMMOSkill(skill), player.getName()); + final int req = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(skill)); + final String skillName = MiscUtil.getCapitalized(skill); + if (level >= req) { + cs.sendMessage(ChatColor.GREEN + skillName + " " + Lang.get("mcMMOLevel") + " " + req); + } else { + cs.sendMessage(ChatColor.RED + skillName + " " + Lang.get("mcMMOLevel") + " " + req); + } } } - } - if (!reqs.getBlockQuests().isEmpty()) { - for (final IQuest quest : reqs.getBlockQuests()) { - if (quester.getCompletedQuestsTemp().contains(quest)) { - String msg = Lang.get("haveCompleted"); - msg = msg.replace("", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE - + quest.getName() + ChatColor.RED); - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + msg); + if (reqs.getQuestPoints() != 0) { + if (quester.getQuestPoints() >= reqs.getQuestPoints()) { + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getQuestPoints() + " " + + Lang.get("questPoints")); } else { - String msg = Lang.get("cannotComplete"); - msg = msg.replace("", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE - + quest.getName() + ChatColor.GREEN); - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + msg); + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getQuestPoints() + " " + + Lang.get("questPoints")); + } + } + if (reqs.getMoney() != 0) { + if (plugin.getDependencies().getVaultEconomy() != null && plugin.getDependencies() + .getVaultEconomy().getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) { + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " " + + (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy() + .currencyNamePlural() : plugin.getDependencies().getVaultEconomy() + .currencyNameSingular())); + } else { + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " " + + (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy() + .currencyNamePlural() : plugin.getDependencies().getVaultEconomy() + .currencyNameSingular())); + } + } + if (!reqs.getItems().isEmpty()) { + for (final ItemStack is : reqs.getItems()) { + if (plugin.getQuester(player.getUniqueId()).hasItem(is)) { + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + ItemUtil.getString(is)); + } else { + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + ItemUtil.getString(is)); + } + } + } + if (!reqs.getNeededQuests().isEmpty()) { + for (final IQuest quest : reqs.getNeededQuests()) { + if (quester.getCompletedQuestsTemp().contains(quest)) { + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " " + + ChatColor.ITALIC + quest.getName()); + } else { + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + Lang.get("complete") + " " + + ChatColor.ITALIC + quest.getName()); + } + } + } + if (!reqs.getBlockQuests().isEmpty()) { + for (final IQuest quest : reqs.getBlockQuests()) { + if (quester.getCompletedQuestsTemp().contains(quest)) { + String msg = Lang.get("haveCompleted"); + msg = msg.replace("", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE + + quest.getName() + ChatColor.RED); + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + msg); + } else { + String msg = Lang.get("cannotComplete"); + msg = msg.replace("", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE + + quest.getName() + ChatColor.GREEN); + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + msg); + } } } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java index e6a48be17..8f6f6902a 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java @@ -31,6 +31,9 @@ import me.blackvein.quests.util.Lang; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; @@ -71,48 +74,27 @@ public class QuestadminCommandHandler { } } cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownAdminCommand")); - /*if (args[0].equalsIgnoreCase("stats") || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_STATS"))) { - new QuestadminStatsCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("give") || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_GIVE"))) { - new QuestadminGiveCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_QUIT"))) { - new QuestadminQuitCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("points") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_POINTS"))) { - new QuestadminPointsCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("takepoints") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS"))) { - new QuestadminTakepointsCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("givepoints") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS"))) { - new QuestadminGivepointsCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("pointsall") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_POINTSALL"))) { - new QuestadminPointsallCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("finish") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_FINISH"))) { - new QuestadminFinishCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("nextstage") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE"))) { - new QuestadminNextstageCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("setstage") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_SETSTAGE"))) { - new QuestadminSetstageCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("reset") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_RESET"))) { - new QuestadminResetCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("remove") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_REMOVE"))) { - new QuestadminRemoveCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("reload") - || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_RELOAD"))) { - new QuestadminReloadCommand(plugin).execute(cs, args); - } else { - cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownAdminCommand")); - }*/ return true; } + public List suggest(final CommandSender cs, final String[] args) { + if (args.length == 1) { + final List results = new ArrayList<>(); + for (Map.Entry cmd : subCommands.entrySet()) { + if (cmd.getKey().startsWith(args[0]) || cmd.getValue().getNameI18N().startsWith(args[0])) { + results.add(cmd.getValue().getNameI18N()); + } + } + return results; + } + for (Map.Entry cmd : subCommands.entrySet()) { + if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) { + return cmd.getValue().tabComplete(cs, args); + } + } + return Collections.emptyList(); + } + private void printAdminHelp(final CommandSender cs) { if (!(cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin"))) { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java index fc8f5f283..a0a07019c 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java @@ -23,6 +23,9 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminFinishCommand extends QuestsSubCommand { @@ -99,4 +102,20 @@ public class QuestadminFinishCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } else if (args.length == 3) { + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java index c44a3a931..911d1d34c 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java @@ -23,6 +23,9 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminGiveCommand extends QuestsSubCommand { @@ -118,4 +121,20 @@ public class QuestadminGiveCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } else if (args.length == 3) { + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGivepointsCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGivepointsCommand.java index 46f713e3a..e1ffabdae 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGivepointsCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminGivepointsCommand.java @@ -22,6 +22,8 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminGivepointsCommand extends QuestsSubCommand { @@ -94,4 +96,12 @@ public class QuestadminGivepointsCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java index 6b049c199..63705b5e6 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java @@ -23,6 +23,9 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminNextstageCommand extends QuestsSubCommand { @@ -99,4 +102,20 @@ public class QuestadminNextstageCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } else if (args.length == 3) { + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminPointsCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminPointsCommand.java index 59a704c38..2fc910b8d 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminPointsCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminPointsCommand.java @@ -22,6 +22,8 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminPointsCommand extends QuestsSubCommand { @@ -94,4 +96,12 @@ public class QuestadminPointsCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java index 1fc51bcce..5292bb011 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java @@ -23,6 +23,9 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminQuitCommand extends QuestsSubCommand { @@ -94,4 +97,20 @@ public class QuestadminQuitCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } else if (args.length == 3) { + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java index 32079a918..928cbc5f4 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java @@ -22,6 +22,9 @@ import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminRemoveCommand extends QuestsSubCommand { @@ -91,4 +94,20 @@ public class QuestadminRemoveCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } else if (args.length == 3) { + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminResetCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminResetCommand.java index 1e04c9b3f..c704f4fa1 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminResetCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminResetCommand.java @@ -23,6 +23,8 @@ import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; +import java.util.Collections; +import java.util.List; import java.util.UUID; import java.util.concurrent.ConcurrentSkipListSet; @@ -103,4 +105,12 @@ public class QuestadminResetCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminSetstageCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminSetstageCommand.java index 233f59f8a..3ce2c1649 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminSetstageCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminSetstageCommand.java @@ -12,6 +12,7 @@ package me.blackvein.quests.commands.questadmin.subcommands; +import me.blackvein.quests.Quest; import me.blackvein.quests.Quests; import me.blackvein.quests.commands.QuestsSubCommand; import me.blackvein.quests.player.IQuester; @@ -22,6 +23,9 @@ import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminSetstageCommand extends QuestsSubCommand { @@ -91,6 +95,20 @@ public class QuestadminSetstageCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); return; } + if (!quester.getCurrentQuestsTemp().containsKey(quest)) { + String msg1 = Lang.get("questForceTake"); + msg1 = msg1.replace("", ChatColor.GREEN + quester.getLastKnownName() + ChatColor.GOLD); + msg1 = msg1.replace("", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD); + cs.sendMessage(ChatColor.GOLD + msg1); + if (quester.getPlayer() != null && quester.getPlayer().isOnline()) { + String msg2 = Lang.get("questForcedTake"); + msg2 = msg2.replace("", ChatColor.GREEN + quester.getLastKnownName() + ChatColor.GOLD); + msg2 = msg2.replace("", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD); + quester.sendMessage(ChatColor.GREEN + msg2); + } + quester.takeQuest(quest, true); + quester.saveData(); + } try { quest.setStage(quester, stage - 1); } catch (final IndexOutOfBoundsException e) { @@ -104,4 +122,29 @@ public class QuestadminSetstageCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } else if (args.length == 3) { + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } else if (args.length > 3) { + final Quest quest = plugin.getQuest(args[2]); + if (quest != null) { + final List results = new ArrayList<>(); + for (int i = 1; i <= quest.getStages().size(); i++) { + results.add(String.valueOf(i)); + } + return results; + } + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminStatsCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminStatsCommand.java index a6399554f..b04834aaa 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminStatsCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminStatsCommand.java @@ -22,6 +22,8 @@ import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -109,4 +111,12 @@ public class QuestadminStatsCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminTakepointsCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminTakepointsCommand.java index d47e39b88..711eb5cd5 100644 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminTakepointsCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminTakepointsCommand.java @@ -22,6 +22,8 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Collections; +import java.util.List; import java.util.UUID; public class QuestadminTakepointsCommand extends QuestsSubCommand { @@ -94,4 +96,12 @@ public class QuestadminTakepointsCommand extends QuestsSubCommand { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + return null; // Shows online players + } + return Collections.emptyList(); + } } 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 005882f12..5cb4471d3 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 @@ -29,6 +29,9 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; @@ -66,34 +69,27 @@ public class QuestsCommandHandler { } } cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownCommand")); - /*if (args[0].equalsIgnoreCase("list") || args[0].equalsIgnoreCase(Lang.get("COMMAND_LIST"))) { - new QuestsListCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("take") || args[0].equalsIgnoreCase(Lang.get("COMMAND_TAKE"))) { - new QuestsTakeCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUIT"))) { - new QuestsQuitCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("stats") || args[0].equalsIgnoreCase(Lang.get("COMMAND_STATS"))) { - new QuestsStatsCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("journal") || args[0].equalsIgnoreCase(Lang.get("COMMAND_JOURNAL"))) { - new QuestsJournalCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("top") || args[0].equalsIgnoreCase(Lang.get("COMMAND_TOP"))) { - new QuestsTopCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("editor") || args[0].equalsIgnoreCase(Lang.get("COMMAND_EDITOR"))) { - new QuestsEditorCommand(plugin).execute(cs, args); - } else if (args[0].startsWith("action") || args[0].startsWith("event") - || args[0].startsWith(Lang.get("COMMAND_EVENTS_EDITOR"))) { - new QuestsActionsCommand(plugin).execute(cs, args); - } else if (args[0].startsWith("condition") || args[0].startsWith(Lang.get("COMMAND_CONDITIONS_EDITOR"))) { - new QuestsConditionsCommand(plugin).execute(cs, args); - } else if (args[0].equalsIgnoreCase("info") || args[0].equalsIgnoreCase(Lang.get("COMMAND_INFO"))) { - new QuestsInfoCommand(plugin).execute(cs, args); - } else { - cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownCommand")); - return true; - }*/ return true; } + public List suggest(final CommandSender cs, final String[] args) { + if (args.length == 1) { + final List results = new ArrayList<>(); + for (Map.Entry cmd : subCommands.entrySet()) { + if (cmd.getKey().startsWith(args[0]) || cmd.getValue().getNameI18N().startsWith(args[0])) { + results.add(cmd.getValue().getNameI18N()); + } + } + return results; + } + for (Map.Entry cmd : subCommands.entrySet()) { + if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) { + return cmd.getValue().tabComplete(cs, args); + } + } + return Collections.emptyList(); + } + private void printHelp(final CommandSender cs) { if (!cs.hasPermission("quests.quests")) { cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java index ff8c1eeb9..a255e4715 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java @@ -21,6 +21,10 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class QuestsQuitCommand extends QuestsSubCommand { private final Quests plugin; @@ -86,4 +90,18 @@ public class QuestsQuitCommand extends QuestsSubCommand { Lang.send(player, ChatColor.RED + Lang.get(player, "noPermission")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java index 7f74846cc..69ed3691e 100644 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java +++ b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java @@ -21,6 +21,10 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class QuestsTakeCommand extends QuestsSubCommand { private final Quests plugin; @@ -86,4 +90,18 @@ public class QuestsTakeCommand extends QuestsSubCommand { Lang.send(player, ChatColor.YELLOW + Lang.get(player, "questTakeDisabled")); } } + + @Override + public List tabComplete(CommandSender commandSender, String[] args) { + if (args.length == 2) { + final List results = new ArrayList<>(); + for (final IQuest quest : plugin.getLoadedQuests()) { + if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) { + results.add(quest.getName()); + } + } + return results; + } + return Collections.emptyList(); + } } diff --git a/core/src/main/java/me/blackvein/quests/listeners/CommandManager.java b/core/src/main/java/me/blackvein/quests/listeners/CommandManager.java index 32d4d86ce..cb5662816 100644 --- a/core/src/main/java/me/blackvein/quests/listeners/CommandManager.java +++ b/core/src/main/java/me/blackvein/quests/listeners/CommandManager.java @@ -19,15 +19,17 @@ import me.blackvein.quests.commands.quests.QuestsCommandHandler; import me.blackvein.quests.util.Lang; import org.bukkit.ChatColor; import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.HashMap; +import java.util.List; import java.util.Map; -public class CommandManager implements CommandExecutor { +public class CommandManager implements TabExecutor { private final Quests plugin; private final Map commandSizes = new HashMap<>(); private final Map adminCommandSizes = new HashMap<>(); @@ -64,6 +66,22 @@ public class CommandManager implements CommandExecutor { } return false; } + + @Nullable + @Override + public List onTabComplete(@NotNull CommandSender cs, @NotNull Command cmd, + @NotNull String label, @NotNull String[] args) { + if (args.length > 0) { + if (cmd.getName().equalsIgnoreCase("quest")) { + return new QuestCommandHandler(plugin).suggest(cs, args); + } else if (cmd.getName().equalsIgnoreCase("quests")) { + return new QuestsCommandHandler(plugin).suggest(cs, args); + } else if (cmd.getName().equalsIgnoreCase("questadmin")) { + return new QuestadminCommandHandler(plugin).suggest(cs, args); + } + } + return null; + } private void init() { // [] - required diff --git a/core/src/main/java/me/blackvein/quests/quests/BukkitRequirements.java b/core/src/main/java/me/blackvein/quests/quests/BukkitRequirements.java index 4a0f92a93..cd4af63ea 100644 --- a/core/src/main/java/me/blackvein/quests/quests/BukkitRequirements.java +++ b/core/src/main/java/me/blackvein/quests/quests/BukkitRequirements.java @@ -112,4 +112,20 @@ public class BukkitRequirements implements Requirements { public void setDetailsOverride(final List detailsOverride) { this.detailsOverride = detailsOverride; } + + @Override + public boolean hasRequirement() { + if (money != 0) { return true; } + if (questPoints != 0) { return true; } + if (!items.isEmpty()) { return true; } + if (!removeItems.isEmpty()) { return true; } + if (!neededQuests.isEmpty()) { return true; } + if (!blockQuests.isEmpty()) { return true; } + if (!permissions.isEmpty()) { return true; } + if (!mcmmoSkills.isEmpty()) { return true; } + if (!mcmmoAmounts.isEmpty()) { return true; } + if (heroesPrimaryClass != null) { return true; } + if (heroesSecondaryClass != null) { return true; } + return !customRequirements.isEmpty(); + } } diff --git a/core/src/main/java/me/blackvein/quests/quests/BukkitRewards.java b/core/src/main/java/me/blackvein/quests/quests/BukkitRewards.java index e56ef6cab..b5b24a471 100644 --- a/core/src/main/java/me/blackvein/quests/quests/BukkitRewards.java +++ b/core/src/main/java/me/blackvein/quests/quests/BukkitRewards.java @@ -133,4 +133,21 @@ public class BukkitRewards implements Rewards { public void setDetailsOverride(final List detailsOverride) { this.detailsOverride = detailsOverride; } + + @Override + public boolean hasReward() { + if (money != 0) { return true; } + if (questPoints != 0) { return true; } + if (exp != 0) { return true; } + if (!commands.isEmpty()) { return true; } + if (!permissions.isEmpty()) { return true; } + if (!items.isEmpty()) { return true; } + if (!mcmmoSkills.isEmpty()) { return true; } + if (!mcmmoAmounts.isEmpty()) { return true; } + if (!heroesClasses.isEmpty()) { return true; } + if (!heroesAmounts.isEmpty()) { return true; } + if (partiesExperience != 0) { return true; } + if (!phatLoots.isEmpty()) { return true; } + return !customRewards.isEmpty(); + } }