-
Notifications
You must be signed in to change notification settings - Fork 5
Console and commands
KocproZ edited this page Jul 26, 2018
·
1 revision
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.
By default these commands are registered:
-
help [command]
- prints help text for given command -
list
- lists all available
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.