From 2ebadbe5d413573c909eb02ade01d59d4624352e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 29 Oct 2016 22:10:00 +0200 Subject: [PATCH] Moved GetSubCommands --- .../java/buttondevteam/lib/chat/TBMCChatAPI.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index e5571df..c1804d9 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -1,6 +1,7 @@ package buttondevteam.lib.chat; import java.lang.reflect.Modifier; +import java.util.ArrayList; import java.util.HashMap; import java.util.Set; @@ -20,6 +21,20 @@ public class TBMCChatAPI { return commands; } + public static String[] GetSubCommands(TBMCCommandBase 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 (ind >= 0) + continue; + cmds.add(cmd.GetCommandPath().replace('/', ' ')); + } + } + return cmds.toArray(new String[cmds.size()]); + } + /** *

* This method adds a plugin's commands to help and sets their executor.