Skip to content

PrivateMessageEvent

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

public ref struct PrivateMessageEvent : IEvent

A player sent a private message (/msg, /tell, /w) to one player. Cancel to drop the copy for that target. Changing the message sends it unsigned; a changed decoration keeps it signed. Console senders do not fire it.

Id 305
Key mc:player_private_message
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Sender player no (readonly) The player who typed the command.
Target player no (readonly) The recipient. A /msg with several targets fires once per target.
Message Utf8String yes The typed text. Changing it sends the message unsigned.
Decoration component yes The body as the line shows it (unsigned content). Equal to the typed text means none. Keeps the message signed.

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

Member Description
Constructor Creates the event (for firing it from a plugin; native code builds its own).
public PrivateMessageEvent(Player sender, Player target, Utf8String message, Utf8String decoration)

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

Parameters

Name Type Description
sender Player
target Player
message Utf8String
decoration Utf8String
Member Description
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
Component Decoration { get; } The body as the line shows it (unsigned content).
Utf8String DecorationJson { get; } The body as the line shows it (unsigned content).
Utf8String Message { get; } The typed text.
Player Sender { get; } The player who typed the command.
Player Target { get; } The recipient.
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 Component Decoration { get; }

The body as the line shows it (unsigned content). Equal to the typed text means none. Keeps the message signed. (parsed on access; allocates).

public Utf8String DecorationJson { get; }

The body as the line shows it (unsigned content). Equal to the typed text means none. Keeps the message signed. as JSON text (borrowed).

public Utf8String Message { get; }

The typed text. Changing it sends the message unsigned. (mutable: use PrivateMessageEvent.SetMessage)

public Player Sender { get; }

The player who typed the command.

public Player Target { get; }

The recipient. A /msg with several targets fires once per target.

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 SetDecoration(Component value) Replaces PrivateMessageEvent.Decoration; an empty component clears it where the event says so.
void SetMessage(string value) Replaces PrivateMessageEvent.Message (copied into the per-tick event arena; the engine reads it back after dispatch).
public void SetDecoration(Component value)

Replaces PrivateMessageEvent.Decoration; an empty component clears it where the event says so.

Parameters

Name Type Description
value Component
public void SetMessage(string value)

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

Parameters

Name Type Description
value string

Component · IEvent · Player · Utf8String