Phpcraft
Public Attributes | Protected Member Functions | List of all members
Phpcraft\Plugin Class Reference
Inheritance diagram for Phpcraft\Plugin:
Inheritance graph
[legend]
Collaboration diagram for Phpcraft\Plugin:
Collaboration graph
[legend]

Public Attributes

 $name
 
 $event_handlers = []
 

Protected Member Functions

 registerCommand ($names, callable $function, ?string $required_permission=null)
 
 unregister ()
 

Member Function Documentation

◆ registerCommand()

Phpcraft\Plugin::registerCommand (   $names,
callable  $function,
?string  $required_permission = null 
)
protected

Registers a command.

Parameters
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$functionThe 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_permissionThe permission required to use this command or null if not applicable.
Returns
Plugin $this

◆ unregister()

Phpcraft\Plugin::unregister ( )
protected

Unregisters the plugin, including its event handlers and its commands. Make sure your plugin has no statements other than return; after this.

Returns
void

Member Data Documentation

◆ $event_handlers

array< array{function:Closure, priority:int}> Phpcraft\Plugin::$event_handlers = []

◆ $name

string Phpcraft\Plugin::$name

The name of the plugin.