Class PermissionManager

java.lang.Object
com.github.darksoulq.abyssallib.server.permission.PermissionManager

public class PermissionManager extends Object
The central authority for managing permissions within AbyssalLib.

This manager handles player join/quit cycles, synchronizes internal permission states with the Bukkit engine, and manages persistent storage operations.

  • Constructor Details

    • PermissionManager

      public PermissionManager(org.bukkit.plugin.Plugin plugin, PermissionStorage storage)
      Constructs a new PermissionManager and initializes storage systems.
      Parameters:
      plugin - The owning plugin.
      storage - The storage backend to use.
  • Method Details

    • getStorage

      public PermissionStorage getStorage()
      Gets the storage implementation.
      Returns:
      The current PermissionStorage.
    • isValidNode

      public static boolean isValidNode(String node)
      Validates if a permission string is a valid or recognized node.
      Parameters:
      node - The permission string to validate.
      Returns:
      true if the node is valid, false otherwise.
    • getUser

      public PermissionUser getUser(UUID uuid)
      Retrieves a user from the cache or loads them from storage.
      Parameters:
      uuid - The UUID of the user.
      Returns:
      The PermissionUser instance.
    • getLoadedUser

      public PermissionUser getLoadedUser(UUID uuid)
      Retrieves a user from memory only.
      Parameters:
      uuid - The UUID of the user.
      Returns:
      The user, or null if not loaded.
    • getKnownUsers

      public Map<UUID,String> getKnownUsers()
      Gets all known users from the storage backend.
      Returns:
      A map of UUID to last known usernames.
    • getUuidFromName

      public UUID getUuidFromName(String name)
      Resolves a UUID from a username.
      Parameters:
      name - The username to resolve.
      Returns:
      The resolved UUID, or null if not found.
    • saveUser

      public void saveUser(PermissionUser user)
      Persists a user asynchronously.
      Parameters:
      user - The PermissionUser to save.
    • saveGroup

      public void saveGroup(PermissionGroup group)
      Persists a group asynchronously.
      Parameters:
      group - The PermissionGroup to save.
    • deleteGroup

      public void deleteGroup(String id)
      Deletes a group and removes it from all active holders.
      Parameters:
      id - The ID of the group to delete.
    • handleJoin

      public void handleJoin(org.bukkit.entity.Player player)
      Processes player join logic, updating names and syncing permissions.
      Parameters:
      player - The joining Player.
    • handleQuit

      public void handleQuit(org.bukkit.entity.Player player)
      Processes player quit logic, cleaning up memory and attachments.
      Parameters:
      player - The quitting Player.
    • updatePlayer

      public void updatePlayer(UUID uuid)
      Synchronizes internal permission states with the Bukkit engine for a player.
      Parameters:
      uuid - The UUID of the player.
    • invalidateAllUsers

      public void invalidateAllUsers()
      Invalidates the calculated permission cache for all loaded users.
    • shutdown

      public void shutdown()
      Performs a graceful shutdown, saving all data synchronously.