Skip to content

Commit

Permalink
Fix chat not working on offline servers (#1060)
Browse files Browse the repository at this point in the history
* Do not acknowledge unsigned messages

* Fix lint

* Parse player data in offline mode

* Fix lint
  • Loading branch information
frej4189 authored Jan 16, 2023
1 parent f2875a5 commit 4201b94
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/client/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,22 @@ module.exports = function (client, options) {
publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
publicKeyDER: player.crypto.publicKey,
signature: player.crypto.signature,
displayName: player.displayName || player.name
displayName: player.displayName || player.name,
name: player.name
}
client._players[player.UUID].hasChainIntegrity = true
} else {
client._players[player.UUID] = {
displayName: player.displayName || player.name,
name: player.name
}
}
}
} else if (packet.action === 3) {
for (const player of packet.data) {
if (!client._players[player.UUID]) continue
client._players[player.UUID].displayName = player.displayName || client._players[player.UUID].name
}
} else if (packet.action === 4) { // remove player
for (const player of packet.data) {
delete client._players[player.UUID]
Expand Down Expand Up @@ -294,6 +305,8 @@ class LastSeenMessages extends Array {
capacity = 5
pending = 0
push (e) {
if (e.signature.length === 0) return // We do not acknowledge unsigned messages

// Insert a new entry at the top and shift everything to the right
let last = this[0]
this[0] = e
Expand Down

0 comments on commit 4201b94

Please sign in to comment.