{"name":"prismarine-chat","version":"1.8.0","description":"Wrapper for a minecraft chat message","main":"index.js","scripts":{"test":"mocha --reporter spec --exit","pretest":"npm run lint","lint":"standard","fix":"standard --fix"},"repository":{"type":"git","url":"git+https://github.com/PrismarineJS/prismarine-chat.git"},"keywords":["prismarine","chat"],"author":{"name":"Romain Beaumont"},"license":"MIT","bugs":{"url":"https://github.com/PrismarineJS/prismarine-chat/issues"},"homepage":"https://github.com/PrismarineJS/prismarine-chat#readme","devDependencies":{"expect":"^29.1.0","mocha":"^10.0.0","prismarine-chat":"file:.","standard":"^17.0.0"},"dependencies":{"mojangson":"^2.0.1","prismarine-item":"^1.10.0","prismarine-nbt":"^2.0.0","prismarine-registry":"^1.4.0"},"gitHead":"8dba368cef6652bcc7785a153964c927ad223ff9","_id":"prismarine-chat@1.8.0","_nodeVersion":"14.0.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-hEz47GESIEP0W1KSHrK7ZSy0PqbQW7khYWenv8d5wvyAYnBs1E4KXDBJSWqyGIYinKGN9aes8v3xpQhgURK/Fg==","shasum":"9cae1bfc17c79450ed8736dbc80b43050b452347","tarball":"http://registry-npm.ywwl.com/prismarine-chat/download/prismarine-chat-1.8.0.tgz","fileCount":20,"unpackedSize":47665,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFbheg5Q4TsDC2DVH+B3grfGiVzsT4xTf6XspViCh4TVAiAhMT2XQ66H8nWwT1UCR3Ev3VsxxbGDipTtk3dJodkOqA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjyJEHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoQ2BAAj8LzToMcjU4NTedkhCLgFi1XjdR0ykzezrT5XTT6hqOk1hbw\r\n5OQjc5LViaOUIkFGE5f/62fFEh1yrIatxH7D2J1o4ucRRzhinIsEnopxZcfG\r\nfPPxq5CXHgsjlPrIvMlNoD2hbC1+oiZZIC8AzF8urkbahhOcVrQSabqA17CQ\r\nGu9ytUVch1Fcoek1ondt130JFx6i9VooVlUY7tHKHUMfDUJ3CWIyGlMH+Esd\r\nWZpcxG0pCrls6GajDWd+ZUnGaRCStlNt3XW+6JQHKchqASRuFGd2hniZt0sE\r\nzCm5pZbvTb3VE9kR7V757ZJsMmMUP3k9z349dt76zFdGKxurb9HjFheMy8Wu\r\n9Ml/XypxiSdXMWS/2rafEU9ZYUdpwD7SqiQ2+8vRqK7R9fxYN2SlW/eEE3hp\r\nEU6LcYDAi2YssVNKjkABqGN+dAf21VQ0znKwEcJKSfO3QVJDavS/E/E2wjMU\r\nF8OgFM94MIzeBJsPK2mYPo3RyiCtiRkZYU1RzmQrXUyyEqpFmjU2xQTO86ZU\r\nYt2cPSXYNH9IFX7cAe1HJaAl2WwBRc5g/2kjmaRJtcgrYgZ9ZaXb5VDo6AvF\r\nnafnYH5ib2C+OD09lq0kVybK77jEPj0pQTlR6B83Vph0UQ5btIt18TLMaFu4\r\n48FH+qRobg50seB+1cZ/ioxOI1aUDz3buzE=\r\n=j6hf\r\n-----END PGP SIGNATURE-----\r\n","size":13469,"noattachment":false,"key":"/prismarine-chat/-/prismarine-chat-1.8.0.tgz"},"_npmUser":{"name":"rom1504","email":"romain.rom1@gmail.com"},"directories":{},"maintainers":[{"name":"rom1504","email":"romain.rom1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/prismarine-chat_1.8.0_1674088711737_0.9249887542252948"},"_hasShrinkwrap":false,"readme":"# prismarine-chat\n[![NPM version](https://img.shields.io/npm/v/prismarine-chat.svg)](http://npmjs.com/package/prismarine-chat)\n[![Build Status](https://github.com/PrismarineJS/prismarine-chat/workflows/CI/badge.svg)](https://github.com/PrismarineJS/prismarine-chat/actions?query=workflow%3A%22CI%22)\n[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](https://discord.gg/GsEFRM8)\n[![Gitter](https://img.shields.io/badge/chat-on%20gitter-brightgreen.svg)](https://gitter.im/PrismarineJS/general)\n[![Irc](https://img.shields.io/badge/chat-on%20irc-brightgreen.svg)](https://irc.gitter.im/)\n[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/PrismarineJS/prismarine-chat)\n\nA parser for a minecraft chat message\n\n\n## Usage\n\n```js\nconst registry = require('prismarine-registry')('1.16')\nconst ChatMessage = require('prismarine-chat')(registry)\n\nconst msg = new ChatMessage({\"text\":\"Example chat mesasge\"})\nconsole.log(msg.toString()) // Example chat message\n\n```\n## API\n\n### ChatMessage(message,[displayWarning])\n* `message` - Can be either text or a minecraft chat JSON object\n* `displayWarning` - Display warnings if true, default to false\n\n#### chat.toString([lang])\n\nFlattens the message in to plain-text\n * `lang` - (optional) - Set a custom lang (defaults to registry.language)\n\n#### chat.toMotd([lang], parent)\n\nConverts to motd format\n * `lang` - (optional) - Set a custom lang (defaults to registry.language)\n * `parent` - Set a custom lang (defaults to mcData.language)\n\n#### chat.getText(idx, [lang])\n\nReturns a text part from the message\n * `idx` - Index of the part\n * `lang` - (optional) - Set a custom lang (defaults to registry.language)\n\n#### chat.toAnsi([lang], [codes])\n\nConverts to ansi format\n * `lang` - (optional) - Set a custom lang (defaults to registry.language)\n * `codes` - (optional) - Specify which ANSI formatting codes should be used for each Minecraft color code\n\n#### chat.toHTML([lang], [codes], [allowedFormats])\nConverts to escaped HTML\n* `lang` - (optional) - Set a custom lang (defaults to registry.language)\n* `codes` - (optional) - Specify which CSS style props should be used for each Minecraft color code\n* `allowedFormats` - The set of allowed formats. Default is ['color', 'bold', 'strikethrough', 'underlined', 'italic']\n\n#### chat.length()\n\nReturns the count of text extras and child ChatMessages\nDoes not count recursively in to the children\n\n#### chat.append(ChatMessage)\n\nAppends another ChatMessage or a string\n\n#### chat.clone()\n\nReturns a clone of the ChatMessage\n\n```js\nconst registry = require('prismarine-registry')('1.16')\nconst { MessageBuilder } = require('prismarine-chat')(registry)\n\nconst msg = new MessageBuilder().setText('Example chat mesasge')\nconsole.log(JSON.stringify(msg)) // The string as a message component\n\n```\n\n#### static ChatMessage.fromNotch(msg)\n\nReturns a prismarine-chat representation of the message recieved from the 'chat' packet, example shown [here](examples/minecraftprotocol_fromnotch/fromnotch.js)\n\n#### static ChatMessage.fromNetwork(messageType, messageParameters)\n\n(1.19+) Loads a chat message sent by server that needs to be formatted on client side.\n\n### MessageBuilder()\n\n#### setBold (val: boolean) : this\n#### setItalic (val: boolean) : this\n#### setUnderlined (val: boolean) : this\n#### setStrikethrough (val: boolean) : this\n#### setObfuscated (val: boolean) : this\n#### setColor (val: string) : this\n#### setText (val: string) : this\n\n> check code for examples (and explanations) from here on\n\n#### setFont (val: string) : this\n#### setTranslate (val: string) : this\n#### setInsertion (val: string) : this\n#### setKeybind (val: string) : this\n#### setScore (name: string, objective: string) : this\n#### setClickEvent (action: string, value: object) : this\n#### setHoverEvent (action: string, data: object, type?: 'contents'|'value') : this\n#### addExtra (...val: MessageBuilder | string) : this\n#### addWith (...val: MessageBuilder | string) : this\n#### resetFormatting () : void\nsets every one of the formatting options to false and sets text to `reset` type\n\n#### toJSON () : object\n`builder.toJSON()` is the same thing as `JSON.stringify(builder)`\n\n#### toString () : string\nruns `JSON.stringify()` on `this`\n\n#### static MessageBuilder.fromString(str, {colorSeparator = '&'}) : MessageBuilder\nconvert string with color codes like `&4Hello&cWorld` to a `MessageBuilder` object\n\n### processNbtMessage\n\nThis method is internally called by fromNotch.\n\nmcpc 1.20.3 uses NBT instead of JSON in some places to store chat, so the schema is a bit different.\n`processNbtMessage` normalizes the JS object obtained from nbt derealization to the old JSON schema,\nso it can be used to instantiate a ChatMessage.\n","publish_time":1674088711904,"_cnpm_publish_time":1674088711904,"dist-tags":{"latest":"1.13.0"}}