From 1cd9f87f1df61ca1ec8d3e987ce8ae87d9b5787b Mon Sep 17 00:00:00 2001 From: Benford Date: Wed, 23 Mar 2016 20:30:00 -0400 Subject: [PATCH] Updates - Updated tabbing for rpg commands - Updated the help command to show rpg commands --- .../command/BendingTabComplete.java | 62 +++++++++++++++---- .../projectkorra/command/HelpCommand.java | 44 ++++++++++--- 2 files changed, 84 insertions(+), 22 deletions(-) diff --git a/src/com/projectkorra/projectkorra/command/BendingTabComplete.java b/src/com/projectkorra/projectkorra/command/BendingTabComplete.java index 1cbc2921..031bbcac 100644 --- a/src/com/projectkorra/projectkorra/command/BendingTabComplete.java +++ b/src/com/projectkorra/projectkorra/command/BendingTabComplete.java @@ -6,6 +6,7 @@ import com.projectkorra.projectkorra.Element.SubElement; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.object.Preset; +import com.projectkorra.rpg.commands.RPGCommand; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -251,19 +252,54 @@ public class BendingTabComplete implements TabCompleter { l.add(p.getName()); } return getPossibleCompletionsForGivenArgs(args, l); - } else if (GeneralMethods.hasRPG() && (args[0].equalsIgnoreCase("avatar") || args[0].equalsIgnoreCase("av") || args[0].equalsIgnoreCase("avy"))) { - if (!sender.hasPermission("bending.command.avatar") || args.length > 2) return new ArrayList(); - List l = new ArrayList(); - for (Player p : Bukkit.getOnlinePlayers()) { - l.add(p.getName()); - } - return getPossibleCompletionsForGivenArgs(args, l); - } else if (GeneralMethods.hasRPG() && (args[0].equalsIgnoreCase("worldevent") || args[0].equalsIgnoreCase("event") || args[0].equalsIgnoreCase("we") || args[0].equalsIgnoreCase("worlde"))) { - if (!sender.hasPermission("bending.command.worldevent") || args.length > 3) return new ArrayList(); - if (args.length == 2) { - return getPossibleCompletionsForGivenArgs(args, Arrays.asList(new String[] {"current", "help", "start"})); - } else if (args[1].equalsIgnoreCase("start")) { - return getPossibleCompletionsForGivenArgs(args, Arrays.asList(new String[] {"FullMoon", "LunarEclipse", "SolarEclipse", "SozinsComet"})); + } else if (GeneralMethods.hasRPG()) { + if (args[0].equalsIgnoreCase("rpg")) { + if (sender.hasPermission("bending.command.rpg") && args.length <= 4) { + if (args.length == 2) { + List l = new ArrayList<>(); + l.addAll(RPGCommand.instances.keySet()); + Collections.sort(l); + return getPossibleCompletionsForGivenArgs(args, l); + } else if (args.length == 3) { + List l = new ArrayList<>(); + if (Arrays.asList(RPGCommand.instances.get("avatar").getAliases()).contains(args[1].toLowerCase()) && sender.hasPermission("bending.command.rpg.avatar")) { + for (Player p : Bukkit.getOnlinePlayers()) { + l.add(p.getName()); + } + } else if (Arrays.asList(RPGCommand.instances.get("worldevent").getAliases()).contains(args[1].toLowerCase()) && sender.hasPermission("bending.command.rpg.worldevent")) { + l.add("start"); + l.add("end"); + l.add("help"); + l.add("skip"); + l.add("current"); + } else if (Arrays.asList(RPGCommand.instances.get("help").getAliases()).contains(args[1].toLowerCase()) && sender.hasPermission("bending.command.rpg.help")) { + l.add("lunareclipse"); + l.add("solareclipse"); + l.add("sozinscomet"); + l.add("fullmoon"); + for (String rpg : RPGCommand.instances.keySet()) { + if (!rpg.equalsIgnoreCase("help")) { + l.add(rpg); + } + } + } + Collections.sort(l); + return getPossibleCompletionsForGivenArgs(args, l); + } else if (args.length == 4) { + List l = new ArrayList<>(); + String[] start = {"start", "st", "strt", "begin"}; + if (Arrays.asList(RPGCommand.instances.get("worldevent").getAliases()).contains(args[1].toLowerCase()) && sender.hasPermission("bending.command.rpg.worldevent")) { + if (Arrays.asList(start).contains(args[2].toLowerCase())) { + l.add("lunareclipse"); + l.add("solareclipse"); + l.add("sozinscomet"); + l.add("fullmoon"); + } + } + Collections.sort(l); + return getPossibleCompletionsForGivenArgs(args, l); + } + } } } diff --git a/src/com/projectkorra/projectkorra/command/HelpCommand.java b/src/com/projectkorra/projectkorra/command/HelpCommand.java index ae8f0127..2b2663b3 100644 --- a/src/com/projectkorra/projectkorra/command/HelpCommand.java +++ b/src/com/projectkorra/projectkorra/command/HelpCommand.java @@ -1,19 +1,21 @@ package com.projectkorra.projectkorra.command; +import com.projectkorra.projectkorra.Element; +import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ability.ComboAbility; +import com.projectkorra.projectkorra.ability.CoreAbility; +import com.projectkorra.projectkorra.ability.util.ComboManager; +import com.projectkorra.projectkorra.configuration.ConfigManager; +import com.projectkorra.rpg.commands.RPGCommand; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - -import com.projectkorra.projectkorra.Element; -import com.projectkorra.projectkorra.ability.ComboAbility; -import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.util.ComboManager; -import com.projectkorra.projectkorra.configuration.ConfigManager; - /** * Executor for /bending help. Extends {@link PKCommand}. */ @@ -58,6 +60,18 @@ public class HelpCommand extends PKCommand { strings.add(command.getProperUse()); } } + if (GeneralMethods.hasItems()) { + //items commands being added + } + if (GeneralMethods.hasRPG()) { + for (RPGCommand command : RPGCommand.instances.values()) { + if (sender.hasPermission("bending.command.rpg." + command.getName())) + strings.add(command.getProperUse()); + } + } + if (GeneralMethods.hasSpirits()) { + //spirits commands being added (if needed) + } Collections.sort(strings); Collections.reverse(strings); strings.add(instances.get("help").getProperUse()); @@ -74,6 +88,18 @@ public class HelpCommand extends PKCommand { for (PKCommand command : instances.values()) { strings.add(command.getProperUse()); } + if (GeneralMethods.hasItems()) { + //items commands being added + } + if (GeneralMethods.hasRPG()) { + for (RPGCommand command : RPGCommand.instances.values()) { + if (sender.hasPermission("bending.command.rpg." + command.getName())) + strings.add(command.getProperUse()); + } + } + if (GeneralMethods.hasSpirits()) { + //spirits commands being added (if needed) + } for (String s : getPage(strings, ChatColor.GOLD + "Commands: <" + required + "> [" + optional + "]", Integer.valueOf(arg), true)) { sender.sendMessage(ChatColor.YELLOW + s); }