|
Phpcraft
|
Public Member Functions | |
| __construct (string $folder, string $name) | |
| fire (Event $event) | |
Public Attributes | |
| $name | |
| $event_handlers = [] | |
Protected Member Functions | |
| on (Closure $function, int $priority=Event::PRIORITY_NORMAL) | |
| registerCommand ($names, callable $function, ?string $required_permission=null) | |
| unregister () | |
| Phpcraft\Plugin::__construct | ( | string | $folder, |
| string | $name | ||
| ) |
Don't call this unless you know what you're doing.
| string | $folder | The path of the folder the plugin was loaded from. |
| string | $name | The name of the plugin. |
| Phpcraft\Plugin::fire | ( | Event | $event | ) |
Fires the event handler for the given event with its data as parameter.
| Event | $event |
|
protected |
Defines a function to be called to handle the given event.
| Closure | $function | The function. The first parameter should explicitly declare its type to be a decendant of Event. |
| int | $priority | The priority of the event handler. The higher the priority, the earlier it will be executed. Use a high value if you plan to cancel the event. |
@noinspection PhpDeprecationInspection
|
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.
1.8.16