-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix handling of disconnect in versionChecking on 1.20.3+. #1291
Conversation
… newer translate string used in 1.20.2+
src/client/versionChecking.js
Outdated
module.exports = function (client, options) { | ||
client.on('disconnect', message => { | ||
if (!message.reason) { return } | ||
if (client.state === states.PLAY | client.state === states.CONFIGURATION) { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment here explaining why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just documented it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why use bitwise or here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, didn't realize that was bitwise or.
src/client/versionChecking.js
Outdated
@@ -11,7 +14,7 @@ module.exports = function (client, options) { | |||
let text = parsed.text ? parsed.text : parsed | |||
let versionRequired | |||
|
|||
if (text.translate && text.translate.startsWith('multiplayer.disconnect.outdated_')) { versionRequired = text.with[0] } else { | |||
if (text.translate && (text.translate.startsWith('multiplayer.disconnect.outdated_') | text.translate.startsWith('multiplayer.disconnect.incompatible'))) { versionRequired = text.with[0] } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you un-inline this if statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just un-inlined the if. Not sure why it was inlined to begin with.
module.exports = function (client, options) { | ||
client.on('disconnect', message => { | ||
if (!message.reason) { return } | ||
// Prevent the disconnect packet handler in the versionChecking code from triggering on PLAY or CONFIGURATION state disconnects | ||
// Since version checking only happens during that HANDSHAKE / LOGIN state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we want to handle this also in PLAY or CONFIGURATION states ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I see #3325
This fixes the versionChecking code catching disconnects from states other then Handshake and Login, which cause errors on 1.20.3+ where NBT chat is used for the Play and Configuration state.
Since version checking only occurs in Handshake / Login state its best not to do anything when those other states occur.
This also includes a fix for the translate string having changed for when you have a version miss match.