Added overload to get subcmds without a cmd object

This commit is contained in:
Norbi Peti 2016-11-18 20:13:39 +01:00
parent 8dfea2032f
commit 656e136b49

View file

@ -31,11 +31,22 @@ public class TBMCChatAPI {
* @return The subcommands * @return The subcommands
*/ */
public static String[] GetSubCommands(TBMCCommandBase command) { public static String[] GetSubCommands(TBMCCommandBase command) {
return GetSubCommands(command.GetCommandPath());
}
/**
* Returns messages formatted for Minecraft chat listing the subcommands of the command.
*
* @param command
* The command which we want the subcommands of
* @return The subcommands
*/
public static String[] GetSubCommands(String command) {
ArrayList<String> cmds = new ArrayList<String>(); ArrayList<String> cmds = new ArrayList<String>();
cmds.add("§6---- Subcommands ----"); cmds.add("§6---- Subcommands ----");
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) { for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) {
if (cmd.GetCommandPath().startsWith(command.GetCommandPath() + " ")) { if (cmd.GetCommandPath().startsWith(command + " ")) {
int ind = cmd.GetCommandPath().indexOf(' ', command.GetCommandPath().length() + 2); int ind = cmd.GetCommandPath().indexOf(' ', command.length() + 2);
if (ind >= 0) if (ind >= 0)
continue; continue;
cmds.add("/" + cmd.GetCommandPath()); cmds.add("/" + cmd.GetCommandPath());