Use consistent parameter naming for systemChat event (#1076)

* Use consistent parameter naming for systemChat event

* Update docs

* Update types
This commit is contained in:
Frej Alexander Nielsen 2023-01-27 01:01:47 +01:00 committed by GitHub
parent 84bd97c3cb
commit e3e20757ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View file

@ -279,7 +279,7 @@ Called when a chat message from another player arrives. The emitted object conta
Called when a system chat message arrives. A system chat message is any message not sent by a player. The emitted object contains:
* formattedMessage -- the chat message preformatted
* positionid -- the chat type of the message. 1 for system chat and 2 for actionbar
* positionId -- the chat type of the message. 1 for system chat and 2 for actionbar
See the [chat example](https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/examples/client_chat/client_chat.js#L1) for usage.

View file

@ -158,7 +158,7 @@ module.exports = function (client, options) {
client.on('system_chat', (packet) => {
client.emit('systemChat', {
positionid: packet.isActionBar ? 2 : 1,
positionId: packet.isActionBar ? 2 : 1,
formattedMessage: packet.content
})

3
src/index.d.ts vendored
View file

@ -48,7 +48,8 @@ declare module 'minecraft-protocol' {
on(event: 'connect', handler: () => PromiseLike): this
on(event: string, handler: (data: any, packetMeta: PacketMeta) => PromiseLike): this
on(event: `raw.${string}`, handler: (buffer: Buffer, packetMeta: PacketMeta) => PromiseLike): this
on(event: 'playerChat', handler: ({ formattedMessage: string, message: string, type: string, sender: string, senderName: string, senderTeam: string, verified?: boolean })): this
on(event: 'playerChat', handler: (data: { formattedMessage: string, message: string, type: string, sender: string, senderName: string, senderTeam: string, verified?: boolean }) => PromiseLike): this
on(event: 'systemChat', handler: (data: { positionId: number, formattedMessage: string }) => PromiseLike): this
once(event: 'error', listener: (error: Error) => PromiseLike): this
once(event: 'packet', handler: (data: any, packetMeta: PacketMeta, buffer: Buffer, fullBuffer: Buffer) => PromiseLike): this
once(event: 'raw', handler: (buffer: Buffer, packetMeta: PacketMeta) => PromiseLike): this