Skip to content
BasaltSoftware
Bedrock 1.26.60

Site colour

Discord
Esc

    ↑↓ moveEnter openEsc close

    Keyboard shortcuts
    Ctrl K
    Search the whole site, from any page
    /
    Jump to the sidebar search, or search the whole site where there isn't one
    Enter
    Open the top search result
    Esc
    Clear the search, or close this panel
    ?
    Show these shortcuts
    Before events

    PlayerCommandBeforeEvent

    Interface in @minecraft/server

    Extends CancellableEvent

    Basalt’s own: a command a player typed, before it runs.

    import type { PlayerCommandBeforeEvent } from '@minecraft/server';

    Subscribe to it with server.beforeEvents.playerCommand.

    import { server, type PlayerCommandBeforeEvent } from '@minecraft/server';
    server.beforeEvents.playerCommand.subscribe((event: PlayerCommandBeforeEvent) => {
    console.log('playerCommand', event.player.name, event.command);
    // Uncomment to stop it from happening.
    // event.cancel = true;
    });
    import { server } from '@minecraft/server';
    server.beforeEvents.playerCommand.subscribe((event) => {
    console.log('playerCommand', event.player.name, event.command);
    // Uncomment to stop it from happening.
    // event.cancel = true;
    });

    read-only

    readonly player: Player;
    Types
    command: string;

    The command without its slash, which handlers may change.

    ServerBeforeEvents.playerCommand

    From CancellableEvent: cancel