Fix players disconnecting when updating boss bars #1656
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On 1.20.2, the Minecraft client started clearing boss bars after the login packet, which meant that the ProxyServer#showBossbar API would result in the player getting kicked if the boss bar they were previously shown was updated after switching servers.
Therefore, I have added BossBarManager which drops boss bar packets once the client enters the configure phase to ensure that they do not disconnect (if the client receives boss bar packets during the configure phase it seems to queue them up and then immediately disconnect at the end of the configure phase, leaving no opportunity to re-send the boss bar creation packet), and then re-adds the boss bar once the client logs in.
This ensures that clients do not receive boss bar updates for boss bars that they don't exist causing them to disconnect. I have also taken care to ensure that this logic only applies on 1.20.2 and up, as it is not necessary for older clients.
In addition, I removed boss bar tracking for backend servers for 1.20.2 and up clients - as it is no longer necessary for them to be manually removed due to the aforementioned change.
Fixes #1529