Package dev.polv.taleapi.permission
Interface PermissionHolder
- All Known Subinterfaces:
TalePlayer
public interface PermissionHolder
Interface for entities that can have permissions.
This interface provides convenience methods for permission checking
on entities like players. It wraps calls to the PermissionService.
Example Usage
// On any PermissionHolder (like TalePlayer)
if (player.hasPermission("cmd.teleport")) {
// Execute teleport
}
// Get a dynamic limit
int maxHomes = player.getPermissionValue("homes.limit").asInt(3);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault PermissionResultgetPermissionValue(String permission) Queries a permission and returns the full result.default PermissionResultgetPermissionValue(String permission, ContextSet context) Queries a permission with context and returns the full result.Returns the unique identifier for this holder.default booleanhasPermission(String permission) Checks if this holder has the specified permission.default booleanhasPermission(String permission, ContextSet context) Checks if this holder has the specified permission in a context.
-
Method Details
-
getUniqueId
String getUniqueId()Returns the unique identifier for this holder.This is used to look up permissions in the permission system.
- Returns:
- the unique identifier
-
hasPermission
Checks if this holder has the specified permission.This is a convenience method equivalent to:
PermissionService.getInstance().query(this, permission).isAllowed()- Parameters:
permission- the permission key to check- Returns:
trueif the permission is ALLOW
-
hasPermission
Checks if this holder has the specified permission in a context.- Parameters:
permission- the permission keycontext- the context to check in- Returns:
trueif the permission is ALLOW in the given context
-
getPermissionValue
Queries a permission and returns the full result.Use this when you need the payload value or tristate:
int maxPlots = holder.getPermissionValue("plots.limit").asInt(1);- Parameters:
permission- the permission key- Returns:
- the permission result
-
getPermissionValue
Queries a permission with context and returns the full result.- Parameters:
permission- the permission keycontext- the context to check in- Returns:
- the permission result
-