{"name":"prismarine-chat","version":"1.13.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":"^30.1.2","mocha":"^11.0.1","prismarine-chat":"file:.","standard":"^17.0.0","prismarine-item":"^1.10.0"},"dependencies":{"debug":"^4.3.2","mojangson":"^2.0.1","prismarine-nbt":"^2.0.0","prismarine-registry":"^1.4.0"},"gitHead":"cd9e437aee4aae57b38b163a45fbc026fd6f58d3","types":"./index.d.ts","_id":"prismarine-chat@1.13.0","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-tvDbrQmJEoy09yLE5nnedGhQYxnRDaPRePMv7W39dFaHr2LGcA2JfCmH0vG5193+BsEFz3a5+0EpQSK8OW7YmA==","shasum":"e669d810b57ced86dc0252b0ec8f5358532b9f61","tarball":"http://registry-npm.ywwl.com/prismarine-chat/download/prismarine-chat-1.13.0.tgz","fileCount":22,"unpackedSize":71928,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/prismarine-chat@1.13.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH8E+UKYHpwH83rQ0H/pOS1BxDrYsMtU1eHjzDcrB8NAAiEAyBFNVZxsXN64NCyisX4CLyeHSlW0ZH4ZRXd/yR8xsyc="}],"size":19950,"noattachment":false,"key":"/prismarine-chat/-/prismarine-chat-1.13.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a0c9ee11-3415-4ad2-961e-7281a05f1236"}},"directories":{},"maintainers":[{"name":"rom1504","email":"romain.rom1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/prismarine-chat_1.13.0_1774833629781_0.9081844670787873"},"_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":1774833629957,"_cnpm_publish_time":1774833629957,"dist-tags":{"latest":"1.13.0"}}