Documentation

PlayerItemHeldEvent extends PlayerEvent
in package
implements Cancellable Uses CancellableTrait

Interfaces, Classes, Traits and Enums

Cancellable
This interface is implemented by an Event subclass if and only if it can be cancelled.

Table of Contents

MAX_EVENT_CALL_DEPTH  = 50
$eventName  : string|null
$player  : Player
$eventCallDepth  : int
$hotbarSlot  : int
$isCancelled  : bool
$item  : Item
__construct()  : mixed
call()  : void
Calls event handlers registered for this event.
cancel()  : void
getEventName()  : string
getItem()  : Item
Returns the item in the slot that the player is trying to equip.
getPlayer()  : Player
getSlot()  : int
Returns the hotbar slot the player is attempting to hold.
isCancelled()  : bool
uncancel()  : void

Constants

MAX_EVENT_CALL_DEPTH

private mixed MAX_EVENT_CALL_DEPTH = 50

Properties

$eventName

protected string|null $eventName = null

$eventCallDepth

private static int $eventCallDepth = 1

Methods

call()

Calls event handlers registered for this event.

public call() : void
Tags
throws
RuntimeException

if event call recursion reaches the max depth limit

Return values
void

getEventName()

public final getEventName() : string
Return values
string

getSlot()

Returns the hotbar slot the player is attempting to hold.

public getSlot() : int

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.

Return values
int

Search results