java.lang.Object
me.github.simonplays15.betterbansystem.core.permissions.PermissionsManager
Direct Known Subclasses:
BungeeCordDefaultHandler, CloudNetPermissionsHandler, LuckPermsManager, SpigotPermissionsHandler, VaultPermissionsSystem

public abstract class PermissionsManager extends Object
The PermissionsManager class is an abstract class that provides a base implementation for managing permissions. It contains methods for retrieving and checking permissions for different players and handlers.
  • Field Details

    • handlerType

      public PermissionsHandlerType handlerType
      The handlerType field represents the type of permissions handler used by the PermissionsManager class.

      The PermissionsHandlerType enum is used to identify and select the appropriate handler for managing permissions in the system. The handlerType field is an instance of the PermissionsHandlerType enum, which allows the system to identify and select the appropriate permissions handler.

      The available types of permissions handlers are defined in the PermissionsHandlerType enum, which includes SPIGOT, LUCKPERMS, BUNGEECORD, CLOUDNET, and VAULT. The DEFAULT_PERMISSION_HANDLING type is also available as a fallback option.

      Example usage:

       PermissionsManager manager = new PermissionsManager(PermissionsHandlerType.SPIGOT);
       PermissionsHandlerType type = manager.getHandlerType();
       if (type == PermissionsHandlerType.SPIGOT) {
           // SPIGOT handler code
       } else if (type == PermissionsHandlerType.LUCKPERMS) {
           // LUCKPERMS handler code
       } else if (type == PermissionsHandlerType.BUNGEECORD) {
           // BUNGEECORD handler code
       } else if (type == PermissionsHandlerType.CLOUDNET) {
           // CLOUDNET handler code
       } else if (type == PermissionsHandlerType.VAULT) {
           // VAULT handler code
       } else if (type == PermissionsHandlerType.DEFAULT_PERMISSION_HANDLING) {
           // DEFAULT_PERMISSION_HANDLING handler code
       }
       

      For more information about each permissions handler type, refer to the documentation of the PermissionsHandlerType enum.

      See Also:
  • Constructor Details

    • PermissionsManager

      @Contract(pure=true) public PermissionsManager (PermissionsHandlerType handlerType)
      The PermissionsManager class is responsible for managing permissions in the system. It uses different types of permissions handlers, defined by the PermissionsHandlerType enum, to perform various operations such as checking if a player has a permission.

      The PermissionsHandlerType enum represents the available types of permissions handlers. Each type is used to identify and select the appropriate handler for managing permissions.

      See Also:
  • Method Details

    • getHandler

      @NotNull public static @NotNull PermissionsManager getHandler (@NotNull @NotNull PermissionsHandlerType type) throws PermissionManagerLoadException
      Returns the PermissionsManager instance for the specified PermissionsHandlerType.
      Parameters:
      type - The type of permissions handler. Must not be null.
      Returns:
      The PermissionsManager instance for the specified type.
      Throws:
      PermissionManagerLoadException - if there is an error loading the PermissionsManager.
    • getAvailableManager

      @NotNull public static @NotNull PermissionsManager getAvailableManager()
      Retrieves the available PermissionsManager instance based on the available types. If a suitable handler cannot be found, a default handler is returned based on the runtime environment.
      Returns:
      The available PermissionsManager instance
      Throws:
      PermissionManagerLoadException - If there is an error loading the PermissionManager
    • hasPermission

      public abstract boolean hasPermission (String playername, String permission)
      This method checks if the specified player has the given permission.
      Parameters:
      playername - The name of the player.
      permission - The permission to check.
      Returns:
      True if the player has the permission, false otherwise.
    • toString

      public String toString()
      Returns a string representation of the PermissionsManager object.

      This method overrides the toString() method from the Object class.

      The string representation of the PermissionsManager object is "PermissionsManager{}".

      Overrides:
      toString in class Object
      Returns:
      a string representation of the PermissionsManager object