PlayerCommandEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct PlayerCommandEvent : IEventA 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.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
PlayerCommandEvent(Player player, Utf8String command) |
Creates the event (for firing it from a plugin; native code builds its own). |
Constructor
Section titled “Constructor”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 |
Properties
Section titled “Properties”| 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. |
Cancelled
Section titled “Cancelled”public bool Cancelled { get; set; }Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
Command
Section titled “Command”public Utf8String Command { get; }The command line without the slash. (mutable: use PlayerCommandEvent.SetCommand)
Player
Section titled “Player”public Player Player { get; }The player.
CatalogueId
Section titled “CatalogueId”public static ushort CatalogueId { get; }Catalogue id (stable ABI).
IsCancellable
Section titled “IsCancellable”public static bool IsCancellable { get; }Whether handlers can cancel the event.
public static string Key { get; }Registry key of the event.
Methods
Section titled “Methods”| Member | Description |
|---|---|
void SetCommand(string value) |
Replaces PlayerCommandEvent.Command (copied into the per-tick event arena; the engine reads it back after dispatch). |
SetCommand
Section titled “SetCommand”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 |
See also
Section titled “See also”Command · IEvent · Player · Utf8String