Fix client sending chat_session packet before server state transition (#1081)

* Fix client sending session packet when server is in offline mode

* Don't send chat session packet before server is in play state

* Fix lint

---------

Co-authored-by: Frej Alexander Nielsen <frej@valoks.com>
This commit is contained in:
Frej Alexander Nielsen 2023-02-19 23:59:18 +01:00 committed by GitHub
parent 45ea82a7dc
commit 90d4143358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,15 +11,10 @@ module.exports = function (client, options) {
}
})
client.once('success', onLogin)
const mcData = require('minecraft-data')(client.version)
function onLogin (packet) {
const mcData = require('minecraft-data')(client.version)
client.state = states.PLAY
client.uuid = packet.uuid
client.username = packet.username
if (mcData.supportFeature('useChatSessions') && client.profileKeys && client._cipher) {
client.once('login', () => {
if (mcData.supportFeature('useChatSessions') && client.profileKeys && client.cipher) {
client._session = {
index: 0,
uuid: uuid.v4fast()
@ -32,6 +27,14 @@ module.exports = function (client, options) {
signature: client.profileKeys ? client.profileKeys.signatureV2 : undefined
})
}
})
client.once('success', onLogin)
function onLogin (packet) {
client.state = states.PLAY
client.uuid = packet.uuid
client.username = packet.username
if (mcData.supportFeature('signedChat')) {
if (options.disableChatSigning && client.serverFeatures.enforcesSecureChat) {