Skip to content

PlayerCommandEvent

Namespace Mc.Scripting.Events · Kind struct (ref)

public ref struct PlayerCommandEvent : IEvent

A player ran a command (without the leading slash). Cancel to suppress it; the command line may be rewritten.

Id 15
Key mc:player_command
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Player player no (readonly) The player.
Command Utf8String yes The command line without the slash.

Set e.Cancelled = true in a handler to cancel it; lower-priority handlers are skipped unless they subscribed with receiveCancelled: true.

Member Description
PlayerCommandEvent(Player player, Utf8String command) Creates the event (for firing it from a plugin; native code builds its own).
public PlayerCommandEvent(Player player, Utf8String command)

Creates the event (for firing it from a plugin; native code builds its own). Signature of API 1.0.

Parameters

Name Type Description
player Player
command Utf8String
Member Description
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
Utf8String Command { get; } The command line without the slash.
Player Player { get; } The player.
static ushort CatalogueId { get; } Catalogue id (stable ABI).
static bool IsCancellable { get; } Whether handlers can cancel the event.
static string Key { get; } Registry key of the event.
public bool Cancelled { get; set; }

Cancelling stops lower-priority handlers (unless they opt in) and the action itself.

public Utf8String Command { get; }

The command line without the slash. (mutable: use PlayerCommandEvent.SetCommand)

public Player Player { get; }

The player.

public static ushort CatalogueId { get; }

Catalogue id (stable ABI).

public static bool IsCancellable { get; }

Whether handlers can cancel the event.

public static string Key { get; }

Registry key of the event.

Member Description
void SetCommand(string value) Replaces PlayerCommandEvent.Command (copied into the per-tick event arena; the engine reads it back after dispatch).
public void SetCommand(string value)

Replaces PlayerCommandEvent.Command (copied into the per-tick event arena; the engine reads it back after dispatch).

Parameters

Name Type Description
value string

Command · IEvent · Player · Utf8String