Files
Frej Alexander NielsenandRomain Beaumont cf1f67117d Update to 1.19.3 (#1069)
* Add 1.19.3 player_info parsing

* player_remove packet parsing

* 1.19.3 chat parsing

* Outgoing chat for 1.19.3

* Fix lint

* Server chat validation

* add 1.19.2 and 1.19.3 in version.js

* Add 1.19.2 and 1.19.3 in ci.yml

* Deprecated client.verifyMessage for server clients

* Update docs

* Deprecate client.verifyMessage for server clients

* Fix tests

* Fix lint

* Fix packetTest

* Fix test

* Remove unneeded log statement

* Update types/docs

* Remove unnecessary feature check

* Remove _session from docs

Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
2023-01-21 20:31:17 +01:00

45 lines
1.5 KiB
JavaScript

'use strict'
const states = require('../states')
module.exports = function (client, options) {
client.on('connect', onConnect)
function onConnect () {
if (client.wait_connect) {
client.on('connect_allowed', next)
} else {
next()
}
function next () {
const mcData = require('minecraft-data')(client.version)
let taggedHost = options.host
if (client.tagHost) taggedHost += client.tagHost
if (options.fakeHost) taggedHost = options.fakeHost
client.write('set_protocol', {
protocolVersion: options.protocolVersion,
serverHost: taggedHost,
serverPort: options.port,
nextState: 2
})
client.state = states.LOGIN
client.write('login_start', {
username: client.username,
signature: (client.profileKeys && !mcData.supportFeature('useChatSessions'))
? {
timestamp: BigInt(client.profileKeys.expiresOn.getTime()), // should probably be called "expireTime"
// Remove padding on the public key: not needed in vanilla server but matches how vanilla client looks
publicKey: client.profileKeys.public.export({ type: 'spki', format: 'der' }),
signature: mcData.supportFeature('profileKeySignatureV2')
? client.profileKeys.signatureV2
: client.profileKeys.signature
}
: null,
playerUUID: client.session?.selectedProfile?.id
})
}
}
}