Repository navigation
feat(permissions): publish the player's rank so something can draw it - #26
Merged
Merged
Conversation
service-permissions has always sent prefix, color and sortOrder alongside the permission patterns, and this plugin has always fetched and cached every field of them -- including onto disk. Nothing has ever read them, so a rank is invisible everywhere a player looks: chat, the tab list, /online. SnapshotRoleQuery registers a PlayerRoleQuery into the ProxyServiceRegistry, answering out of the in-memory snapshot this plugin already keeps current. A consumer asks the registry instead of growing a permissions client of its own, and a player with no snapshot is null rather than a wait. Highest role = lowest sortOrder, ties broken on key. Not the first entry: everyone carries the default `user` on top of whatever else they hold, and the service returns roles in no particular order, so "first" would colour an admin as a normal player whenever `user` happened to come back first. The tie-break exists so a name does not change colour depending on which proxy you are on. Unregistered on shutdown -- a query left behind would keep colouring names out of whatever was cached when the plugin stopped.
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.
A rank is invisible everywhere a player looks — chat, the tab list,
/online— and itis not for want of data.
service-permissionshas always sentprefix,colorandsortOrderalongside thepermission patterns. This plugin has always fetched them, parsed them, cached them in
memory and written them to disk. Nothing has ever read them. Here is a live snapshot
from stage:
What this adds
SnapshotRoleQueryregisters aPlayerRoleQuery(groundsgg/plugin-proxy#23) into theProxyServiceRegistry, answering out of the in-memory snapshot this plugin already keepscurrent. Consumers ask the registry rather than growing a permissions client of their
own, and a player with no snapshot is
nullrather than a wait — so a caller degrades todrawing the name plainly.
Highest role = lowest sortOrder, ties on key
Not the first entry. Everyone carries the default
useron top of whatever else theyhold, and the service returns roles in no particular order — so "first" would colour an
admin as a normal player whenever
userhappened to come back first. That is the bugthis ordering exists to prevent, and it has a test.
The tie-break on
keyis so two roles sharing asortOrderresolve identically on everyproxy. A name that changes colour depending on which proxy you are on reads as a bug;
stable-but-arbitrary beats unstable.
Blank
prefix/colorare treated as absent — blank is what an unset field looks likeafter a form round-trip, and a caller checking for null would otherwise paint with
"".Lifecycle
Unregistered on shutdown. A query left behind would keep colouring names out of whatever
was cached when the plugin stopped.
Depends on
plugin-proxy-api0.7.0, released —compileOnly, never shaded, so the registry isthe class plugin-proxy loaded rather than a private copy nobody writes to.
Still needed for the colour to appear
The tab list consumes this already. Chat does not:
ChatLine.of(senderName: String, …)has no colour parameter, and the receiving proxy has no snapshot for a player on another
proxy — so the colour has to travel in the chat payload. That is a plugin-chat change,
landing separately.
Verification
./gradlew buildgreen — 6 new tests inSnapshotRoleQueryTest, spotless clean.