Moved GetSubCommands

This commit is contained in:
Norbi Peti 2016-10-29 22:10:00 +02:00
parent 981b2e70db
commit 2ebadbe5d4

View file

@ -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<String> cmds = new ArrayList<String>();
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()]);
}
/**
* <p>
* This method adds a plugin's commands to help and sets their executor.