Skip to content

API reference / @jsprismarine/prismarine / chat/ChatManager

chat/ChatManager ​

Classes ​

Interfaces ​

ChatDelivery ​

Defined in: packages/prismarine/src/chat/ChatManager.ts:13

One chat line as a player's client receives it.

Properties ​

kind ​

readonly kind: MessageKind

Defined in: packages/prismarine/src/chat/ChatManager.ts:15

message ​

readonly message: string

Defined in: packages/prismarine/src/chat/ChatManager.ts:14

needsTranslation ​

readonly needsTranslation: boolean

Defined in: packages/prismarine/src/chat/ChatManager.ts:17

parameters ​

readonly parameters: string[]

Defined in: packages/prismarine/src/chat/ChatManager.ts:16

sender? ​

readonly optional sender?: ShownChatSender

Defined in: packages/prismarine/src/chat/ChatManager.ts:23

The author's UUID and signature, for a player's own chat only.

sourceName? ​

readonly optional sourceName?: string

Defined in: packages/prismarine/src/chat/ChatManager.ts:19

The author's name, for a player's own chat only.

xuid? ​

readonly optional xuid?: string

Defined in: packages/prismarine/src/chat/ChatManager.ts:21

The author's XUID, for a player's own chat only, and empty without one.


ChatRecipient ​

Defined in: packages/prismarine/src/chat/ChatManager.ts:32

A connected player as the chat fan-out sees one: who they are and where their lines go.

The name and the operator check are read when a message arrives rather than when the player joins, so a name or an operator grant that changes in between is the one that counts.

Properties ​

key ​

readonly key: string

Defined in: packages/prismarine/src/chat/ChatManager.ts:34

The player's key; see keyOfPlayer.

Methods ​

getName() ​

getName(): string

Defined in: packages/prismarine/src/chat/ChatManager.ts:36

The name a *.player.<name> channel addresses.

Returns ​

string

isOp() ​

isOp(): boolean

Defined in: packages/prismarine/src/chat/ChatManager.ts:38

Whether the *.ops channel reaches this player.

Returns ​

boolean

receive() ​

receive(delivery): Promise<void>

Defined in: packages/prismarine/src/chat/ChatManager.ts:40

Sends one line to the player's client.

Parameters ​
delivery ​

ChatDelivery

Returns ​

Promise<void>


ChatRecipientServer ​

Defined in: packages/prismarine/src/chat/ChatManager.ts:50

What a recipient built by chatRecipientOf reads of the server.

Methods ​

getPermissionManager() ​

getPermissionManager(): object

Defined in: packages/prismarine/src/chat/ChatManager.ts:52

Returns ​

object

isOp() ​

isOp(subject): boolean

Parameters ​
subject ​

Subject

Returns ​

boolean

getSessionManager() ​

getSessionManager(): ChatSessions

Defined in: packages/prismarine/src/chat/ChatManager.ts:51

Returns ​

ChatSessions


ChatSessions ​

Defined in: packages/prismarine/src/chat/ChatManager.ts:44

The session registry, as a recipient finds its player's client in it.

Methods ​

sessionOf() ​

sessionOf(id): { sendMessage(delivery): Promise<void>; } | null

Defined in: packages/prismarine/src/chat/ChatManager.ts:46

The client of the online player with this entity id, or null when no online player has it.

Parameters ​
id ​

bigint

Returns ​

{ sendMessage(delivery): Promise<void>; } | null


PlayerChatIntent ​

Defined in: packages/prismarine/src/chat/ChatManager.ts:82

A line a player typed, as the chat action's guard stage sees it.

Properties ​

message ​

readonly message: string

Defined in: packages/prismarine/src/chat/ChatManager.ts:85

sender ​

readonly sender: bigint

Defined in: packages/prismarine/src/chat/ChatManager.ts:84

The entity id of the player who typed it.

Type Aliases ​

ChatBus ​

ChatBus = Pick<ServerEventBus, "post">

Defined in: packages/prismarine/src/chat/ChatManager.ts:79

The part of the server's event bus chat uses.


PlayerChatGuard ​

PlayerChatGuard = (intent) => { veto: true; } | { intent: PlayerChatIntent; veto: false; }

Defined in: packages/prismarine/src/chat/ChatManager.ts:92

A guard in the chat action's guard stage (ADR 0013). It reads the line, writes nothing, and lets it through or vetoes it.

Parameters ​

intent ​

PlayerChatIntent

Returns ​

{ veto: true; } | { intent: PlayerChatIntent; veto: false; }

Functions ​

chatRecipientOf() ​

chatRecipientOf(player, server): ChatRecipient

Defined in: packages/prismarine/src/chat/ChatManager.ts:68

A connected player as the chat fan-out reaches them, built from who they are.

The key and the name come from the identity and the operator check from the permission list. Each line goes to the session the registry finds under the player's entity id, so the recipient holds neither the player nor its client, and a line for a player who has left reaches nobody.

Parameters ​

player ​

The player's entity id and identity, as its session holds them.

identity ​

PlayerIdentity

The name, XUID and UUID the login named.

runtimeId ​

bigint

The entity id the registry finds the session by.

server ​

ChatRecipientServer

The session registry and the permission list.

Returns ​

ChatRecipient

The recipient, to join once and leave with.