Interface PermissionEntity
- All Known Subinterfaces:
PermissionGroup,PermissionUser
ru.tehkode.permissions API.
Concrete implementations ship in permissionsex-core (AbstractPermissionEntity,
PermissionUser, PermissionGroup).
Frozen public contract. Baseline commit 628215f. Do not extend this
interface with new methods — use the modern API for new features.
World scope
A null world name denotes the global (common) scope: permissions, options,
prefix/suffix, and parent groups assigned for all worlds unless overridden by world-specific data.
Direct (getOwn*) vs effective (get*)
Methods prefixed with getOwn return values stored directly on this entity only.
Methods without Own resolve effective values by traversing parent groups and
world inheritance (see PermissionManager.getWorldInheritance(String)).
Non-inheritable permissions
Permissions prefixed with NON_INHERITABLE_PREFIX ("#") are not propagated
to child subjects through inheritance.
Timed permissions
Temporary grants are tracked separately from persisted permissions. A lifetime of
PermissionManager.TRANSIENT_PERMISSION (0) means the grant is held in memory only
and is not written to the backend.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumKind of permission subject represented by this entity. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringPrefix ("#") marking a permission expression as non-inheritable by child groups or users. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPermission(String permission) Adds a permission expression in global scope (worldName == null).voidaddPermission(String permission, String worldName) Adds a permission expression to this entity for the given world, placing it at highest precedence.voidaddTimedPermission(String permission, String world, int lifeTime) Grants a timed permission on this entity for the given world.voidClears in-memory caches for this entity (resolved permissions, inheritance, and related derived state).booleanexplainExpression(String expression) Interprets a permission expression as grant or deny.Returns all directly stored options keyed by world name.Returns direct parent groups keyed by world name.Returns all permission lists keyed by world name.Returns the stable backend identifier for this entity (UUID string for users, group name for groups).getMatchingExpression(String permission, String world) Finds the highest-precedence permission expression that matches the requested node in the given world.getMatchingExpression(List<String> permissions, String permission) Finds the first expression in the supplied list that matches the requested permission node.getName()Returns the display name for this entity.Returns the effective value of an option in global scope.Returns the effective value of an option for the given world.Returns the effective string value of an option, traversing parent groups when not set locally.booleangetOptionBoolean(String optionName, String world, boolean defaultValue) Returns the effective boolean value of an option for the given world.doublegetOptionDouble(String optionName, String world, double defaultValue) Returns the effective double value of an option for the given world.intgetOptionInteger(String optionName, String world, int defaultValue) Returns the effective integer value of an option for the given world.Returns all options stored directly on this entity in global scope.getOptions(String world) Returns all options stored directly on this entity for the given world.getOwnOption(String option) Returns the value of an option stored directly on this entity in global scope.getOwnOption(String option, String world) Returns the value of an option stored directly on this entity for the given world.getOwnOption(String option, String world, String defaultValue) Returns the value of an option stored directly on this entity for the given world.booleangetOwnOptionBoolean(String optionName, String world, boolean defaultValue) Returns the boolean value of an option stored directly on this entity.doublegetOwnOptionDouble(String optionName, String world, double defaultValue) Returns the double value of an option stored directly on this entity.intgetOwnOptionInteger(String optionName, String world, int defaultValue) Returns the integer value of an option stored directly on this entity.Returns identifiers of parent groups assigned directly to this entity in global scope.getOwnParentIdentifiers(String world) Returns identifiers of parent groups assigned directly to this entity for the given world.Returns parent groups assigned directly to this entity in global scope.getOwnParents(String world) Returns parent groups assigned directly to this entity for the given world.getOwnPermissions(String world) Returns permission expressions assigned directly to this entity for the given world.Returns the prefix stored directly on this entity in the global scope.getOwnPrefix(String worldName) Returns the prefix stored directly on this entity for the given world.Returns the suffix stored directly on this entity in the global scope.getOwnSuffix(String worldName) Returns the suffix stored directly on this entity for the given world.Returns identifiers of all parent groups in the effective inheritance chain in global scope.getParentIdentifiers(String world) Returns identifiers of all parent groups in the effective inheritance chain for the given world.Returns all parent groups that contribute to effective inheritance in global scope.getParents(String world) Returns all parent groups that contribute to this entity's effective inheritance for the given world.Returns thePermissionManagerthat owns and resolves this entity.Returns effective permission expressions in the global scope.getPermissions(String world) Returns the effective permission expressions for the given world, including inherited and timed grants.Returns the effective chat prefix in the global scope, including inheritance from parent groups.Returns the effective chat prefix for the given world, including inheritance from parent groups and world inheritance.Returns the effective chat suffix in the global scope, including inheritance from parent groups.Returns the effective chat suffix for the given world, including inheritance from parent groups and world inheritance.intgetTimedPermissionLifetime(String permission, String world) Returns remaining lifetime in seconds for a timed permission on this entity.getTimedPermissions(String world) Returns timed (temporary) permission expressions active for the given world on this entity.getType()Returns whether this entity represents a user or a group.Returns world names for which this entity has stored permissions, options, or parent assignments.booleanChecks whether this entity effectively holds the given permission in the default world context.booleanChecks whether this entity effectively holds the given permission in the specified world.voidCompletes post-construction initialization for this entity.booleanisDebug()Returns whether debug logging is enabled for this entity or its manager.booleanTests whether a permission expression matches a concrete permission node.booleanReturns whether this entity exists only in memory and has not yet been persisted.voidremove()Deletes this entity from the backend and clears associated in-memory state.voidremovePermission(String permission) Removes the given permission expression from every world where this entity defines permissions.voidremovePermission(String permission, String worldName) Removes a permission expression (and any matching timed grant) from this entity for the given world.voidremoveTimedPermission(String permission, String world) Revokes a timed permission from this entity for the given world.voidsave()Persists in-memory changes for this entity to the active backend.voidsetDebug(boolean debug) Enables or disables debug logging for this entity only.voidSets an option value in global scope.voidSets an option value stored directly on this entity for the given world.voidsetParents(List<PermissionGroup> parents) Replaces the direct parent group list in global scope.voidsetParents(List<PermissionGroup> parents, String world) Replaces the direct parent group list for the given world.voidsetParentsIdentifier(List<String> parentNames) Replaces the direct parent group identifiers in global scope.voidsetParentsIdentifier(List<String> parentNames, String world) Replaces the direct parent group identifiers for the given world.voidsetPermissions(List<String> permission) Replaces the direct permission list in global scope.voidsetPermissions(List<String> permissions, String world) Replaces the direct permission list for the given world.voidSets the chat prefix stored directly on this entity for the given world.voidSets the chat suffix stored directly on this entity for the given world.
-
Field Details
-
NON_INHERITABLE_PREFIX
Prefix ("#") marking a permission expression as non-inheritable by child groups or users.When a permission starts with this character, descendants do not receive it through group inheritance (see
getPermissions(String)vsgetOwnPermissions(String)).- See Also:
-
-
Method Details
-
clearCache
void clearCache()Clears in-memory caches for this entity (resolved permissions, inheritance, and related derived state).Implementations invoke this after mutating permissions, options, or parent groups so subsequent
get*calls recompute effective values. -
initialize
void initialize()Completes post-construction initialization for this entity.Called by the owning
PermissionManagerafter the entity and its backing data are fully constructed. Typically loads debug flags and other derived state from stored options. -
getPermissionManager
PermissionManager getPermissionManager()Returns thePermissionManagerthat owns and resolves this entity.- Returns:
- the permission manager instance
-
getIdentifier
String getIdentifier()Returns the stable backend identifier for this entity (UUID string for users, group name for groups).- Returns:
- entity identifier; never
nullfor a live instance
-
getName
String getName()Returns the display name for this entity.May differ from
getIdentifier()when anameoption is set; otherwise falls back to the identifier.- Returns:
- display name
-
getType
PermissionEntity.Type getType()Returns whether this entity represents a user or a group. -
getOwnPrefix
String getOwnPrefix()Returns the prefix stored directly on this entity in the global scope.Does not traverse parent groups. Returns
nullor empty when no own prefix is set.- Returns:
- direct prefix, or
null/empty if unset - See Also:
-
getOwnPrefix
Returns the prefix stored directly on this entity for the given world.worldName == nullselects the global scope. Does not traverse parent groups.- Parameters:
worldName- world name, ornullfor global scope- Returns:
- direct prefix, or
null/empty if unset - See Also:
-
getOwnSuffix
String getOwnSuffix()Returns the suffix stored directly on this entity in the global scope.Does not traverse parent groups. Returns
nullor empty when no own suffix is set.- Returns:
- direct suffix, or
null/empty if unset - See Also:
-
getOwnSuffix
Returns the suffix stored directly on this entity for the given world.worldName == nullselects the global scope. Does not traverse parent groups.- Parameters:
worldName- world name, ornullfor global scope- Returns:
- direct suffix, or
null/empty if unset - See Also:
-
getPrefix
String getPrefix()Returns the effective chat prefix in the global scope, including inheritance from parent groups.- Returns:
- resolved prefix, or empty string when none is defined
- See Also:
-
getPrefix
Returns the effective chat prefix for the given world, including inheritance from parent groups and world inheritance.worldName == nullselects the global scope.- Parameters:
worldName- world name, ornullfor global scope- Returns:
- resolved prefix, or empty string when none is defined
- See Also:
-
setPrefix
Sets the chat prefix stored directly on this entity for the given world.worldName == nullstores the prefix in global scope. Clears entity cache after update.- Parameters:
prefix- new prefix valueworldName- world name, ornullfor global scope
-
getSuffix
Returns the effective chat suffix for the given world, including inheritance from parent groups and world inheritance.worldName == nullselects the global scope.- Parameters:
worldName- world name, ornullfor global scope- Returns:
- resolved suffix, or empty string when none is defined
- See Also:
-
getSuffix
String getSuffix()Returns the effective chat suffix in the global scope, including inheritance from parent groups.- Returns:
- resolved suffix, or empty string when none is defined
- See Also:
-
setSuffix
Sets the chat suffix stored directly on this entity for the given world.worldName == nullstores the suffix in global scope. Clears entity cache after update.- Parameters:
suffix- new suffix valueworldName- world name, ornullfor global scope
-
has
Checks whether this entity effectively holds the given permission in the default world context.Equivalent to
has(String, String)with a server-default world name when worlds exist, or global scope (null) otherwise.- Parameters:
permission- permission node to check- Returns:
trueif the permission is granted,falseotherwise
-
has
Checks whether this entity effectively holds the given permission in the specified world.Resolves inheritance, timed permissions, negated nodes (
-node), andnon-inheritableexpressions.world == nulluses global scope.- Parameters:
permission- permission node to checkworld- world name, ornullfor global scope- Returns:
trueif the permission is granted,falseotherwise
-
getPermissions
Returns the effective permission expressions for the given world, including inherited and timed grants.world == nullselects global scope. Order reflects precedence for matching (seegetMatchingExpression(String, String)).- Parameters:
world- world name, ornullfor global scope- Returns:
- unmodifiable list of effective permission expressions
- See Also:
-
getPermissions
Returns effective permission expressions in the global scope.- Returns:
- unmodifiable list of effective permission expressions
- See Also:
-
getOwnPermissions
Returns permission expressions assigned directly to this entity for the given world.Does not include inherited parent-group permissions or timed grants.
world == nullselects global scope.- Parameters:
world- world name, ornullfor global scope- Returns:
- unmodifiable list of directly assigned permission expressions
- See Also:
-
getAllPermissions
Returns all permission lists keyed by world name.Global-scope permissions are stored under a
nullkey. Timed permissions for each world are merged into the corresponding entry.- Returns:
- unmodifiable map of world name to permission expression list
-
addPermission
Adds a permission expression to this entity for the given world, placing it at highest precedence.If the expression already exists for that world, it is moved to the front of the list.
worldName == nullselects global scope.- Parameters:
permission- permission expression to addworldName- world name, ornullfor global scope
-
addPermission
Adds a permission expression in global scope (worldName == null).- Parameters:
permission- permission expression to add- See Also:
-
removePermission
Removes a permission expression (and any matching timed grant) from this entity for the given world.- Parameters:
permission- permission expression to removeworldName- world name, ornullfor global scope
-
removePermission
Removes the given permission expression from every world where this entity defines permissions.- Parameters:
permission- permission expression to remove
-
setPermissions
Replaces the direct permission list for the given world.world == nullselects global scope. Clears entity cache after update.- Parameters:
permissions- new permission expression listworld- world name, ornullfor global scope
-
setPermissions
Replaces the direct permission list in global scope.- Parameters:
permission- new permission expression list- See Also:
-
getOption
Returns the effective string value of an option, traversing parent groups when not set locally.- Parameters:
option- option nameworld- world name, ornullfor global scopedefaultValue- value returned when the option is unset after inheritance resolution- Returns:
- resolved option value, or
defaultValueif absent - See Also:
-
getOption
Returns the effective value of an option in global scope.- Parameters:
option- option name- Returns:
- resolved option value, or
nullif unset - See Also:
-
getOption
Returns the effective value of an option for the given world.- Parameters:
option- option nameworld- world name, ornullfor global scope- Returns:
- resolved option value, or
nullif unset - See Also:
-
getOptionInteger
Returns the effective integer value of an option for the given world.- Parameters:
optionName- option nameworld- world name, ornullfor global scopedefaultValue- value returned when the option is unset or not parseable as an integer- Returns:
- parsed integer option value, or
defaultValue
-
getOptionDouble
Returns the effective double value of an option for the given world.- Parameters:
optionName- option nameworld- world name, ornullfor global scopedefaultValue- value returned when the option is unset or not parseable as a double- Returns:
- parsed double option value, or
defaultValue
-
getOptionBoolean
Returns the effective boolean value of an option for the given world.- Parameters:
optionName- option nameworld- world name, ornullfor global scopedefaultValue- value returned when the option is unset or not"true"/"false"- Returns:
- parsed boolean option value, or
defaultValue
-
setOption
Sets an option value stored directly on this entity for the given world.Pass
nullasvalueto remove the option.world == nullselects global scope.- Parameters:
option- option namevalue- option value, ornullto removeworld- world name, ornullfor global scope
-
setOption
Sets an option value in global scope.- Parameters:
option- option namevalue- option value, ornullto remove- See Also:
-
getOptions
Returns all options stored directly on this entity for the given world.Does not merge inherited parent options.
world == nullselects global scope.- Parameters:
world- world name, ornullfor global scope- Returns:
- map of option name to value
-
getOptions
Returns all options stored directly on this entity in global scope.- Returns:
- map of option name to value
- See Also:
-
getAllOptions
Returns all directly stored options keyed by world name.Global-scope options are stored under a
nullkey.- Returns:
- map of world name to option map
-
getOwnOption
Returns the value of an option stored directly on this entity for the given world.Does not traverse parent groups.
world == nullselects global scope.- Parameters:
option- option nameworld- world name, ornullfor global scopedefaultValue- value returned when the option is not set on this entity- Returns:
- direct option value, or
defaultValueif absent - See Also:
-
getOwnOption
Returns the value of an option stored directly on this entity in global scope.- Parameters:
option- option name- Returns:
- direct option value, or
nullif unset - See Also:
-
getOwnOption
Returns the value of an option stored directly on this entity for the given world.- Parameters:
option- option nameworld- world name, ornullfor global scope- Returns:
- direct option value, or
nullif unset - See Also:
-
getOwnOptionInteger
Returns the integer value of an option stored directly on this entity.- Parameters:
optionName- option nameworld- world name, ornullfor global scopedefaultValue- value returned when unset or not parseable- Returns:
- parsed integer, or
defaultValue - See Also:
-
getOwnOptionBoolean
Returns the boolean value of an option stored directly on this entity.- Parameters:
optionName- option nameworld- world name, ornullfor global scopedefaultValue- value returned when unset or not"true"/"false"- Returns:
- parsed boolean, or
defaultValue - See Also:
-
getOwnOptionDouble
Returns the double value of an option stored directly on this entity.- Parameters:
optionName- option nameworld- world name, ornullfor global scopedefaultValue- value returned when unset or not parseable- Returns:
- parsed double, or
defaultValue - See Also:
-
save
void save()Persists in-memory changes for this entity to the active backend.Clears entity cache after a successful save.
-
remove
void remove()Deletes this entity from the backend and clears associated in-memory state. -
isVirtual
boolean isVirtual()Returns whether this entity exists only in memory and has not yet been persisted.- Returns:
trueif virtual (not yet saved),falseif backed by storage
-
getWorlds
Returns world names for which this entity has stored permissions, options, or parent assignments.- Returns:
- set of world names (may be empty)
-
getTimedPermissions
Returns timed (temporary) permission expressions active for the given world on this entity.world == nullselects global scope. Does not include inherited timed grants from parents.- Parameters:
world- world name, ornullfor global scope- Returns:
- unmodifiable list of timed permission expressions
-
getTimedPermissionLifetime
Returns remaining lifetime in seconds for a timed permission on this entity.world == nullselects global scope. Returns0when the permission is transient (PermissionManager.TRANSIENT_PERMISSION) or not timed.- Parameters:
permission- permission expressionworld- world name, ornullfor global scope- Returns:
- seconds remaining, or
0if not timed or already expired
-
addTimedPermission
Grants a timed permission on this entity for the given world.world == nullselects global scope.lifeTimeis in seconds; passPermissionManager.TRANSIENT_PERMISSION(0) for a non-persisted in-memory grant that survives until reload.- Parameters:
permission- permission expression to grantworld- world name, ornullfor global scopelifeTime- lifetime in seconds, or0for transient
-
removeTimedPermission
Revokes a timed permission from this entity for the given world.- Parameters:
permission- permission expression to revokeworld- world name, ornullfor global scope
-
getMatchingExpression
Finds the highest-precedence permission expression that matches the requested node in the given world.Uses the entity's effective permission list for
world(seegetPermissions(String)).- Parameters:
permission- permission node to matchworld- world name, ornullfor global scope- Returns:
- winning expression, or
nullif none matches
-
getMatchingExpression
Finds the first expression in the supplied list that matches the requested permission node.- Parameters:
permissions- ordered list of permission expressions to searchpermission- permission node to match- Returns:
- winning expression, or
nullif none matches
-
isMatches
Tests whether a permission expression matches a concrete permission node.- Parameters:
expression- stored permission expression (may include wildcards or regex)permission- permission node being checkedadditionalChecks- whentrue, enables parent-node matching semantics in the matcher- Returns:
trueif the expression matches the node
-
explainExpression
Interprets a permission expression as grant or deny.Expressions prefixed with
-are negations and yieldfalse; all other non-empty expressions yieldtrue.nullor empty expressions yieldfalse.- Parameters:
expression- permission expression to interpret- Returns:
trueif the expression grants access,falseif denied or absent
-
isDebug
boolean isDebug()Returns whether debug logging is enabled for this entity or its manager.- Returns:
trueif entity-level or manager-level debug is active
-
setDebug
void setDebug(boolean debug) Enables or disables debug logging for this entity only.Does not change manager-wide debug mode (see
PermissionManager.setDebug(boolean)).- Parameters:
debug-trueto enable entity debug output
-
getOwnParents
Returns parent groups assigned directly to this entity for the given world.Does not traverse the group hierarchy.
world == nullselects global scope.- Parameters:
world- world name, ornullfor global scope- Returns:
- unmodifiable list of directly assigned parent groups
- See Also:
-
getOwnParents
List<PermissionGroup> getOwnParents()Returns parent groups assigned directly to this entity in global scope.- Returns:
- unmodifiable list of directly assigned parent groups
- See Also:
-
getOwnParentIdentifiers
Returns identifiers of parent groups assigned directly to this entity for the given world.- Parameters:
world- world name, ornullfor global scope- Returns:
- unmodifiable list of parent group identifiers
- See Also:
-
getOwnParentIdentifiers
Returns identifiers of parent groups assigned directly to this entity in global scope.- Returns:
- unmodifiable list of parent group identifiers
- See Also:
-
getParents
Returns all parent groups that contribute to this entity's effective inheritance for the given world.Includes ancestors reachable through the group hierarchy.
world == nullselects global scope.- Parameters:
world- world name, ornullfor global scope- Returns:
- unmodifiable list of resolved parent groups
- See Also:
-
getParents
List<PermissionGroup> getParents()Returns all parent groups that contribute to effective inheritance in global scope.- Returns:
- unmodifiable list of resolved parent groups
- See Also:
-
getParentIdentifiers
Returns identifiers of all parent groups in the effective inheritance chain for the given world.- Parameters:
world- world name, ornullfor global scope- Returns:
- unmodifiable list of parent group identifiers
- See Also:
-
getParentIdentifiers
Returns identifiers of all parent groups in the effective inheritance chain in global scope.- Returns:
- unmodifiable list of parent group identifiers
- See Also:
-
getAllParents
Map<String,List<PermissionGroup>> getAllParents()Returns direct parent groups keyed by world name.Global-scope parents are stored under a
nullkey. Values are direct assignments only (seegetOwnParents(String)), not fully resolved inheritance chains.- Returns:
- unmodifiable map of world name to parent group list
-
setParents
Replaces the direct parent group list for the given world.- Parameters:
parents- new parent groupsworld- world name, ornullfor global scope
-
setParents
Replaces the direct parent group list in global scope.- Parameters:
parents- new parent groups- See Also:
-
setParentsIdentifier
Replaces the direct parent group identifiers for the given world.- Parameters:
parentNames- parent group identifiersworld- world name, ornullfor global scope
-
setParentsIdentifier
Replaces the direct parent group identifiers in global scope.- Parameters:
parentNames- parent group identifiers- See Also:
-