Interface Node

All Known Subinterfaces:
ChatMetaNode<N,B>, DisplayNameNode, InheritanceNode, MetaNode, PermissionNode, PrefixNode, RegexPermissionNode, ScopedNode<N,B>, SuffixNode, WeightNode

@NonExtendable public interface Node
Represents a LuckPerms "node".

The Node class encapsulates more than just permission assignments. Nodes are used to store data about inherited groups, as well as assigned prefixes, suffixes and meta values.

Combining these various states into one object (a "node") means that a holder only has to have one type of data set (a set of nodes) in order to take on various properties.

It is recommended that users of the API make use of Streams to manipulate data and obtain the required information.

This interface provides a number of methods to read the attributes of the node, as well as methods to query and extract additional state and properties from these settings.

Nodes have the following 4 key attributes:

  • key - the key of the node
  • value - the value of the node (false for negated)
  • context - the contexts required for this node to apply
  • expiry - the time when this node should expire

These are the key attributes which are considered when evaluating node equality.

Nodes can also optionally have metadata attached to them, added during construction using NodeBuilder.withMetadata(NodeMetadataKey, Object), and queried using metadata(NodeMetadataKey) and getMetadata(NodeMetadataKey). Such metadata is never considered when evaluating equals(Object) or equals(Node, NodeEqualityPredicate) (any form of equality check).

There are a number of node types, all of which extend from this class:

The core node state must be immutable in all implementations.

  • Method Details

    • builder

      static @NonNull NodeBuilder<?,?> builder(@NonNull String key)
      Gets a NodeBuilder for the given node key.
      Parameters:
      key - the key
      Returns:
      the node builder
    • getType

      @NonNull NodeType<?> getType()
      Gets the type of the node.
      Returns:
      the node type
    • getKey

      @NonNull String getKey()
      Gets the key (String) of the node.
      Returns:
      the key
    • getValue

      boolean getValue()
      Gets the value of the node.

      A negated setting would result in a value of false.

      Returns:
      the nodes value
    • isNegated

      default boolean isNegated()
      Gets if the node is negated.

      This is the inverse of the value.

      Returns:
      true if the node is negated
    • resolveShorthand

      Resolves any shorthand parts of this node and returns the full list of resolved nodes.

      The list will not contain the exact permission itself.

      Returns:
      a list of full nodes
    • hasExpiry

      boolean hasExpiry()
      Gets if this node is assigned temporarily.
      Returns:
      true if this node will expire in the future
    • getExpiry

      @Nullable Instant getExpiry()
      Gets the time when this node will expire.
      Returns:
      the Instant when this node will expire, or null if it doesn't have an expiry time
    • hasExpired

      boolean hasExpired()
      Gets if the node has expired.

      This returns false if the node is not temporary.

      Returns:
      true if this node has expired
    • getExpiryDuration

      @Nullable Duration getExpiryDuration()
      Gets the time until this node will expire.

      Returns null if the node doesn't have an expiry time, and a negative duration if it has already expired.

      Returns:
      the duration until the nodes expiry
      Since:
      5.1
    • getContexts

      Gets the contexts required for this node to apply.
      Returns:
      the contexts required for this node to apply
    • getMetadata

      <T> Optional<T> getMetadata(@NonNull NodeMetadataKey<T> key)
      Gets the metadata corresponding to the given key, if present.
      Type Parameters:
      T - the metadata type
      Parameters:
      key - the key
      Returns:
      the data, if present
    • metadata

      default <T> T metadata(@NonNull NodeMetadataKey<T> key) throws IllegalStateException
      Gets the metadata corresponding to the given key, throwing an exception if no data is present.
      Type Parameters:
      T - the metadata type
      Parameters:
      key - the key
      Returns:
      the data
      Throws:
      IllegalStateException - if data isn't present
    • equals

      boolean equals(Object obj)
      Gets if this Node is equal to another node.
      Overrides:
      equals in class Object
      Parameters:
      obj - the other node
      Returns:
      true if this node is equal to the other provided
      See Also:
    • equals

      boolean equals(@NonNull Node other, @NonNull NodeEqualityPredicate equalityPredicate)
      Gets if this Node is equal to another node as defined by the given NodeEqualityPredicate.
      Parameters:
      other - the other node
      equalityPredicate - the predicate
      Returns:
      true if this node is considered equal
    • toBuilder

      @NonNull NodeBuilder<?,?> toBuilder()
      Gets a NodeBuilder, with the attributes of this node already applied.
      Returns:
      an editable, builder form of this node