diff --git a/src/server.js b/src/server.js index 7eab660..24db23f 100644 --- a/src/server.js +++ b/src/server.js @@ -24,12 +24,11 @@ class Server extends EventEmitter { self.socketServer.on('connection', socket => { const client = new Client(true, this.version, this.customPackets, this.hideErrors) client._end = client.end - client.end = function end (endReason, fullReason) { - endReason = fullReason !== undefined ? fullReason : '{"text":"' + endReason + '"}' + client.end = function end (endReason, fullReason = JSON.stringify({ text: endReason })) { if (client.state === states.PLAY) { - client.write('kick_disconnect', { reason: endReason }) + client.write('kick_disconnect', { reason: fullReason }) } else if (client.state === states.LOGIN) { - client.write('disconnect', { reason: endReason }) + client.write('disconnect', { reason: fullReason }) } client._end(endReason) } diff --git a/test/serverTest.js b/test/serverTest.js index 1062301..2515189 100644 --- a/test/serverTest.js +++ b/test/serverTest.js @@ -95,7 +95,7 @@ mc.supportedVersions.forEach(function (supportedVersion, i) { let count = 2 server.on('connection', function (client) { client.on('end', function (reason) { - assert.strictEqual(reason, '{"text":"LoginTimeout"}') + assert.strictEqual(reason, 'LoginTimeout') server.close() }) }) @@ -126,7 +126,7 @@ mc.supportedVersions.forEach(function (supportedVersion, i) { let count = 2 server.on('connection', function (client) { client.on('end', function (reason) { - assert.strictEqual(reason, '{"text":"KeepAliveTimeout"}') + assert.strictEqual(reason, 'KeepAliveTimeout') server.close() }) }) @@ -323,7 +323,7 @@ mc.supportedVersions.forEach(function (supportedVersion, i) { let count = 2 server.on('login', function (client) { client.on('end', function (reason) { - assert.strictEqual(reason, '{"text":"ServerShutdown"}') + assert.strictEqual(reason, 'ServerShutdown') resolve() }) const loginPacket = {