Interface PermissionSubject

All Known Subinterfaces:
CommandSource, Player

public interface PermissionSubject
Represents an object that can have permissions.

This interface is implemented by Player and CommandSource to provide a unified permission checking API.

Permission Checking

Permissions are checked through a PermissionFunction which can be provided by external plugins like LuckPerms. The function returns a Tristate value:

Example Usage

if (player.hasPermission("numdrassl.command.server")) {
    // Execute command
}

// For more control:
Tristate state = player.getPermissionValue("some.permission");
if (state == Tristate.TRUE) {
    // Explicitly granted
} else if (state == Tristate.FALSE) {
    // Explicitly denied
} else {
    // Undefined - use default
}
See Also:
  • Method Details

    • getPermissionValue

      @Nonnull Tristate getPermissionValue(@Nonnull String permission)
      Gets the tristate permission value for the given permission.

      This method returns the raw permission value without any default behavior applied.

      Parameters:
      permission - the permission to check
      Returns:
      the tristate value
    • hasPermission

      default boolean hasPermission(@Nonnull String permission)
      Checks if this subject has the given permission.

      This is a convenience method that converts the Tristate result to a boolean. Tristate.UNDEFINED is treated as the default value (typically false for players, true for console).

      Parameters:
      permission - the permission to check
      Returns:
      true if the subject has the permission
    • getPermissionFunction

      @Nonnull PermissionFunction getPermissionFunction()
      Gets the permission function for this subject.

      The permission function is used to resolve all permission checks. It may be provided by an external permission plugin.

      Returns:
      the permission function
    • setPermissionFunction

      void setPermissionFunction(@Nonnull PermissionFunction function)
      Sets a new permission function for this subject.

      This is typically called by permission plugins to install their permission checking logic.

      Parameters:
      function - the new permission function