Interface PermissionHandler

All Known Subinterfaces:
CommandSender
All Known Implementing Classes:
ConsoleSender, Entity, EntityCreature, EntityProjectile, ExperienceOrb, ItemEntity, LivingEntity, Player, PlayerProjectile, ServerSender

public interface PermissionHandler
Represents an object which can have permissions.

Permissions are in-memory only by default. You have however the capacity to store them persistently as the Permission object is serializer-friendly, Permission.getPermissionName() being a String and Permission.getNBTData() serializable into a string using NBTCompound.toSNBT() and deserialized back with SNBTParser.parse().

  • Method Details

    • getAllPermissions

      @NotNull @NotNull Set<Permission> getAllPermissions()
      Returns all permissions associated to this handler. The returned collection should be modified only by subclasses.
      Returns:
      the permissions of this handler.
    • addPermission

      default void addPermission(@NotNull @NotNull Permission permission)
      Adds a Permission to this handler.
      Parameters:
      permission - the permission to add
    • removePermission

      default void removePermission(@NotNull @NotNull Permission permission)
      Removes a Permission from this handler.
      Parameters:
      permission - the permission to remove
    • removePermission

      default void removePermission(@NotNull @NotNull String permissionName)
      Removes a Permission based on its string identifier.
      Parameters:
      permissionName - the permission name
    • hasPermission

      default boolean hasPermission(@NotNull @NotNull Permission permission)
      Gets if this handler has the permission permission. This method will also pattern match for wildcards. For example, if this handler has the permission "*", this method will always return true. However, if this handler has the permission "foo.b*r.baz", this method will return true if permission is "foo.baaar.baz" or "foo.br.baz, but not "foo.bar.bz".

      Uses Permission.equals(Object) internally.

      Parameters:
      permission - the permission to check
      Returns:
      true if the handler has the permission, false otherwise
    • getPermission

      @Nullable default @Nullable Permission getPermission(@NotNull @NotNull String permissionName)
      Gets the Permission with the name permissionName.

      Useful if you want to retrieve the permission data.

      Parameters:
      permissionName - the permission name
      Returns:
      the permission from its name, null if not found
    • hasPermission

      default boolean hasPermission(@NotNull @NotNull String permissionName, @Nullable @Nullable PermissionVerifier permissionVerifier)
      Gets if this handler has the permission with the name permissionName and which verify the optional PermissionVerifier.
      Parameters:
      permissionName - the permission name
      permissionVerifier - the optional verifier, null means that only the permission name will be used
      Returns:
      true if the handler has the permission, false otherwise
    • hasPermission

      default boolean hasPermission(@NotNull @NotNull String permissionName)
      Gets if this handler has the permission with the name permissionName.
      Parameters:
      permissionName - the permission name
      Returns:
      true if the handler has the permission, false otherwise