From 385fba65ed6ebe632c870c7cf234666cacf5a766 Mon Sep 17 00:00:00 2001 From: Lucas Wilson Date: Sat, 5 Aug 2023 10:12:49 -0600 Subject: [PATCH] Use node-minecraft-protocol for chat (#3110) * 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 Co-authored-by: Romain Beaumont --- lib/plugins/chat.js | 22 ++++------------------ package.json | 2 +- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/plugins/chat.js b/lib/plugins/chat.js index ddd33e55a..b306b1b81 100644 --- a/lib/plugins/chat.js +++ b/lib/plugins/chat.js @@ -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 diff --git a/package.json b/package.json index d24f42720..dc82648d6 100644 --- a/package.json +++ b/package.json @@ -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",