mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-23 15:57:50 -05:00
Ensure onReady
in client is called once
Fix https://github.com/PrismarineJS/node-minecraft-protocol/issues/1286 Server sending start_config packets will incorrectly cause onReady to call multiple times
This commit is contained in:
parent
092e10c53d
commit
9350bddd9b
1 changed files with 4 additions and 4 deletions
|
@ -37,15 +37,15 @@ module.exports = function (client, options) {
|
|||
|
||||
if (mcData.supportFeature('hasConfigurationState')) {
|
||||
client.write('login_acknowledged', {})
|
||||
enterConfigState()
|
||||
enterConfigState(onReady)
|
||||
// Server can tell client to re-enter config state
|
||||
client.on('start_configuration', enterConfigState)
|
||||
client.on('start_configuration', () => enterConfigState())
|
||||
} else {
|
||||
client.state = states.PLAY
|
||||
onReady()
|
||||
}
|
||||
|
||||
function enterConfigState () {
|
||||
function enterConfigState (finishCb) {
|
||||
if (client.state === states.CONFIGURATION) return
|
||||
// If we are returning to the configuration state from the play state, we ahve to acknowledge it.
|
||||
if (client.state === states.PLAY) {
|
||||
|
@ -57,7 +57,7 @@ module.exports = function (client, options) {
|
|||
client.once('finish_configuration', () => {
|
||||
client.write('finish_configuration', {})
|
||||
client.state = states.PLAY
|
||||
onReady()
|
||||
finishCb?.()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue