Skip to content

Commit 3bd4dc1

Browse files
authored
Fix client.end() (#1376)
1 parent 5ec3dd4 commit 3bd4dc1

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/createServer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ function createServer (options = {}) {
4646
server.onlineModeExceptions = Object.create(null)
4747
server.favicon = favicon
4848
server.options = options
49-
server._supportFeature = mcData.supportFeature
5049
options.registryCodec = options.registryCodec || mcData.registryCodec || mcData.loginPacket?.dimensionCodec
5150

5251
// The RSA keypair can take some time to generate

src/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Server extends EventEmitter {
2929
client._end = client.end
3030
client.end = function end (endReason, fullReason) {
3131
if (client.state === states.PLAY) {
32-
fullReason ||= this._supportFeature('chatPacketsUseNbtComponents')
32+
fullReason ||= client._supportFeature('chatPacketsUseNbtComponents')
3333
? nbt.comp({ text: nbt.string(endReason) })
3434
: JSON.stringify({ text: endReason })
3535
client.write('kick_disconnect', { reason: fullReason })

src/server/handshake.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ module.exports = function (client, server, { version, fallbackVersion }) {
99
client.protocolVersion = packet.protocolVersion
1010

1111
if (version === false) {
12-
if (require('minecraft-data')(client.protocolVersion)) {
12+
const mcData = require('minecraft-data')(client.protocolVersion)
13+
if (mcData) {
1314
client.version = client.protocolVersion
15+
client._supportFeature = mcData.supportFeature
16+
client._hasBundlePacket = mcData.supportFeature('hasBundlePacket')
1417
} else {
1518
let fallback
1619
if (fallbackVersion !== undefined) {
1720
fallback = require('minecraft-data')(fallbackVersion)
1821
}
1922
if (fallback) {
2023
client.version = fallback.version.version
24+
client._supportFeature = fallback.supportFeature
25+
client._hasBundlePacket = fallback.supportFeature('hasBundlePacket')
2126
} else {
2227
client.end('Protocol version ' + client.protocolVersion + ' is not supported')
2328
}

0 commit comments

Comments
 (0)