The PlayerGameModeChangeBeforeEvent interface in @minecraft/server.
Interface in @minecraft/server
Extends PlayerGameModeChangeAfterEvent, CancellableEvent
import type { PlayerGameModeChangeBeforeEvent } from '@minecraft/server';Subscribe to it with world.beforeEvents.playerGameModeChange.
Example
Section titled “Example”import { world, type PlayerGameModeChangeBeforeEvent } from '@minecraft/server';
world.beforeEvents.playerGameModeChange.subscribe((event: PlayerGameModeChangeBeforeEvent) => { console.log('playerGameModeChange', event.player.name, event.fromGameMode, event.toGameMode);
// Uncomment to stop it from happening. // event.cancel = true;});import { world } from '@minecraft/server';
world.beforeEvents.playerGameModeChange.subscribe((event) => { console.log('playerGameModeChange', event.player.name, event.fromGameMode, event.toGameMode);
// Uncomment to stop it from happening. // event.cancel = true;});Used by
Section titled “Used by”WorldBeforeEvents.playerGameModeChange, PlayerGameModeChangeBeforeEventSignal.subscribe, PlayerGameModeChangeBeforeEventSignal.unsubscribe
Inherited
Section titled “Inherited”From PlayerGameModeChangeAfterEvent: player, fromGameMode, toGameMode
From CancellableEvent: cancel