Class PermissionHolder

java.lang.Object
com.github.darksoulq.abyssallib.server.permission.PermissionHolder
Direct Known Subclasses:
PermissionGroup, PermissionUser

public abstract class PermissionHolder extends Object
An abstract base for objects that can hold permissions and inherit from parent nodes (typically groups).
  • Field Details

    • permissions

      public final Map<String,Node> permissions
      Map of permission keys to their respective Node data.
    • parents

      public final Map<String,Node> parents
      Map of parent group keys to their respective Node data.
  • Constructor Details

    • PermissionHolder

      public PermissionHolder()
  • Method Details

    • setPermission

      public void setPermission(Node node)
      Sets a permission node on this holder and invalidates the cache.
      Parameters:
      node - The Node to set.
    • unsetPermission

      public void unsetPermission(String key)
      Removes a permission node by its key.
      Parameters:
      key - The node key to remove.
    • addParent

      public void addParent(Node node)
      Adds a parent group to this holder via a Node.
      Parameters:
      node - The node representing group inheritance.
    • removeParent

      public void removeParent(String key)
      Removes a parent group by its key.
      Parameters:
      key - The key of the parent to remove.
    • hasDirectPermission

      public boolean hasDirectPermission(String key)
      Checks if this holder has a direct (non-inherited) permission set to true.
      Parameters:
      key - The permission key.
      Returns:
      True if directly set, not expired, and true.
    • hasParent

      public boolean hasParent(String key)
      Checks if this holder has a specific parent group assigned.
      Parameters:
      key - The group key.
      Returns:
      True if assigned and not expired.
    • getNodes

      public Collection<Node> getNodes()
      Returns:
      An unmodifiable collection of direct permission nodes.
    • getParentNodes

      public Collection<Node> getParentNodes()
      Returns:
      An unmodifiable collection of parent group nodes.
    • clearExpired

      public boolean clearExpired()
      Removes nodes and parents that have exceeded their expiry time.
      Returns:
      True if any entries were removed.
    • invalidateCache

      public void invalidateCache()
      Clears the effective permission cache and triggers custom invalidation logic.
    • save

      public abstract void save()
      Abstract hook for subclasses to handle data persistence.
    • getEffectivePermissions

      public Map<String,Boolean> getEffectivePermissions()
      Calculates and returns the map of all permissions active for this holder, including inherited ones.
      Returns:
      A map of active permission keys to their boolean values.