Class PermissionControl

java.lang.Object
nl.pim16aap2.lightkeeper.framework.PermissionControl

public final class PermissionControl extends Object
Handle for mutating and querying a synthetic player's permissions.

Honesty contract: grant(java.lang.String), revoke(java.lang.String), and unset(java.lang.String) mutate LightKeeper's own PermissionAttachment on the synthetic player. This bypasses permission plugins such as LuckPerms — the mutation is real as far as Bukkit's permission resolution is concerned, but no permission plugin observes it. For permission-plugin-realistic tests, drive the plugin itself instead (e.g. console lp user ... permission set ... commands).

has(String) is a live query: every call asks the server for the player's current hasPermission result, which reflects all permission sources (attachments, permission plugins, defaults, and OP status) — not just LightKeeper's own attachment.

  • Method Details

    • grant

      public PermissionControl grant(String permission)
      Grants a permission node by setting it to true on the player's attachment.
      Parameters:
      permission - The permission node to grant.
      Returns:
      This handle for fluent chaining.
    • revoke

      public PermissionControl revoke(String permission)
      Revokes a permission node by setting it to false on the player's attachment.

      Unlike unset(String), this overrides the node's default and any grant on LightKeeper's own attachment. Grants applied by other attachments (e.g. a permission plugin's) may still win, depending on Bukkit's attachment resolution order.

      Parameters:
      permission - The permission node to revoke.
      Returns:
      This handle for fluent chaining.
    • unset

      public PermissionControl unset(String permission)
      Removes a permission node from the player's attachment, restoring the player's default for that node.

      A no-op when the node was never granted or revoked through this handle (or at spawn time).

      Parameters:
      permission - The permission node to remove from the attachment.
      Returns:
      This handle for fluent chaining.
    • has

      public boolean has(String permission)
      Queries the live value of a permission node for this player.
      Parameters:
      permission - The permission node to query.
      Returns:
      The player's current hasPermission result on the server.