public abstract class Command
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.awt.Color |
outputColor |
protected java.lang.String |
outputMessage |
| Constructor and Description |
|---|
Command()
Creates a new
Command object and adds it to the CommandsManager list. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
check(java.lang.String[] params)
The method that checks the validity of a parameters String array for this command.
You should never really have to explicitly call this method. |
java.lang.String |
checkAndExecute(java.lang.String[] params)
This method will check the validity of the parameters and execute it if the check is successful.
|
protected abstract void |
execute(java.lang.String[] params)
The execute code.
You should never really have to explicitly call this method. |
abstract java.lang.String |
getCommand()
Gets this command as a String.
|
abstract java.lang.String |
getHelpMessage()
Gets this command's help message.
|
abstract int |
getMaxParams()
Gets the maximum number of parameters this command can be used with.
|
abstract int |
getMinParams()
Gets the minimum number of parameters this command can be used with.
|
java.awt.Color |
getOutputColor()
Gets the color that this command's output text should be printed with.
|
abstract java.lang.String |
getUsage()
Gets the proper usage of this command.
|
protected void |
missingParameters(java.lang.String[] params)
This method gets called if the check method finds that the parameter array provided contains too little parameters.
|
protected void |
tooManyParameters(java.lang.String[] params)
This method gets called if the check method finds that the parameter array provided contains too many parameters.
|
java.lang.String |
toString()
Returns a String containing information about this command using the following format:
[This command as a String]: [This command's help message or "<no help message specified>" if none specified], Usage: [This command's usage or "<none specified>" if none specified] |
protected java.lang.String outputMessage
protected java.awt.Color outputColor
public Command()
Command object and adds it to the CommandsManager list.public abstract java.lang.String getCommand()
public abstract java.lang.String getHelpMessage()
public abstract java.lang.String getUsage()
public abstract int getMaxParams()
public abstract int getMinParams()
public java.awt.Color getOutputColor()
For example, suppose the command's output text indicates that some error has occurred, the color returned would be red.
This color doesn't matter unless this command's output is being printed with a colored text compatible handler.
public java.lang.String checkAndExecute(java.lang.String[] params)
params - A String array of the parameters you'd like to execute this command with.protected boolean check(java.lang.String[] params)
checkAndExecute(String[]) instead.
The default check method simply checks if the length of the String array of parameters falls within the bounds of getMinParams() and getMaxParams() of this command.
params - A String array of parameters.protected abstract void execute(java.lang.String[] params)
checkAndExecute(String[]) instead.
Simply put whatever code you'd like to be run in here, and when this command is executed the code will be run.
params - A String array of parameters.protected void missingParameters(java.lang.String[] params)
By default it sets this command's output message to "Missing parameters!" and this command's output color to red.
params - A String array of parameters.protected void tooManyParameters(java.lang.String[] params)
By default it sets this command's output message to "Too many parameters!" and this command's output color to red.
params - A String array of parameters.public java.lang.String toString()
toString in class java.lang.Object