PlayerChatEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct PlayerChatEvent : IEventA player sent a chat message. Cancel to drop it. Changing Message or Rendered sends the line as an unsigned server message instead of the player’s signed one. SenderName, ChatType, Decoration and the filter fields restyle the signed line without unsigning it: the signature covers only the typed text.
| Id | 14 |
| Key | mc:player_chat |
| Cancellable | yes |
| Fired by the engine | yes |
| Field | Type | Handlers may write | Description |
|---|---|---|---|
Player |
player |
no (readonly) | The sender. |
Message |
Utf8String |
yes | What the player typed. Changing it re-renders the line with the default format. |
Rendered |
component |
yes | The complete line shown to everybody (default: |
SenderName |
component |
yes | The sender name as the line shows it (hover, click and insertion included). Changing it keeps the message signed. |
ChatType |
enum:ChatKind |
yes | The chat type of the line: Chat, EmoteCommand or SayCommand. The message kinds need a target and are refused here (Chat is used). |
Decoration |
component |
yes | The body as the line shows it (unsigned content: colours, highlights, glyphs). Equal to the typed text means none. Keeps the message signed. |
FilterKind |
enum:ChatFilterKind |
yes | How the recipients who filter text see the message (vanilla FilterMask). Any other value fully filters the message. |
FilterBits |
Utf8String |
yes | For PartiallyFiltered: one 0 or 1 per UTF-16 unit of the typed text, 1 hides the unit. A different length or character fully filters the message. |
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 PlayerChatEvent(Player player, Utf8String message, Utf8String rendered, Utf8String senderName, ChatKind chatType, Utf8String decoration, ChatFilterKind filterKind, Utf8String filterBits)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 |
|
message |
Utf8String |
|
rendered |
Utf8String |
|
senderName |
Utf8String |
|
chatType |
ChatKind |
|
decoration |
Utf8String |
|
filterKind |
ChatFilterKind |
|
filterBits |
Utf8String |
Properties
Section titled “Properties”| Member | Description |
|---|---|
bool Cancelled { get; set; } |
Cancelling stops lower-priority handlers (unless they opt in) and the action itself. |
ChatKind ChatType { get; set; } |
The chat type of the line: Chat, EmoteCommand or SayCommand. |
Component Decoration { get; } |
The body as the line shows it (unsigned content: colours, highlights, glyphs). |
Utf8String DecorationJson { get; } |
The body as the line shows it (unsigned content: colours, highlights, glyphs). |
Utf8String FilterBits { get; } |
For PartiallyFiltered: one 0 or 1 per UTF-16 unit of the typed text, 1 hides the unit. |
ChatFilterKind FilterKind { get; set; } |
How the recipients who filter text see the message (vanilla FilterMask). |
Utf8String Message { get; } |
What the player typed. |
Player Player { get; } |
The sender. |
Component Rendered { get; } |
The complete line shown to everybody (default: <name> message). |
Utf8String RenderedJson { get; } |
The complete line shown to everybody (default: <name> message). |
Component SenderName { get; } |
The sender name as the line shows it (hover, click and insertion included). |
Utf8String SenderNameJson { get; } |
The sender name as the line shows it (hover, click and insertion included). |
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.
ChatType
Section titled “ChatType”public ChatKind ChatType { get; set; }The chat type of the line: Chat, EmoteCommand or SayCommand. The message kinds need a target and are refused here (Chat is used).
Decoration
Section titled “Decoration”public Component Decoration { get; }The body as the line shows it (unsigned content: colours, highlights, glyphs). 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: colours, highlights, glyphs). Equal to the typed text means none. Keeps the message signed. as JSON text (borrowed).
FilterBits
Section titled “FilterBits”public Utf8String FilterBits { get; }For PartiallyFiltered: one 0 or 1 per UTF-16 unit of the typed text, 1 hides the unit. A different length or character fully filters the message. (mutable: use PlayerChatEvent.SetFilterBits)
FilterKind
Section titled “FilterKind”public ChatFilterKind FilterKind { get; set; }How the recipients who filter text see the message (vanilla FilterMask). Any other value fully filters the message.
Message
Section titled “Message”public Utf8String Message { get; }What the player typed. Changing it re-renders the line with the default format. (mutable: use PlayerChatEvent.SetMessage)
Player
Section titled “Player”public Player Player { get; }The sender.
Rendered
Section titled “Rendered”public Component Rendered { get; }The complete line shown to everybody (default: <name> message). Replace it to change the format; takes precedence over Message. (parsed on access; allocates).
RenderedJson
Section titled “RenderedJson”public Utf8String RenderedJson { get; }The complete line shown to everybody (default: <name> message). Replace it to change the format; takes precedence over Message. as JSON text (borrowed).
SenderName
Section titled “SenderName”public Component SenderName { get; }The sender name as the line shows it (hover, click and insertion included). Changing it keeps the message signed. (parsed on access; allocates).
SenderNameJson
Section titled “SenderNameJson”public Utf8String SenderNameJson { get; }The sender name as the line shows it (hover, click and insertion included). Changing it keeps the message signed. as JSON text (borrowed).
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 PlayerChatEvent.Decoration; an empty component clears it where the event says so. |
void SetFilterBits(string value) |
Replaces PlayerChatEvent.FilterBits (copied into the per-tick event arena; the engine reads it back after dispatch). |
void SetMessage(string value) |
Replaces PlayerChatEvent.Message (copied into the per-tick event arena; the engine reads it back after dispatch). |
void SetRendered(Component value) |
Replaces PlayerChatEvent.Rendered; an empty component clears it where the event says so. |
void SetSenderName(Component value) |
Replaces PlayerChatEvent.SenderName; an empty component clears it where the event says so. |
SetDecoration
Section titled “SetDecoration”public void SetDecoration(Component value)Replaces PlayerChatEvent.Decoration; an empty component clears it where the event says so.
Parameters
| Name | Type | Description |
|---|---|---|
value |
Component |
SetFilterBits
Section titled “SetFilterBits”public void SetFilterBits(string value)Replaces PlayerChatEvent.FilterBits (copied into the per-tick event arena; the engine reads it back after dispatch).
Parameters
| Name | Type | Description |
|---|---|---|
value |
string |
SetMessage
Section titled “SetMessage”public void SetMessage(string value)Replaces PlayerChatEvent.Message (copied into the per-tick event arena; the engine reads it back after dispatch).
Parameters
| Name | Type | Description |
|---|---|---|
value |
string |
SetRendered
Section titled “SetRendered”public void SetRendered(Component value)Replaces PlayerChatEvent.Rendered; an empty component clears it where the event says so.
Parameters
| Name | Type | Description |
|---|---|---|
value |
Component |
SetSenderName
Section titled “SetSenderName”public void SetSenderName(Component value)Replaces PlayerChatEvent.SenderName; an empty component clears it where the event says so.
Parameters
| Name | Type | Description |
|---|---|---|
value |
Component |
See also
Section titled “See also”ChatFilterKind · ChatKind · Component · IEvent · Player · Utf8String