Skip to content

Commit

Permalink
Use node-minecraft-protocol for chat (#3110)
Browse files Browse the repository at this point in the history
* Send previous msgs

* Use node-minecraft-protocol for command parsing

* Leave all chat handling to nmp

* Don't split command without header

* point minecraft-protocol dep to fork

* Update package.json

---------

Co-authored-by: extremeheat <extreme@protonmail.ch>
Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
  • Loading branch information
3 people committed Aug 5, 2023
1 parent 131a7ea commit 385fba6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
22 changes: 4 additions & 18 deletions lib/plugins/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,10 @@ function inject (bot, options) {
throw new Error('Incorrect type! Should be a string or number.')
}

if (bot.supportFeature('signedChat')) {
if (message.startsWith('/')) {
// We send commands as Chat Command packet in 1.19+
const command = message.slice(1)
const timestamp = BigInt(Date.now())
bot._client.write('chat_command', {
command,
timestamp,
salt: 0n,
argumentSignatures: [],
signedPreview: false,
messageCount: 0,
acknowledged: Buffer.alloc(3),
// 1.19.2 Chat Command packet also includes an array of last seen messages
previousMessages: []
})
return
}
if (!header && message.startsWith('/')) {
// Do not try and split a command without a header
bot._client.chat(message)
return
}

const lengthLimit = CHAT_LENGTH_LIMIT - header.length
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"license": "MIT",
"dependencies": {
"minecraft-data": "^3.37.0",
"minecraft-protocol": "^1.43.1",
"minecraft-protocol": "^1.44.0",
"prismarine-biome": "^1.1.1",
"prismarine-block": "^1.17.0",
"prismarine-chat": "^1.7.1",
Expand Down

0 comments on commit 385fba6

Please sign in to comment.