Skip to content

Commit

Permalink
only nbt on the play state disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeheat committed Jan 6, 2025
1 parent 9519944 commit a034500
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ class Server extends EventEmitter {
const client = new Client(true, this.version, this.customPackets, this.hideErrors)
client._end = client.end
client.end = function end (endReason, fullReason) {
fullReason ??= this._supportFeature('chatPacketsUseNbtComponents') ? nbt.comp({ text: nbt.string(endReason) }) : JSON.stringify({ text: endReason })
if (client.state === states.PLAY) {
fullReason ||= this._supportFeature('chatPacketsUseNbtComponents')
? nbt.comp({ text: nbt.string(endReason) })
: JSON.stringify({ text: endReason })
client.write('kick_disconnect', { reason: fullReason })
} else if (client.state === states.LOGIN) {
client.write('disconnect', { reason: fullReason })
client.write('disconnect', { reason: fullReason || endReason })
}
client._end(endReason)
}
Expand Down

0 comments on commit a034500

Please sign in to comment.