A parser for a minecraft chat message
const registry = require('prismarine-registry')('1.16')
const ChatMessage = require('prismarine-chat')(registry)
const msg = new ChatMessage({"text":"Example chat mesasge"})
console.log(msg.toString()) // Example chat messagemessage- Can be either text or a minecraft chat JSON objectdisplayWarning- Display warnings if true, default to false
Flattens the message in to plain-text
lang- (optional) - Set a custom lang (defaults to mcData.language)
Converts to motd format
lang- (optional) - Set a custom lang (defaults to mcData.language)parent- Set a custom lang (defaults to mcData.language)
Returns a text part from the message
idx- Index of the partlang- (optional) - Set a custom lang (defaults to mcData.language)
Converts to ansi format
lang- (optional) - Set a custom lang (defaults to mcData.language)
Returns the count of text extras and child ChatMessages Does not count recursively in to the children
Appends another ChatMessage or a string
Returns a clone of the ChatMessage
const registry = require('prismarine-registry')('1.16')
const { MessageBuilder } = require('prismarine-chat')(registry)
const msg = new MessageBuilder().setText('Example chat mesasge')
console.log(JSON.stringify(msg)) // The string as a message componentReturns a prismarine-chat representation of the message recieved from the 'chat' packet, example shown here
(1.19+) Loads a chat message sent by server that needs to be formatted on client side.
check code for examples (and explanations) from here on
sets every one of the formatting options to false and sets text to reset type
builder.toJSON() is the same thing as JSON.stringify(builder)
runs JSON.stringify() on this
convert string with color codes like &4Hello&cWorld to a MessageBuilder object