public interface 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 attributes:
permission - the actual permission stringvalue - the value of the node (false for negated)override - if the node is marked as having special priority over other nodesserver - the specific server where this node should applyworld - the specific world where this node should applycontext - the additional contexts required for this node to apply expiry - the time when this node should expireThe 'permission' property of a Node is also used in some cases to represent state
beyond a granted permission. This state is encapsulated by extra NodeType data which
can be obtained from this instance using getTypeData(NodeTypeKey).
Type data is mapped by NodeTypeKeys, which are usually stored as static members of the
corresponding NodeType class under the KEY field.
The current types are:
InheritanceType - an "inheritance node" marks that the holder should inherit data from another groupPrefixType - represents an assigned prefixSuffixType - represents an assigned suffixMetaType - represents an assigned meta optionWeightType - marks the weight of the object holding this nodeDisplayNameType - marks the display name of the object holding this nodeThe core node state must be immutable in all implementations.
for obtaining and constructing instances.| Modifier and Type | Interface and Description |
|---|---|
static interface |
Node.Builder
Builds a Node instance
|
| Modifier and Type | Method and Description |
|---|---|
default boolean |
almostEquals(@NonNull Node other)
Deprecated.
in favour of
equals(Node, NodeEqualityPredicate) |
boolean |
appliesGlobally()
Gets if this node applies globally, and therefore has no specific context.
|
default boolean |
equals(Node other,
NodeEqualityPredicate equalityPredicate)
Gets if this Node is equal to another node as defined by the given
NodeEqualityPredicate. |
boolean |
equals(Object obj)
Gets if this Node is equal to another node.
|
default boolean |
equalsIgnoringValue(@NonNull Node other)
Deprecated.
in favour of
equals(Node, NodeEqualityPredicate) |
default boolean |
equalsIgnoringValueOrTemp(@NonNull Node other)
Deprecated.
in favour of
equals(Node, NodeEqualityPredicate) |
@NonNull ContextSet |
getContexts()
Gets the extra contexts required for this node to apply.
|
@NonNull Date |
getExpiry()
Gets the date when this node will expire.
|
long |
getExpiryUnixTime()
Gets the unix timestamp (in seconds) when this node will expire.
|
@NonNull ContextSet |
getFullContexts()
The same as
getContexts(), but also includes context pairs for
"server" and "world" keys if present. |
default @NonNull String |
getGroupName()
Gets the name of the inherited group if this node has
InheritanceType type data,
throwing an exception if the data is not present. |
default Map.Entry<String,String> |
getMeta()
Gets the meta entry if this node has
MetaType type data,
throwing an exception if the data is not present. |
@NonNull String |
getPermission()
Gets the permission string this node encapsulates.
|
default Map.Entry<Integer,String> |
getPrefix()
Gets the prefix entry if this node has
PrefixType type data,
throwing an exception if the data is not present. |
long |
getSecondsTilExpiry()
Gets the number of seconds until this permission will expire.
|
@NonNull Optional<String> |
getServer()
Gets the server this node applies on, if the node is server specific.
|
default Map.Entry<Integer,String> |
getSuffix()
Gets the suffix entry if this node has
SuffixType type data,
throwing an exception if the data is not present. |
default @NonNull Tristate |
getTristate()
Gets the value of this node as a
Tristate. |
<T extends NodeType> |
getTypeData(NodeTypeKey<T> key)
Gets the type data corresponding to the given
key, if present. |
boolean |
getValue()
Gets the value of the node.
|
int |
getWildcardLevel()
Gets the level of this wildcard.
|
@NonNull Optional<String> |
getWorld()
Gets the world this node applies on, if the node is world specific.
|
boolean |
hasExpired()
Gets if the node has expired.
|
boolean |
hasSpecificContext()
Gets if this node has any specific context in order for it to apply.
|
boolean |
hasTypeData()
Gets if this node has any extra
NodeType data attached to it. |
default boolean |
isGroupNode()
Gets if this node has
InheritanceType type data. |
default boolean |
isMeta()
Gets if this node has
MetaType type data. |
default boolean |
isNegated()
Gets if the node is negated.
|
boolean |
isOverride()
Gets if this node is set to override explicitly.
|
default boolean |
isPermanent()
Gets if this node is permanent (will not expire).
|
default boolean |
isPrefix()
Gets if this node has
PrefixType type data. |
boolean |
isServerSpecific()
Gets if this node is server specific.
|
default boolean |
isSuffix()
Gets if this node has
SuffixType type data. |
boolean |
isTemporary()
Gets if this node is assigned temporarily.
|
boolean |
isWildcard()
Gets if this node is a wildcard permission.
|
boolean |
isWorldSpecific()
Gets if this node is server specific.
|
@NonNull List<String> |
resolveShorthand()
Resolves any shorthand parts of this node and returns the full list of
resolved nodes.
|
boolean |
shouldApplyWithContext(@NonNull ContextSet contextSet)
Gets if this node should apply in the given context
|
boolean |
standardEquals(Node other,
StandardNodeEquality equalityPredicate)
Gets if this Node is equal to another node as defined by the given
StandardNodeEquality predicate. |
Node.Builder |
toBuilder()
Constructs a new builder initially containing the current properties of
this node.
|
default <T extends NodeType> |
typeData(NodeTypeKey<T> key)
Gets the type data corresponding to the given
key, throwing an exception
if no data is present. |
@NonNull String getPermission()
The exact value of this string may vary for nodes which aren't regular permission settings.
boolean getValue()
A negated setting would result in a value of false.
default @NonNull Tristate getTristate()
Tristate.default boolean isNegated()
This is the inverse of the value.
boolean isOverride()
This value does not persist across saves, and is therefore only useful for transient nodes.
@NonNull Optional<String> getServer()
Optional containing the server, if one is defined@NonNull Optional<String> getWorld()
Optional containing the world, if one is definedboolean isServerSpecific()
boolean isWorldSpecific()
boolean appliesGlobally()
boolean hasSpecificContext()
boolean shouldApplyWithContext(@NonNull ContextSet contextSet)
contextSet - the context set@NonNull List<String> resolveShorthand()
The list will not contain the exact permission itself.
boolean isTemporary()
default boolean isPermanent()
long getExpiryUnixTime()
throws IllegalStateException
IllegalStateException - if the node is not temporary@NonNull Date getExpiry() throws IllegalStateException
Date when this node will expireIllegalStateException - if the node is not temporarylong getSecondsTilExpiry()
throws IllegalStateException
Will return a negative value if the node has already expired.
IllegalStateException - if the node is not temporaryboolean hasExpired()
This returns false if the node is not temporary.
@NonNull ContextSet getContexts()
@NonNull ContextSet getFullContexts()
getContexts(), but also includes context pairs for
"server" and "world" keys if present.Contexts.SERVER_KEY,
Contexts.WORLD_KEYboolean isWildcard()
int getWildcardLevel()
throws IllegalStateException
The node luckperms.* has a wildcard level of 1.
The node luckperms.user.permission.* has a wildcard level of 3.
Nodes with a higher wildcard level are more specific and have priority over less specific nodes (nodes with a lower wildcard level).
IllegalStateException - if this is not a wildcardboolean hasTypeData()
NodeType data attached to it.<T extends NodeType> Optional<T> getTypeData(NodeTypeKey<T> key)
key, if present.T - the NodeType typekey - the keydefault <T extends NodeType> T typeData(NodeTypeKey<T> key) throws IllegalStateException
key, throwing an exception
if no data is present.T - the NodeType typekey - the keyIllegalStateException - if data isn't presentdefault boolean isGroupNode()
InheritanceType type data.default @NonNull String getGroupName() throws IllegalStateException
InheritanceType type data,
throwing an exception if the data is not present.IllegalStateException - if this node doesn't have InheritanceType datadefault boolean isMeta()
MetaType type data.default Map.Entry<String,String> getMeta() throws IllegalStateException
MetaType type data,
throwing an exception if the data is not present.IllegalStateException - if this node doesn't have MetaType datadefault boolean isPrefix()
PrefixType type data.default Map.Entry<Integer,String> getPrefix() throws IllegalStateException
PrefixType type data,
throwing an exception if the data is not present.IllegalStateException - if this node doesn't have PrefixType datadefault boolean isSuffix()
SuffixType type data.default Map.Entry<Integer,String> getSuffix() throws IllegalStateException
SuffixType type data,
throwing an exception if the data is not present.IllegalStateException - if this node doesn't have SuffixType databoolean equals(Object obj)
equals in class Objectobj - the other nodeStandardNodeEquality.EXACTboolean standardEquals(Node other, StandardNodeEquality equalityPredicate)
StandardNodeEquality predicate.other - the other nodeequalityPredicate - the predicatedefault boolean equals(Node other, NodeEqualityPredicate equalityPredicate)
NodeEqualityPredicate.other - the other nodeequalityPredicate - the predicate@Deprecated default boolean equalsIgnoringValue(@NonNull Node other)
equals(Node, NodeEqualityPredicate)equals(Object), except doesn't take note of the
value.other - the other nodeStandardNodeEquality.IGNORE_VALUE@Deprecated default boolean almostEquals(@NonNull Node other)
equals(Node, NodeEqualityPredicate)equals(Object), except doesn't take note of the
expiry time or value.other - the other nodeStandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE@Deprecated default boolean equalsIgnoringValueOrTemp(@NonNull Node other)
equals(Node, NodeEqualityPredicate)equals(Object), except doesn't take note of the
value or if the node is temporary.other - the other nodeStandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARYNode.Builder toBuilder()