Package Exports
- prismarine-chat
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (prismarine-chat) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
prismarine-chat
A parser for a minecraft chat message
Usage
const ChatMessage = require('prismarine-chat')('1.16')
const msg = new ChatMessage({"text":"Example chat mesasge"})
console.log(msg.toString()) // Example chat message
API
ChatMessage(message)
message- Can be either text or a minecraft chat JSON object
chat.toString([lang])
Flattens the message in to plain-text
lang- (optional) - Set a custom lang (defaults to mcData.language)
chat.toMotd([lang], parent)
Converts to motd format
lang- (optional) - Set a custom lang (defaults to mcData.language)parent- Set a custom lang (defaults to mcData.language)
chat.getText(idx, [lang])
Returns a text part from the message
idx- Index of the partlang- (optional) - Set a custom lang (defaults to mcData.language)
chat.toAnsi([lang])
Converts to ansi format
lang- (optional) - Set a custom lang (defaults to mcData.language)
chat.length()
Returns the count of text extras and child ChatMessages Does not count recursively in to the children