Skip to main content
Player events are fired when players perform actions or undergo state changes. All player events extend the PlayerEvent base class.

PlayerEvent Base Class

All player events inherit from this class:
getPlayer()
Player
Returns the player involved in the event

Connection Events

Cancellable: YesCalled before a player is authenticated. Use this for custom authentication or IP bans.
Methods:
  • getPlayerInfo() - Returns player information
  • getIp() - Returns player’s IP address
  • getPort() - Returns connection port
  • setKickFlag(int $flag, Translatable|string $reason) - Kicks the player with a reason
Cancellable: YesCalled when a player logs in, after authentication but before they spawn.
Methods:
  • getPlayer() - Returns the player
  • setKickMessage(Translatable|string $message) - Sets kick message
  • getKickMessage() - Gets kick message
Cancellable: NoCalled when a player spawns in the world after logging in.
Methods:
  • getJoinMessage() - Returns the join message
  • setJoinMessage(Translatable|string $message) - Sets the join message
Cancellable: NoCalled when a player disconnects from the server.
Methods:
  • getQuitMessage() - Returns the quit message
  • setQuitMessage(Translatable|string $message) - Sets the quit message
  • getDisconnectReason() - Returns the disconnect reason
Cancellable: YesCalled when a player is kicked from the server.
Methods:
  • getDisconnectReason() - Returns the kick reason
  • getQuitMessage() - Returns the quit message
  • setQuitMessage(Translatable|string $message) - Sets the quit message
  • getDisconnectScreenMessage() - Returns message shown to kicked player

Movement Events

Cancellable: YesCalled when a player moves. Warning: This event is called very frequently!
Methods:
  • getFrom() - Returns the location the player is moving from
  • getTo() - Returns the location the player is moving to
  • setTo(Location $to) - Changes the destination location
Cancellable: NoCalled when a player jumps.
Cancellable: YesCalled when a player toggles flight mode.
Methods:
  • isFlying() - Returns whether the player is starting to fly
Cancellable: YesCalled when a player starts or stops sneaking.Methods:
  • isSneaking() - Returns whether the player is starting to sneak
Cancellable: YesCalled when a player starts or stops sprinting.Methods:
  • isSprinting() - Returns whether the player is starting to sprint
Cancellable: YesCalled when a player starts or stops gliding with elytra.Methods:
  • isGliding() - Returns whether the player is starting to glide
Cancellable: YesCalled when a player starts or stops swimming.Methods:
  • isSwimming() - Returns whether the player is starting to swim

Interaction Events

Cancellable: YesCalled when a player interacts with a block (left or right click).
Constants:
  • LEFT_CLICK_BLOCK (0) - Player left-clicked
  • RIGHT_CLICK_BLOCK (1) - Player right-clicked
Methods:
  • getAction() - Returns the action type
  • getItem() - Returns the item in hand
  • getBlock() - Returns the block that was touched
  • getTouchVector() - Returns the exact position touched
  • getFace() - Returns the block face that was touched
  • useItem() - Returns whether the item may react
  • setUseItem(bool $use) - Sets whether the item may react
  • useBlock() - Returns whether the block may react
  • setUseBlock(bool $use) - Sets whether the block may react
Cancellable: YesCalled when a player uses an item (right-clicks while holding it).
Methods:
  • getItem() - Returns the item being used
  • getDirectionVector() - Returns the direction the player is facing
Cancellable: YesCalled when a player changes their held item slot.
Methods:
  • getItem() - Returns the item being held
  • getSlot() - Returns the hotbar slot number (0-8)
Cancellable: YesCalled when a player finishes consuming an item (eating food, drinking potions).
Methods:
  • getItem() - Returns the item being consumed
Cancellable: YesCalled when a player drops an item.
Methods:
  • getItem() - Returns the dropped item entity
Cancellable: YesCalled when a player interacts with an entity.
Methods:
  • getEntity() - Returns the entity that was interacted with
  • getTouchVector() - Returns the touch position

Combat Events

Cancellable: NoCalled when a player dies.
Methods:
  • getDeathMessage() - Returns the death message
  • setDeathMessage(Translatable|string $message) - Sets the death message
  • getDrops() - Returns array of dropped items
  • setDrops(array $drops) - Sets the dropped items
  • getXpDropAmount() - Returns XP to drop
  • setXpDropAmount(int $amount) - Sets XP to drop
Cancellable: NoCalled when a player respawns after death.
Methods:
  • getRespawnPosition() - Returns the respawn position
  • setRespawnPosition(Position $position) - Sets the respawn position

Communication Events

Cancellable: YesCalled when a player sends a chat message.
Methods:
  • getMessage() - Returns the chat message
  • setMessage(string $message) - Sets the chat message
  • getRecipients() - Returns array of CommandSenders who will receive the message
  • setRecipients(array $recipients) - Sets the message recipients
  • getFormatter() - Returns the chat formatter
  • setFormatter(ChatFormatter $formatter) - Sets the chat formatter
Cancellable: YesCalled when a player uses an emote.Methods:
  • getEmoteId() - Returns the emote ID

Game State Events

Cancellable: YesCalled when a player’s game mode changes.
Methods:
  • getNewGameMode() - Returns the new GameMode
Cancellable: YesCalled when a player’s experience changes.Methods:
  • getExpDifference() - Returns the XP change amount
  • setExpDifference(int|float $amount) - Sets the XP change amount
  • getOldProgress() - Returns old progress to next level
  • getOldLevel() - Returns old XP level
Cancellable: YesCalled when a player’s food exhaustion increases.Methods:
  • getAmount() - Returns exhaustion amount
  • setAmount(float $amount) - Sets exhaustion amount
  • getCause() - Returns the exhaustion cause

Complete Event List

Other player events not detailed above:
  • PlayerBedEnterEvent - Player enters a bed
  • PlayerBedLeaveEvent - Player leaves a bed
  • PlayerBlockPickEvent - Player picks a block (middle-click)
  • PlayerBucketEmptyEvent - Player empties a bucket
  • PlayerBucketFillEvent - Player fills a bucket
  • PlayerChangeSkinEvent - Player changes their skin
  • PlayerCreationEvent - Before player object is created
  • PlayerDataSaveEvent - Before player data is saved
  • PlayerDisplayNameChangeEvent - Player’s display name changes
  • PlayerDuplicateLoginEvent - Player tries to login while already online
  • PlayerEditBookEvent - Player edits a book
  • PlayerEnchantingOptionsRequestEvent - Player opens enchanting table
  • PlayerEntityPickEvent - Player picks an entity (middle-click)
  • PlayerItemEnchantEvent - Player enchants an item
  • PlayerMissSwingEvent - Player swings at air
  • PlayerPostChunkSendEvent - After chunk is sent to player
  • PlayerResourcePackOfferEvent - Server offers resource pack to player
  • PlayerRespawnAnchorUseEvent - Player uses a respawn anchor
  • PlayerTransferEvent - Player is transferred to another server
  • PlayerViewDistanceChangeEvent - Player’s view distance changes