Interface PermissionHolder

All Known Subinterfaces:
Group, User

public interface PermissionHolder
Generic superinterface for an object which holds permissions.
  • Method Details

    • getIdentifier

      Gets the identifier of the holder.
      Returns:
      the identifier
    • getFriendlyName

      @NonNull String getFriendlyName()
      Gets a friendly name for this holder, to be displayed in command output, etc.

      This will always return a value, eventually falling back to PermissionHolder.Identifier.getName() if no other "friendlier" identifiers are present.

      For Users, this method will attempt to return the username, before falling back to PermissionHolder.Identifier.getName().

      For Groups, this method will attempt to return the groups display name, before falling back to PermissionHolder.Identifier.getName().

      Returns:
      a friendly identifier for this holder
    • getQueryOptions

      @NonNull QueryOptions getQueryOptions()
      Gets the most appropriate query options available at the time for the PermissionHolder.

      For Users, the most appropriate query options will be their current active query options if the corresponding player is online, and otherwise, will fallback to the current static query options if they are offline.

      For Groups, the most appropriate query options will always be ContextManager.getStaticQueryOptions() the current static query options.

      Returns:
      query options
      Since:
      5.1
    • getCachedData

      @NonNull CachedDataManager getCachedData()
      Gets the holders CachedDataManager cache.
      Returns:
      the holders cached data.
    • getData

      @NonNull NodeMap getData(@NonNull DataType dataType)
      Gets the NodeMap of a particular type.
      Parameters:
      dataType - the data type
      Returns:
      the data
    • data

      Gets the holders DataType.NORMAL data.
      Returns:
      the normal data
    • transientData

      @NonNull NodeMap transientData()
      Gets the holders DataType.TRANSIENT data.

      Transient permissions only exist for the duration of the session.

      A transient node is a permission that does not persist. Whenever a user logs out of the server, or the server restarts, this permission will disappear. It is never saved to the datastore, and therefore will not apply on other servers.

      This is useful if you want to temporarily set a permission for a user while they're online, but don't want it to persist, and have to worry about removing it when they log out.

      Returns:
      the transient data
    • getNodes

      default @NonNull @Unmodifiable Collection<Node> getNodes()
      Gets a flattened view of the holders own Nodes.

      This list is constructed using the values of both the normal and transient backing node maps.

      It may contain duplicate entries if the same node is added to both the normal and transient node maps. You can use getDistinctNodes() for a view without duplicates.

      This method does not resolve inheritance rules.

      Returns:
      a collection of the holders own nodes.
    • getNodes

      default <T extends Node> @NonNull @Unmodifiable Collection<T> getNodes(@NonNull NodeType<T> type)
      Gets a flattened view of the holders own Nodes of the given type.
      Type Parameters:
      T - the node type
      Parameters:
      type - the type of node to filter by
      Returns:
      a filtered collection of the holders own nodes
      Since:
      5.1
      See Also:
    • getDistinctNodes

      @NonNull @Unmodifiable SortedSet<Node> getDistinctNodes()
      Gets a flattened and sorted view of the holders own distinct Nodes.

      Effectively a sorted version of getNodes(), without duplicates. Use the aforementioned method if you don't require either of these attributes.

      This method does not resolve inheritance rules.

      Returns:
      a sorted set of the holders own distinct nodes
    • resolveInheritedNodes

      @NonNull @Unmodifiable Collection<Node> resolveInheritedNodes(@NonNull QueryOptions queryOptions)
      Gets a resolved view of the holders own and inherited Nodes.

      The returned list will contain every inherited node the holder has, in the order that they were inherited in.

      This means the list will contain duplicates.

      Inheritance is performed according to the platforms rules, and the order will vary depending on the accumulation order. By default, the holders own nodes are first in the list, with the entries from the end of the inheritance tree appearing last.

      Parameters:
      queryOptions - the query options
      Returns:
      a list of the holders inherited nodes
    • resolveInheritedNodes

      default <T extends Node> @NonNull @Unmodifiable Collection<T> resolveInheritedNodes(@NonNull NodeType<T> type, @NonNull QueryOptions queryOptions)
      Gets a resolved view of the holders own and inherited Nodes of a given type.
      Type Parameters:
      T - the node type
      Parameters:
      type - the type of node to filter by
      queryOptions - the query options
      Returns:
      a filtered list of the holders inherited nodes
      Since:
      5.1
      See Also:
    • resolveDistinctInheritedNodes

      @NonNull @Unmodifiable SortedSet<Node> resolveDistinctInheritedNodes(@NonNull QueryOptions queryOptions)
      Gets a resolved and sorted view of the holders own and inherited distinct Nodes.

      Effectively a sorted version of resolveInheritedNodes(QueryOptions), without duplicates. Use the aforementioned method if you don't require either of these attributes.

      Inheritance is performed according to the platforms rules, and the order will vary depending on the accumulation order. By default, the holders own nodes are first in the list, with the entries from the end of the inheritance tree appearing last.

      Parameters:
      queryOptions - the query options
      Returns:
      a sorted set of the holders distinct inherited nodes
    • getInheritedGroups

      @NonNull @Unmodifiable Collection<Group> getInheritedGroups(@NonNull QueryOptions queryOptions)
      Gets a collection of the Groups this holder inherits nodes from.

      If Flag.RESOLVE_INHERITANCE is set, this will include holders inherited from both directly and indirectly (through directly inherited groups). It will effectively resolve the whole "inheritance tree".

      If Flag.RESOLVE_INHERITANCE is not set, then the traversal will only go one level up the inheritance tree, and return only directly inherited groups.

      The collection will be ordered according to the platforms inheritance rules. The groups which are inherited from first will appear earlier in the list.

      The list will not contain the holder.

      Parameters:
      queryOptions - the query options
      Returns:
      a collection of the groups the holder inherits from
      Since:
      5.1
    • auditTemporaryNodes

      void auditTemporaryNodes()
      Removes any temporary permissions that have expired.

      This method is called periodically by the platform, so it is only necessary to run if you want to guarantee that the current data is totally up-to-date.