PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
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
Permissible::addAttachment()

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 ( )
inherited

Calls event handlers registered for this event.

Exceptions

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 ( )
finalinherited

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 ( )
staticinherited

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 ( )
inherited

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
protectedinherited

Definition at line 38 of file Event.php.


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