public final class CommandsManager
extends java.lang.Object
Commands created.| Modifier and Type | Field and Description |
|---|---|
private static java.util.ArrayList<Command> |
commands |
| Constructor and Description |
|---|
CommandsManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
add(Command command)
Adds a
Command to the commands list. |
static java.lang.String |
executeCommand(java.lang.String commandAndParams)
Executes a
Command in the commands list. |
static Command |
findCommand(java.lang.String command)
Finds a
Command in the commands list. |
static java.util.ArrayList<Command> |
getAllCommands()
Gets the commands list.
|
static java.util.HashMap<java.lang.String,java.lang.String> |
parseFlags(java.lang.String[] params)
This method receives a String array of parameters which contain flags (which are formatted "flag:value") and will create a HashMap<String, String> which contains the flags as keys and their values.
|
static java.lang.String[] |
parseParams(java.lang.String params)
Will parse the parameters from an input String into a String array.
For example: "/test param1 param2" will return {"param1", "param2"}. |
static java.lang.String |
stringParams(java.lang.String[] params,
int start)
Receives a String array and combines all the indexes into one String object.
|
private static java.util.ArrayList<Command> commands
public static void add(Command command)
Command to the commands list. command - Command to add to the list.public static Command findCommand(java.lang.String command)
Command in the commands list.public static java.util.ArrayList<Command> getAllCommands()
public static java.lang.String executeCommand(java.lang.String commandAndParams)
throws InvalidCommandException
Command in the commands list.commandAndParams - The command in String form and any parameters to execute with.Command executed.InvalidCommandException - If the input String's length is 0 or if the command cannot be found.public static java.lang.String[] parseParams(java.lang.String params)
params - The input to parse.public static java.lang.String stringParams(java.lang.String[] params,
int start)
params - A String array of parameters.start - The index with which to start combining.public static java.util.HashMap<java.lang.String,java.lang.String> parseFlags(java.lang.String[] params)
params - String array of parameters where each place contains a flag.