diff --git a/src/handshake/login.js b/src/handshake/login.js index 5035a3d..cf76d96 100644 --- a/src/handshake/login.js +++ b/src/handshake/login.js @@ -15,7 +15,8 @@ module.exports = (client, server, options) => { extraData: { displayName: client.username, identity: client.profile.uuid, - titleId: '89692877' + titleId: '89692877', + XUID: '0' }, certificateAuthority: true, identityPublicKey: client.clientX509 diff --git a/src/serverPlayer.js b/src/serverPlayer.js index 906f3f2..7edfea2 100644 --- a/src/serverPlayer.js +++ b/src/serverPlayer.js @@ -69,7 +69,7 @@ class Player extends Connection { this.profile = { name: userData.extraData?.displayName, uuid: userData.extraData?.identity, - xuid: userData.extraData?.xuid + xuid: userData.extraData?.xuid || userData.extraData?.XUID } this.version = clientVer this.emit('login', { user: userData.extraData }) // emit events for user diff --git a/test/internal.js b/test/internal.js index 50335fd..22c6c87 100644 --- a/test/internal.js +++ b/test/internal.js @@ -14,7 +14,7 @@ function prepare (version) { async function startTest (version = CURRENT_VERSION, ok) { await prepare(version) const Item = require('../types/Item')(version) - const port = 19130 + const port = 19130 + Math.floor(Math.random() * 100) const server = new Server({ host: '0.0.0.0', port, version, offline: true }) function getPath (packetPath) { @@ -25,6 +25,7 @@ async function startTest (version = CURRENT_VERSION, ok) { return require(getPath('sample/' + packetPath)) } + console.log('Starting internal server') server.listen() console.log('Started server') @@ -190,7 +191,6 @@ async function requestChunks (version, x, z, radius) { blobs: [], payload: cbuf }) - // console.log('Ht',cc.sectionsLen,cc.sections) } } @@ -207,5 +207,5 @@ async function timedTest (version, timeout = 1000 * 220) { console.info('✔ ok') } -// if (!module.parent) timedTest('1.18.11') +// if (!module.parent) timedTest('1.16.210') module.exports = { startTest, timedTest, requestChunks } diff --git a/test/vanilla.js b/test/vanilla.js index 41033cc..3f3aa0c 100644 --- a/test/vanilla.js +++ b/test/vanilla.js @@ -7,7 +7,7 @@ async function test (version) { const ChunkColumn = require('bedrock-provider').chunk('bedrock_' + version) // Start the server, wait for it to accept clients, throws on timeout - const handle = await vanillaServer.startServerAndWait(version, 1000 * 220) + const handle = await vanillaServer.startServerAndWait2(version, 1000 * 220) console.log('Started server') const client = new Client({ diff --git a/tools/startVanillaServer.js b/tools/startVanillaServer.js index e2ba4d9..74e4360 100644 --- a/tools/startVanillaServer.js +++ b/tools/startVanillaServer.js @@ -110,9 +110,18 @@ async function startServerAndWait (version, withTimeout, options) { return handle } +async function startServerAndWait2 (version, withTimeout, options) { + try { + return await startServerAndWait(version, withTimeout, options) + } catch (e) { + console.log(e, 'tring once more to start server...') + return await startServerAndWait(version, withTimeout, options) + } +} + if (!module.parent) { // if (process.argv.length < 3) throw Error('Missing version argument') startServer(process.argv[2] || '1.17.10', null, process.argv[3] ? { 'server-port': process.argv[3], 'online-mode': !!process.argv[4] } : undefined) } -module.exports = { fetchLatestStable, startServer, startServerAndWait } +module.exports = { fetchLatestStable, startServer, startServerAndWait, startServerAndWait2 }