ChannelRegistry
Namespace Mc.Scripting · Kind class (sealed)
public sealed class ChannelRegistryPlugin messaging channels (Paper’s Messenger, sendPluginMessage). ChannelRegistry.On listens on a channel: the messages that the clients send on it arrive in the handler. The engine tells the clients which channels are listened on (minecraft:register). Send with {{cref:M:Mc.Scripting.Player.SendPluginMessage(System.String,System.ReadOnlySpan{System.Byte})}}.
Remarks
Section titled “Remarks”Refused: the minecraft:* channels (a client’s own registrations are read through Player.Channels), velocity:* and bungeecord:*. Messages arrive in the tick window, in order per player, within the budgets of scripting.channels (a message beyond them is dropped). A listener ends with its plugin (unload or reload). Tick thread only. The worker delivers the messages; the in-process runtime does not.
Methods
Section titled “Methods”| Member | Description |
|---|---|
ChannelSubscription On(string channel, PluginMessageHandler handler) |
Listens on a channel. |
public ChannelSubscription On(string channel, PluginMessageHandler handler)Listens on a channel. The first listener of a channel makes the engine announce it to the clients (minecraft:register).
Parameters
| Name | Type | Description |
|---|---|---|
channel |
string |
A channel id, namespace:path (for example “myplugin:sync”). |
handler |
PluginMessageHandler |
Gets the player who sent the message and its bytes. |
Returns ChannelSubscription: The subscription; dispose it to stop listening.
Throws
System.ArgumentException: The channel is not a valid id, or it is reserved.System.InvalidOperationException: The engine already listens on too many channels.