Interface PermissionSubject
- All Known Subinterfaces:
CommandSource, Player
public interface PermissionSubject
Represents an object that can have permissions.
This interface is implemented by Player
and CommandSource to provide
a unified permission checking API.
Permission Checking
Permissions are checked through a PermissionFunction which can be
provided by external plugins like LuckPerms. The function returns a Tristate
value:
Tristate.TRUE- Permission explicitly grantedTristate.FALSE- Permission explicitly deniedTristate.UNDEFINED- Not set, uses default behavior
Example Usage
if (player.hasPermission("numdrassl.command.server")) {
// Execute command
}
// For more control:
Tristate state = player.getPermissionValue("some.permission");
if (state == Tristate.TRUE) {
// Explicitly granted
} else if (state == Tristate.FALSE) {
// Explicitly denied
} else {
// Undefined - use default
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGets the permission function for this subject.getPermissionValue(String permission) Gets the tristate permission value for the given permission.default booleanhasPermission(String permission) Checks if this subject has the given permission.voidsetPermissionFunction(PermissionFunction function) Sets a new permission function for this subject.
-
Method Details
-
getPermissionValue
-
hasPermission
Checks if this subject has the given permission.This is a convenience method that converts the
Tristateresult to a boolean.Tristate.UNDEFINEDis treated as the default value (typically false for players, true for console).- Parameters:
permission- the permission to check- Returns:
- true if the subject has the permission
-
getPermissionFunction
Gets the permission function for this subject.The permission function is used to resolve all permission checks. It may be provided by an external permission plugin.
- Returns:
- the permission function
-
setPermissionFunction
Sets a new permission function for this subject.This is typically called by permission plugins to install their permission checking logic.
- Parameters:
function- the new permission function
-