The PlayerLeaveBeforeEvent interface in @minecraft/server.
Interface in @minecraft/server
import type { PlayerLeaveBeforeEvent } from '@minecraft/server';Subscribe to it with world.beforeEvents.playerLeave.
Example
Section titled “Example”import { world, type PlayerLeaveBeforeEvent } from '@minecraft/server';
world.beforeEvents.playerLeave.subscribe((event: PlayerLeaveBeforeEvent) => { console.log('playerLeave', event.player.name);});import { world } from '@minecraft/server';
world.beforeEvents.playerLeave.subscribe((event) => { console.log('playerLeave', event.player.name);});Properties
Section titled “Properties”player
Section titled “player”read-only
readonly player: Player;The player leaving; they’re already gone from the world’s list.
Types
Used by
Section titled “Used by”WorldBeforeEvents.playerLeave, PlayerLeaveBeforeEventSignal.subscribe, PlayerLeaveBeforeEventSignal.unsubscribe