Skip to content

server: allow the permission level a client displays for itself to be set - #1431

Open
xRookieFight wants to merge 5 commits into
df-mc:masterfrom
xRookieFight:permission-level
Open

server: allow the permission level a client displays for itself to be set#1431
xRookieFight wants to merge 5 commits into
df-mc:masterfrom
xRookieFight:permission-level

Conversation

@xRookieFight

Copy link
Copy Markdown

No description provided.

@schphe

schphe commented Aug 16, 2026

Copy link
Copy Markdown
Contributor
func (p *Player) SetPermissionLevel(level session.PermissionLevel) {

I believe this shouldn't be exposing the session package
that aside, I wonder if the naming is a bit misleading,
as it could be perceived as granting permission at first glance

@xRookieFight

Copy link
Copy Markdown
Author

It's PermissionLevel on the official protocol docs, however I can rename it as ClientPermissionLevel or something if it is misleading.

@cjmustard

Copy link
Copy Markdown
Collaborator

@HashimTheArab @didntpot @RestartFU is this the best way to do this?

@cjmustard

Copy link
Copy Markdown
Collaborator

Should PermissionLevel be included in Data() as well? Since Config.Apply() now reads it back into the player, it seems like a level set with SetPermissionLevel() would be lost when the player data is saved/reloaded.

@cjmustard

Copy link
Copy Markdown
Collaborator

One other small thing I noticed: StartGame still always sends PlayerPermissions as PermissionLevelMember in server.go. Should that initial value use the configured permission level too, or is it expected to be corrected later by UpdateAbilities?

@xRookieFight

xRookieFight commented Aug 25, 2026

Copy link
Copy Markdown
Author

@schphe - exposing session in the public API: moved the type out of session into a new server/player/permission package, matching the existing player/hud, player/input, player/skin pattern (small leaf packages that both player and session can import). It now reads p.SetPermissionLevel(permission.Operator()), and session only consumes it through Controllable.

On the naming: I kept PermissionLevel since that is what the protocol field is called, and the doc comment on permission.Level states explicitly that it only changes what the client displays and allows locally - cmd.Allower is still the only thing deciding whether a command may be run. Happy to rename it if you still find it misleading.

@cjmustard - Data(): good catch, it was missing. Added PermissionLevel: p.permission so a level set with SetPermissionLevel() survives a save/reload round trip.

@cjmustard - StartGame: it is now taken from the loaded player data in finaliseConn:

data.PlayerPermissions, _ = d.PermissionLevel.Permissions()

UpdateAbilities would have corrected it shortly after anyway, but sending the right value up front avoids the client briefly rendering itself as a member.

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.

4 participants