Package net.minestom.server.permission
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 Summary
Modifier and TypeMethodDescriptiondefault voidaddPermission(@NotNull Permission permission) Adds aPermissionto this handler.@NotNull Set<Permission> Returns all permissions associated to this handler.default @Nullable PermissiongetPermission(@NotNull String permissionName) Gets thePermissionwith the namepermissionName.default booleanhasPermission(@NotNull String permissionName) Gets if this handler has the permission with the namepermissionName.default booleanhasPermission(@NotNull String permissionName, @Nullable PermissionVerifier permissionVerifier) Gets if this handler has the permission with the namepermissionNameand which verify the optionalPermissionVerifier.default booleanhasPermission(@NotNull Permission permission) Gets if this handler has the permissionpermission.default voidremovePermission(@NotNull String permissionName) Removes aPermissionbased on its string identifier.default voidremovePermission(@NotNull Permission permission) Removes aPermissionfrom this handler.
-
Method Details
-
getAllPermissions
Returns all permissions associated to this handler. The returned collection should be modified only by subclasses.- Returns:
- the permissions of this handler.
-
addPermission
Adds aPermissionto this handler.- Parameters:
permission- the permission to add
-
removePermission
Removes aPermissionfrom this handler.- Parameters:
permission- the permission to remove
-
removePermission
Removes aPermissionbased on its string identifier.- Parameters:
permissionName- the permission name
-
hasPermission
Gets if this handler has the permissionpermission. 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 ifpermissionis"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
Gets thePermissionwith the namepermissionName.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 namepermissionNameand which verify the optionalPermissionVerifier.- Parameters:
permissionName- the permission namepermissionVerifier- the optional verifier, null means that only the permission name will be used- Returns:
- true if the handler has the permission, false otherwise
-
hasPermission
Gets if this handler has the permission with the namepermissionName.- Parameters:
permissionName- the permission name- Returns:
- true if the handler has the permission, false otherwise
-