Interface PermissionResult


@Immutable @API(status=STABLE) public interface PermissionResult
The cached result of a permission check, representing whether a command may be executed.

Implementations must be immutable. Most importantly, allowed() must always return the same value as previous invocations.

Custom implementations may be used in order to provide more information. For example, the reason that the permission lookup returned false.

  • Method Details

    • allowed

      boolean allowed()
      Returns true if the command may be executed.

      This always returns the opposite of denied().

      Returns:
      true if the command may be executed
    • denied

      default boolean denied()
      Returns true if the command may not be executed.

      This always returns the opposite of allowed().

      Returns:
      true if the command may not be executed
    • permission

      @NonNull Permission permission()
      Returns the permission that this result came from.
      Returns:
      the permission that this result came from
    • of

      static @NonNull PermissionResult of(boolean result, @NonNull Permission permission)
      Creates a result that wraps the given boolean result.
      Parameters:
      result - true if the command may be executed, false otherwise
      permission - the permission that this result came from
      Returns:
      a PermissionResult of the boolean result
    • allowed

      static @NonNull PermissionResult allowed(@NonNull Permission permission)
      Creates a successful result for the given permission.
      Parameters:
      permission - the permission that this result came from
      Returns:
      a successful PermissionResult
    • denied

      static @NonNull PermissionResult denied(@NonNull Permission permission)
      Creates a failed result for the given permission.
      Parameters:
      permission - the permission that this result came from
      Returns:
      a failed PermissionResult