Phpcraft
|
Public Attributes | |
$name | |
$event_handlers = [] | |
Protected Member Functions | |
registerCommand ($names, callable $function, ?string $required_permission=null) | |
unregister () | |
|
protected |
Registers a command.
string|array<string> | $names One or more names without the / prefix. So, if you want a "/gamemode" comand, you provide "gamemode", and if you want a "//wand" command, you provide "/wand". | |
callable | $function | The function called when the command is executed. The first argument will be the CommandSender but if type-hinted to be ClientConnection or Server it will be exclusive to players or the server, respectively. Further arguments determine the command's arguments, e.g. ->registerCommand("gamemode", function(ClientConnection &$con, int $gamemode){...}) would result in the player-exclusive command /gamemode <gamemode> where the gamemode argument only allows integers. |
string | null | $required_permission | The permission required to use this command or null if not applicable. |
|
protected |
Unregisters the plugin, including its event handlers and its commands. Make sure your plugin has no statements other than return;
after this.
array< array{function:Closure, priority:int}> Phpcraft\Plugin::$event_handlers = [] |
string Phpcraft\Plugin::$name |
The name of the plugin.