From 656e136b49410d59a0a47f89aefded473b4d74e1 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 18 Nov 2016 20:13:39 +0100 Subject: [PATCH] Added overload to get subcmds without a cmd object --- .../java/buttondevteam/lib/chat/TBMCChatAPI.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 4d58544..82b3e65 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -31,11 +31,22 @@ public class TBMCChatAPI { * @return The subcommands */ 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 cmds = new ArrayList(); cmds.add("ยง6---- Subcommands ----"); for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) { - if (cmd.GetCommandPath().startsWith(command.GetCommandPath() + " ")) { - int ind = cmd.GetCommandPath().indexOf(' ', command.GetCommandPath().length() + 2); + if (cmd.GetCommandPath().startsWith(command + " ")) { + int ind = cmd.GetCommandPath().indexOf(' ', command.length() + 2); if (ind >= 0) continue; cmds.add("/" + cmd.GetCommandPath());