Better support for multiple tablist add/remove - #1872
Open
pop4959 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The Minecraft protocol supports adding/removing multiple entries from the tab list in a single packet (see Player Info Update and Player Info Remove).
Currently, while Velocity does have an
addEntriesmethod on itsTabList, the method currently processes each entry individually regardless of what entries are being updated.Velocity/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java
Lines 53 to 57 in a078053
There are no subclasses of
TabListwhich override this default behavior, meaning each individual tab list entry sends a separate packet, which is undesirable.Similarly,
removeEntryexists, but in this case there are no correspondingremoveEntriesmethods, even though removing multiple entries is also supported (and trivial).This PR attempts to address this by refactoring the existing code from
addEntrytoaddEntriesinVelocityTabList, whereaddEntriesnow handles batching tab list modifications into the least number of packets possible. It is not possible (to my knowledge, I'm happy to be corrected) to combine modifications that contain varying length player actions, as a restriction imposed by the protocol, since the actions must prefix the list of entries being updated. As a result, the existingaddEntrymethod can simply delegate toaddEntriespassing only one entry. TheremoveEntriesimplementation is pretty straightforward, my goal there was simply to mirror the same kinds of overloads asaddEntrieshas, and keep the same behavior of returning all of the removedTabListEntryinstances.