{"name":"prismarine-chat","version":"1.7.1","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","sprintf-js":"^1.1.2"},"gitHead":"57ea8b375f40802c32238e720790856fac8d8956","_id":"prismarine-chat@1.7.1","_nodeVersion":"14.0.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-SwhtT+0LcqHjs/9DY4IOmPYQUKOMitg4yj30znUS16x6/PhLDBqk37CHcQWOju17GChphd8tjj891o2HCBjZ9w==","shasum":"83b666f4dba086cf7ddad4d5bc1a24386c420e50","tarball":"http://registry-npm.ywwl.com/prismarine-chat/download/prismarine-chat-1.7.1.tgz","fileCount":19,"unpackedSize":46682,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHX/UMNEQsnVw5U8+66bd4+YRyk8CCk/E1z75a2Yn3ZRAiEAhn6NWiKBZs4VMNtbu6Rey6ZjlN7sGgg9NzUjXczX6ak="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjN+1jACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr3lQ//fHFOa0ny/BnD+N7Dg2b+4eE/n01X+Kr0MHrAI93JrnvyW1F9\r\nEWQBvyoDXRQ/LTc7g2xZIGSgEiuH1cg0w9RZwDu9hjMGg6tDsOxyQVcSYohI\r\noHzgbFsJVXSPrcEO0IPaF1IDmJ6+mYPN/9Y6IhAUefhpmxxserHu+88Ag0vR\r\nIsup+ogCXCLCOZeFRkHFqUBVFUQ9/i1INH9Yi4J9wc4/KUTtoShnoELzjDeq\r\nMG8GgXMZ+79UR/jTWTeJZfpRNSKMHUZxWpKd/auf17EoiONJeo9aHICcJRpG\r\nYeMAmJuO7pq2RPCAKUt69c2+C8LP1gM41cwn1uRdblyR8eQxtfvfn4fVsf0E\r\nMMfLeA4tzNIDwFELsx0tgwLL5OjMbo5sH4I5+c7hDofKkMlLuRfosDMvDOA0\r\nwk1JR0g6SyytwzQryJmjv4KsD/JDJQE4wvoY8S+6QVne+4f1/HNQuBolct5p\r\n7lDZBMC96KU5vmsWHrcCf1+tIB3WzZS6lHoKWPfXjo5vFWMfdGDhh4/7/3CU\r\nx3murryqFhEhS+tDzL0V7WGwZy+ozh3JaHwh6Mt9YckuaTdT7T4/Lt3MJ0jT\r\nN5b0xbDd8cm9LpD15kc9s2ptM2mGL7/WPBPDxGOhVF3uLgi28mVCMehsfShi\r\nveIN4PP3Rrbj7ts65HGRqmS4088NgV0sdqs=\r\n=bEnO\r\n-----END PGP SIGNATURE-----\r\n","size":13181,"noattachment":false,"key":"/prismarine-chat/-/prismarine-chat-1.7.1.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.7.1_1664609635695_0.5042061812066734"},"_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":1664609635831,"_cnpm_publish_time":1664609635831,"dist-tags":{"latest":"1.13.0"}}