PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
pocketmine\event\player\PlayerItemHeldEvent Class Reference
+ Inheritance diagram for pocketmine\event\player\PlayerItemHeldEvent:
+ Collaboration diagram for pocketmine\event\player\PlayerItemHeldEvent:

Public Member Functions

 __construct (Player $player, private Item $item, private int $hotbarSlot)
 
 call ()
 
 getEventName ()
 
 getItem ()
 
 getPlayer ()
 
 getSlot ()
 
 isCancelled ()
 

Static Public Member Functions

static hasHandlers ()
 

Protected Attributes

string $eventName = null
 
Player $player
 

Detailed Description

Called when a player's held item changes. This could be because they selected a different hotbar slot, or because the item in the selected hotbar slot was changed.

Definition at line 36 of file PlayerItemHeldEvent.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\event\player\PlayerItemHeldEvent::__construct ( Player $player,
private Item $item,
private int $hotbarSlot )

Definition at line 39 of file PlayerItemHeldEvent.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.

◆ getEventName()

pocketmine\event\Event::getEventName ( )
finalinherited

Definition at line 40 of file Event.php.

◆ getItem()

pocketmine\event\player\PlayerItemHeldEvent::getItem ( )

Returns the item in the slot that the player is trying to equip.

Definition at line 62 of file PlayerItemHeldEvent.php.

◆ getPlayer()

pocketmine\event\player\PlayerEvent::getPlayer ( )
inherited

Definition at line 35 of file PlayerEvent.php.

◆ getSlot()

pocketmine\event\player\PlayerItemHeldEvent::getSlot ( )

Returns the hotbar slot the player is attempting to hold.

NOTE: This event is called BEFORE the slot is equipped server-side. Setting the player's held item during this event will result in the old slot being changed, not this one.

To change the item in the slot that the player is attempting to hold, set the slot that this function reports.

Definition at line 55 of file PlayerItemHeldEvent.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.

Member Data Documentation

◆ $eventName

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

Definition at line 38 of file Event.php.

◆ $player

Player pocketmine\event\player\PlayerEvent::$player
protectedinherited

Definition at line 33 of file PlayerEvent.php.


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