Skip to content

Commit

Permalink
Fix server_data payload sent to clients for versions 1.19+
Browse files Browse the repository at this point in the history
Fixes #1362

Add missing fields to `server_data` payload for versions 1.19+.

* Add `motd` and `icon` fields to `server_data` payload for version 1.19.
* Add `motd`, `icon`, and `enforcesSecureChat` fields to `server_data` payload for version 1.19.2.
* Add `motd`, `icon`, and `enforcesSecureChat` fields to `server_data` payload for version 1.19.3.
* Add `motd`, `iconBytes`, and `enforcesSecureChat` fields to `server_data` payload for versions 1.19.4, 1.20, and 1.20.2.
* Add `motd`, `iconBytes`, and `enforcesSecureChat` fields to `server_data` payload for version 1.20.3.
* Add `motd` and `iconBytes` fields to `server_data` payload for version 1.20.5+.
* Use NBT components for `motd` if `chatPacketsUseNbtComponents` feature is supported.
* Convert `favicon` to buffer for `iconBytes` field if available.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/PrismarineJS/node-minecraft-protocol/issues/1362?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
extremeheat committed Jan 6, 2025
1 parent f258c76 commit 2007a73
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/server/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ module.exports = function (client, server, options) {
client.settings = {}

if (client.supportFeature('chainedChatWithHashing')) { // 1.19.1+
const jsonMotd = server.motdMsg ?? { text: server.motd }
const nbtMotd = nbt.comp({ text: nbt.string(server.motd) })
client.write('server_data', {
motd: client.supportFeature('chatPacketsUseNbtComponents') ? nbtMotd : motd,
icon: server.favicon, // b64
iconBytes: server.favicon ? Buffer.from(server.favicon, 'base64') : undefined,
previewsChat: options.enableChatPreview,
// Note: in 1.20.5+ user must send this with `login`
enforcesSecureChat: options.enforceSecureProfile
Expand Down

0 comments on commit 2007a73

Please sign in to comment.