CommandExecutor
This is a guide on the CommandExecutor interface.
What is CommandExecutor ?
CommandExecutor
is an interface used to execute your commands and to manage the completions of its arguments. It contains two methods which we will see in more details in the rest of this guide.
This interface is not the same as the one used by Bukkit !
The onCommand() method
This method is used to execute your command. It returns a boolean
to find out if your command has been correctly executed or not.
Indeed, onCommand()
method returns true
if your command has been correctly executed without user error. However, if user makes errors by using your command, it will returns false
. In this case, if you're using CommandUsage
, it will use the advanced command aid system to help the user by showing the right usages.
These parameters
Type | Parameter | Description |
|
| The command executed by a user (see here for more information) |
|
| The command issuer (see here for more information) |
|
| The name of the executed command (original name or aliases) |
|
| The arguments of the command |
Example
Let's see an example with a basic /test
command:
The onTabComplete() method
This method is used to send tab completions to a CommandSender
. It can be very useful to create your own completions when you're not using the automatic tab completor.
This method is useless if you're using the automatic tab completor because the system already supports all the possible completions.
These parameters
Type | Parameter | Description |
|
| The command a user wants to tab complete the arguments |
|
| The user who wants to tab complete the command arguments |
|
| The from of the command (original name or aliases) |
|
| The arguments of the command |
|
| The completions found for these arguments |
If this method returns a list, it will override the completions found by the automatic tab completer instead of adding them.
Last updated