Default createClient to latest version, fix server motd version (#144)
* Default createClient to latest version, fix server motd version * Update vanilla.js
This commit is contained in:
parent
ac2e9852be
commit
adfa248e2d
8 changed files with 13 additions and 14 deletions
|
|
@ -61,7 +61,7 @@ const server = bedrock.createServer({
|
|||
port: 19132, // optional, port to bind to, default 19132
|
||||
offline: false, // default false. verify connections with XBL
|
||||
motd: {
|
||||
name: 'Funtime Server', // Top level message shown in server list
|
||||
motd: 'Funtime Server', // Top level message shown in server list
|
||||
levelName: 'Wonderland' // Sub-level header
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
"debug": "^4.3.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jsp-raknet": "^2.1.3",
|
||||
"minecraft-data": "^2.89.4",
|
||||
"minecraft-data": "^2.95.0",
|
||||
"minecraft-folder-path": "^1.2.0",
|
||||
"prismarine-auth": "^1.1.0",
|
||||
"prismarine-nbt": "^1.5.0",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
const { Client } = require('./client')
|
||||
const { RakClient } = require('./rak')(true)
|
||||
const { Versions, CURRENT_VERSION } = require('./options')
|
||||
const { sleep } = require('./datatypes/util')
|
||||
const assert = require('assert')
|
||||
const advertisement = require('./server/advertisement')
|
||||
const { sleep } = require('./datatypes/util')
|
||||
|
||||
/** @param {{ version?: number, host: string, port?: number, connectTimeout?: number, skipPing?: boolean }} options */
|
||||
function createClient (options) {
|
||||
|
|
@ -13,9 +14,9 @@ function createClient (options) {
|
|||
connect(client)
|
||||
} else { // Try to ping
|
||||
client.ping().then(data => {
|
||||
const advert = advertisement.fromServerName(data)
|
||||
console.log(`Connecting to server ${advert.motd} (${advert.name}), version ${advert.version}`)
|
||||
client.options.version = options.version ?? advert.version
|
||||
const ad = advertisement.fromServerName(data)
|
||||
client.options.version = options.version ?? (Versions[ad.version] ? ad.version : CURRENT_VERSION)
|
||||
console.log(`Connecting to server ${ad.motd} (${ad.name}), version ${ad.version}`, client.options.version !== ad.version ? ` (as ${client.options.version})` : undefined)
|
||||
connect(client)
|
||||
}, client)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Server extends EventEmitter {
|
|||
|
||||
this.serializer = createSerializer(this.options.version)
|
||||
this.deserializer = createDeserializer(this.options.version)
|
||||
this.advertisement = new ServerAdvertisement(this.options.motd)
|
||||
this.advertisement = new ServerAdvertisement(this.options.motd, this.options.version)
|
||||
this.advertisement.playersMax = options.maxPlayers ?? 3
|
||||
/** @type {Object<string, Player>} */
|
||||
this.clients = {}
|
||||
|
|
|
|||
|
|
@ -3,16 +3,15 @@ const { Versions, CURRENT_VERSION } = require('../options')
|
|||
class ServerAdvertisement {
|
||||
motd = 'Bedrock Protocol Server'
|
||||
levelName = 'bedrock-protocol'
|
||||
protocol = Versions[CURRENT_VERSION]
|
||||
version = CURRENT_VERSION
|
||||
playersOnline = 0
|
||||
playersMax = 5
|
||||
|
||||
gamemode = 'Creative'
|
||||
serverId = '0'
|
||||
|
||||
constructor (obj, version) {
|
||||
constructor (obj, version = CURRENT_VERSION) {
|
||||
if (obj?.name) obj.motd = obj.name
|
||||
this.protocol = Versions[version]
|
||||
this.version = version
|
||||
Object.assign(this, obj)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -205,5 +205,5 @@ async function timedTest (version, timeout = 1000 * 220) {
|
|||
console.info('✔ ok')
|
||||
}
|
||||
|
||||
if (!module.parent) timedTest()
|
||||
// if (!module.parent) timedTest()
|
||||
module.exports = { startTest, timedTest, requestChunks }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ const vanillaServer = require('../tools/startVanillaServer')
|
|||
const { Client } = require('../src/client')
|
||||
const { waitFor } = require('../src/datatypes/util')
|
||||
const { ChunkColumn, Version } = require('bedrock-provider')
|
||||
const { CURRENT_VERSION } = require('../src/options')
|
||||
|
||||
async function test (version) {
|
||||
// Start the server, wait for it to accept clients, throws on timeout
|
||||
|
|
@ -67,5 +66,4 @@ async function test (version) {
|
|||
clearInterval(loop)
|
||||
}
|
||||
|
||||
if (!module.parent) test(CURRENT_VERSION)
|
||||
module.exports = { clientTest: test }
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ async function dump (version, force = true) {
|
|||
const random = ((Math.random() * 100) | 0)
|
||||
const port = 19130 + random
|
||||
|
||||
console.log('Starting dump server', version)
|
||||
const handle = await vanillaServer.startServerAndWait(version || CURRENT_VERSION, 1000 * 120, { 'server-port': port })
|
||||
|
||||
console.log('Started dump server', version)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue