Skip to content

feat(paper): add permissions runtime - #30

Merged
lusu007 merged 13 commits into
mainfrom
feat/paper-permissions
Aug 23, 2026
Merged

lusu007 merged 13 commits into
mainfrom
feat/paper-permissions

Conversation

@lusu007

@lusu007 lusu007 commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Description

Adds a Paper runtime for Grounds permission snapshots. It reuses the common REST client, resolver, cache, scheduled refresh and NATS invalidation lifecycle, fails closed during pre-login, and publishes the common Permissions service through Bukkit's ServicesManager.

For compatibility with ordinary Bukkit plugins, the runtime materializes every permission registered with Paper into one PermissionAttachment per online player. This makes normal player.hasPermission(...) checks use Grounds decisions, including explicit deny, wildcard matching and scoped precedence. Attachments are reapplied after refreshes, invalidations and plugin enable events, then removed on quit and shutdown. Nodes that are never registered with Bukkit remain available through the Grounds Permissions service because Paper exposes no stable hook for intercepting arbitrary unregistered checks.

The release data image preserves the Velocity artifact at /jar/plugin.jar and additionally publishes the shaded Paper artifact at /jar/paper.jar. Chat, tab-list and prefix formatting remain outside this plugin.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • ♻️ Refactoring
  • 📚 Documentation
  • 🔧 Chore

Related Issues

  • N/A

Testing

  • Unit tests pass
  • Manual testing completed
  • New tests added for new functionality

Commands and checks:

  • ./gradlew spotlessCheck check :paper:shadowJar
  • focused MockBukkit attachment integration test with --rerun-tasks
  • local authenticated Docker build
  • container smoke check proving non-empty /jar/plugin.jar and /jar/paper.jar

Checklist

  • I have performed a self-review of my own code
  • Tests have been added/updated and pass (if needed)
  • Documentation has been updated (if needed)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e1d8b6046

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +31 to +32
override fun onlinePlayerIds(): Set<UUID> =
plugin.server.onlinePlayers.mapTo(mutableSetOf()) { it.uniqueId }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep Bukkit player enumeration on the main thread

Both the asynchronous refresh task and the NATS subscriber call onlinePlayerIds(), so this method iterates Bukkit's live online-player collection off the server thread. A concurrent join or quit can make that view inconsistent or throw during a sweep/invalidation, skipping permission refreshes. Track UUIDs through main-thread join/quit events or capture the collection synchronously before doing the HTTP work asynchronously.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b65a73d and covered by 99f94e6/53c1802. The platform now seeds a ConcurrentHashMap-backed UUID set on the main-thread enable path, updates it from join/quit listeners, and returns immutable snapshots to refresh and NATS callers; those async paths no longer enumerate Bukkit onlinePlayers.

Comment on lines +235 to +236
environment["GROUNDS_PERMISSION_SERVER_TYPE"]?.takeIf(String::isNotBlank)
?: "paper",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not invent a Paper server type when none is configured

When the optional GROUNDS_PERMISSION_SERVER_TYPE variable is omitted, this sends serverType=paper with every snapshot request and uses the same literal value for local scope resolution. Server types represent workload scopes such as lobby or survival, not the implementation platform, so otherwise valid server-type grants are filtered out and fail permission checks on an ordinarily configured Paper server. Leave the value unset as Velocity does, or require/provide the server's actual logical type.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b65a73d and covered by 99f94e6. Omitted GROUNDS_PERMISSION_SERVER_TYPE now remains null, matching Velocity; an explicitly configured buildserver value is preserved.

@lusu007
lusu007 merged commit d67c452 into main Aug 23, 2026
3 checks passed
@lusu007
lusu007 deleted the feat/paper-permissions branch August 23, 2026 20:44
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