Skip to content

API reference / @jsprismarine/prismarine / Console

Class: Console ​

Defined in: prismarine/src/Console.ts:34

The plain line console: one command per line of input, one log record per line of output.

This is the in-process console for plain mode, where the server owns stdin and stdout itself. It never puts the terminal in raw mode, draws no prompt, and does no completion, so it works the same under a pipe, inside a container, from a panel that feeds stdin, and on a Node without a TTY. The interactive terminal UI lives in @jsprismarine/console.

Ctrl+C is not handled here. The process entry point installs the signal handlers that stop the server.

Implements ​

Constructors ​

Constructor ​

new Console(server, input?): Console

Defined in: prismarine/src/Console.ts:41

Parameters ​

server ​

Server

input? ​

Readable = process.stdin

Where command lines come from. Defaults to the process's stdin.

Returns ​

Console

Methods ​

getFormattedUsername() ​

getFormattedUsername(): string

Defined in: prismarine/src/Console.ts:123

The console's name as shown in chat and command feedback.

Returns ​

string

Implementation of ​

CommandExecutor.getFormattedUsername


getName() ​

getName(): string

Defined in: prismarine/src/Console.ts:116

The name commands see for the console executor.

Returns ​

string

Implementation of ​

CommandExecutor.getName


getServer() ​

getServer(): Server

Defined in: prismarine/src/Console.ts:137

Returns the server this console belongs to.

Returns ​

Server

Implementation of ​

CommandExecutor.getServer


sendMessage() ​

sendMessage(message): void

Defined in: prismarine/src/Console.ts:130

Prints a message addressed to the console through the logger at info level.

Parameters ​

message ​

string

Returns ​

void

Implementation of ​

CommandExecutor.sendMessage


write() ​

write(line): void

Defined in: prismarine/src/Console.ts:109

Writes one formatted log line to stdout.

Parameters ​

line ​

string

Returns ​

void

Lifecycle ​

disable() ​

disable(): Promise<void>

Defined in: prismarine/src/Console.ts:96

Stops reading command lines. Output keeps working through write.

Returns ​

Promise<void>

Implementation of ​

Service.disable


enable() ​

enable(): Promise<void>

Defined in: prismarine/src/Console.ts:59

Subscribes to chat and starts reading command lines from the input.

Output needs nothing to be set up, so chat forwarding happens even when there is no usable input; the server attaches this console to the logger itself. Input is skipped when the stream is destroyed or no longer readable, which is what a host that closed stdin leaves behind. A pipe that stays open but never sends anything, as under the test runner, is harmless: readline only pauses it again on disable.

Calling this again after disable starts reading again. Calling it twice without a disable in between does nothing the second time.

Returns ​

Promise<void>

Implementation of ​

Service.enable