Console and commands - WarpOrganization/warp GitHub Wiki
Execution
Writing anything in console and pressing enter sends ConsoleInputEvent.
If the text starts with /
it is passed to ConsoleService to be parsed and executed.
If not, it is passed to ClientConsoleService
or ServerConsoleService where it ise then sent to server/clients through the use of ChatMessageEvent.
Default commands
By default these commands are registered:
help [command]
- prints help text for given commandlist
- lists all available
Writing own commands
There are two ways to write a command:
- SimpleCommand, where you pass
command
(word that triggers execution),helpText
(text that appears when help command is called), andusageText
(text that you can print if command was used wrong) in the constructor. Then you callsetExecutor
to pass a lambda to be executed. From inside the lambda you have access to String[] containing arguments. - By creating own class extending abstract class Command
Remember to callregisterCommand
on ConsoleService instance.