Skip to content

feat(permissions): publish the player's rank so something can draw it - #26

Merged
hbrombeer merged 1 commit into
mainfrom
feat/publish-role-query
Aug 2, 2026
Merged

hbrombeer merged 1 commit into
mainfrom
feat/publish-role-query

Conversation

@hbrombeer

Copy link
Copy Markdown
Member

A rank is invisible everywhere a player looks — chat, the tab list, /online — and it
is not for want of data.

service-permissions has always sent prefix, color and sortOrder alongside the
permission 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:

"roleKeys": ["user","administrator"],
"roleMetadata": [
  {"key":"user",          "prefix":"[User]",  "color": null,     "sortOrder":20},
  {"key":"administrator", "prefix":"[Admin]", "color":"#f9a49a", "sortOrder":0}
]

What this adds

SnapshotRoleQuery registers a PlayerRoleQuery (groundsgg/plugin-proxy#23) into the
ProxyServiceRegistry, answering out of the in-memory snapshot this plugin already keeps
current. Consumers ask the registry rather than growing a permissions client of their
own, and a player with no snapshot is null rather than a wait — so a caller degrades to
drawing the name plainly.

Highest role = lowest sortOrder, ties 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. That is the bug
this ordering exists to prevent, and it has a test.

The tie-break on key is so two roles sharing a sortOrder resolve identically on every
proxy. A name that changes colour depending on which proxy you are on reads as a bug;
stable-but-arbitrary beats unstable.

Blank prefix/color are treated as absent — blank is what an unset field looks like
after 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-api 0.7.0, released — compileOnly, never shaded, so the registry is
the 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 build green — 6 new tests in SnapshotRoleQueryTest, spotless clean.

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.
@hbrombeer
hbrombeer merged commit 217f0f6 into main Aug 2, 2026
2 checks passed
@hbrombeer
hbrombeer deleted the feat/publish-role-query branch August 2, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant