mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
Fix chat not working on offline servers (#1060)
* Do not acknowledge unsigned messages * Fix lint * Parse player data in offline mode * Fix lint
This commit is contained in:
parent
f2875a5f03
commit
4201b94ab8
1 changed files with 14 additions and 1 deletions
|
@ -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]
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue