PrivateMessageEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct PrivateMessageEvent : IEventA 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.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
Constructor |
Creates the event (for firing it from a plugin; native code builds its own). |
Constructor
Section titled “Constructor”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 |
Properties
Section titled “Properties”| 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. |
Cancelled
Section titled “Cancelled”public bool Cancelled { get; set; }Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
Decoration
Section titled “Decoration”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).
DecorationJson
Section titled “DecorationJson”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).
Message
Section titled “Message”public Utf8String Message { get; }The typed text. Changing it sends the message unsigned. (mutable: use PrivateMessageEvent.SetMessage)
Sender
Section titled “Sender”public Player Sender { get; }The player who typed the command.
Target
Section titled “Target”public Player Target { get; }The recipient. A /msg with several targets fires once per target.
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 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). |
SetDecoration
Section titled “SetDecoration”public void SetDecoration(Component value)Replaces PrivateMessageEvent.Decoration; an empty component clears it where the event says so.
Parameters
| Name | Type | Description |
|---|---|---|
value |
Component |
SetMessage
Section titled “SetMessage”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 |
See also
Section titled “See also”Component · IEvent · Player · Utf8String