Repository navigation
feat(velocity): show the network-wide player count - #43
Merged
Merged
Conversation
The server list showed only this proxy's players, so a player on one proxy saw a much smaller number than the network really had. The plugin now fetches the network count on connect and after every resync, keeps it up to date from network.players events, and shows the larger of that total and the local count in the ping. The maximum stays as Velocity has it. The SDK reads GET /v1/network and the network.players payload. An older controller that answers 404 is treated as "no count yet", so the proxy falls back to its local count instead of failing. Each backend server is pinged once after it is registered and the result is logged, which shows that the proxy can reach the server without a game client.
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.
Problem
Players see the online count in the server list when they add or refresh a server. With several proxies, each proxy only counted its own players, so the number people saw was far below what was actually online on the network.
Approach
The Velocity plugin now keeps a copy of the network-wide player count. It loads the count when it connects and after a resync, and updates it from the controller's
network.playersevents. When the server list is pinged, the plugin shows the larger of the network total and the proxy's own count. The maximum stays as Velocity reports it. If the controller does not offer the count yet (404 from an older controller), the proxy falls back to its own count and keeps working.The proxy's own player count was already reported to the controller, so no change was needed there.
To check that a proxy can reach its game servers without a client joining, the plugin now pings each backend server once after registering it and logs the result, either the version and player count or the reason it failed.
Testing
heavy ./gradlew --max-workers=2 :grus-sdk:test :grus-velocity:testpasses.Not covered here: the controller endpoint
GET /v1/networkand thenetwork.playersevent are not on main yet. Until they land, the plugin shows its own count as before.