mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
Add more fields to playerChat event (#1068)
* Add sender and target name to playerChat event * Update docs * Update docs * Remove unnecessary displayName parsing
This commit is contained in:
parent
c9e900d442
commit
92a5219915
2 changed files with 5 additions and 14 deletions
|
@ -271,6 +271,8 @@ Called when a chat message from another player arrives. The emitted object conta
|
||||||
* type -- the message type - on 1.19, which format string to use to render message ; below, the place where the message is displayed (for example chat or action bar)
|
* type -- the message type - on 1.19, which format string to use to render message ; below, the place where the message is displayed (for example chat or action bar)
|
||||||
* sender -- the UUID of the player sending the message
|
* sender -- the UUID of the player sending the message
|
||||||
* senderTeam -- scoreboard team of the player (pre 1.19)
|
* senderTeam -- scoreboard team of the player (pre 1.19)
|
||||||
|
* senderName -- Name of the sender
|
||||||
|
* targetName -- Name of the target (for outgoing commands like /tell). Only in 1.19.2+
|
||||||
* verified -- true if message is signed, false if not signed, undefined on versions prior to 1.19
|
* verified -- true if message is signed, false if not signed, undefined on versions prior to 1.19
|
||||||
|
|
||||||
### `systemChat` event
|
### `systemChat` event
|
||||||
|
|
|
@ -71,22 +71,11 @@ module.exports = function (client, options) {
|
||||||
publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
|
publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
|
||||||
publicKeyDER: player.crypto.publicKey,
|
publicKeyDER: player.crypto.publicKey,
|
||||||
signature: player.crypto.signature,
|
signature: player.crypto.signature,
|
||||||
displayName: player.displayName || player.name,
|
displayName: player.displayName || player.name
|
||||||
name: player.name
|
|
||||||
}
|
}
|
||||||
client._players[player.UUID].hasChainIntegrity = true
|
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
|
} else if (packet.action === 4) { // remove player
|
||||||
for (const player of packet.data) {
|
for (const player of packet.data) {
|
||||||
delete client._players[player.UUID]
|
delete client._players[player.UUID]
|
||||||
|
@ -143,8 +132,8 @@ module.exports = function (client, options) {
|
||||||
formattedMessage: packet.formattedMessage,
|
formattedMessage: packet.formattedMessage,
|
||||||
type: packet.type,
|
type: packet.type,
|
||||||
sender: packet.senderUuid,
|
sender: packet.senderUuid,
|
||||||
senderName: client._players[packet.senderUuid]?.displayName,
|
senderName: packet.networkName,
|
||||||
senderTeam: packet.senderTeam,
|
targetName: packet.networkTargetName,
|
||||||
verified
|
verified
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue