Skip to content
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

Merged
merged 4 commits into from
Mar 17, 2024

Conversation

wgaylord
Copy link
Contributor

@wgaylord wgaylord commented Mar 7, 2024

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.

module.exports = function (client, options) {
client.on('disconnect', message => {
if (!message.reason) { return }
if (client.state === states.PLAY | client.state === states.CONFIGURATION) { return }
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just documented it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

@@ -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 {
Copy link
Member

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?

Copy link
Contributor Author

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.
Copy link
Member

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 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I see #3325

@rom1504 rom1504 merged commit ccab9fb into PrismarineJS:master Mar 17, 2024
24 checks passed
PR Triage automation moved this from Needs triage to Closed Mar 17, 2024
@wgaylord wgaylord mentioned this pull request May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
PR Triage
  
Closed
Development

Successfully merging this pull request may close these issues.

None yet

3 participants