PocketMine-MP 5.15.1 git-fb9a74e8799c71ed8292cfa53abe7a4c9204629d
pocketmine\event\server\CommandEvent Class Reference
+ Inheritance diagram for pocketmine\event\server\CommandEvent:
+ Collaboration diagram for pocketmine\event\server\CommandEvent:

Public Member Functions

 __construct (protected CommandSender $sender, protected string $command)
 call ()
 getCommand ()
 getEventName ()
 getSender ()
 isCancelled ()
 setCommand (string $command)

Static Public Member Functions

static hasHandlers ()

Protected Attributes

string $eventName = null

Detailed Description

Called when any CommandSender runs a command, before it is parsed.

This can be used for logging commands, or preprocessing the command string to add custom features (e.g. selectors).

WARNING: DO NOT use this to block commands. Many commands have aliases. For example, /version can also be invoked using /ver or /about. To prevent command senders from using certain commands, deny them permission to use the commands you don't want them to have access to.

See also

The message DOES NOT begin with a slash.

Definition at line 44 of file CommandEvent.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\event\server\CommandEvent::__construct ( protected CommandSender  $sender,
protected string  $command 

Definition at line 47 of file CommandEvent.php.

Member Function Documentation

◆ call()

pocketmine\event\Event::call ( )

Calls event handlers registered for this event.


RuntimeException if event call recursion reaches the max depth limit

Definition at line 49 of file Event.php.

◆ getCommand()

pocketmine\event\server\CommandEvent::getCommand ( )

Definition at line 56 of file CommandEvent.php.

◆ getEventName()

pocketmine\event\Event::getEventName ( )

Definition at line 40 of file Event.php.

◆ getSender()

pocketmine\event\server\CommandEvent::getSender ( )

Definition at line 52 of file CommandEvent.php.

◆ hasHandlers()

static pocketmine\event\Event::hasHandlers ( )

Returns whether the current class context has any registered global handlers. This can be used in hot code paths to avoid unnecessary event object creation.

Usage: SomeEventClass::hasHandlers()

Definition at line 77 of file Event.php.

◆ isCancelled()

pocketmine\event\Cancellable::isCancelled ( )

Returns whether this instance of the event is currently cancelled.

If it is cancelled, only downstream handlers that declare @handleCancelled will be called with this event.

◆ setCommand()

pocketmine\event\server\CommandEvent::setCommand ( string  $command)

Definition at line 60 of file CommandEvent.php.

Member Data Documentation

◆ $eventName

string pocketmine\event\Event::$eventName = null

Definition at line 38 of file Event.php.

The documentation for this class was generated from the following file: