Basic Permissions
Use the@Permission annotation to require permissions for commands:
Permission Annotation
The@Permission annotation has several options:
Special Permission Values
Operator Permission
Require the sender to be a server operator:Console Only
Restrict commands to console only:Custom Permission Messages
Provide a custom message when permission is denied:Default Permission Message
Set a default permission message for all commands in the Blade configuration:Custom Permission Predicates
For advanced permission logic, you can create custom permission predicates. These are registered with an ID and can be referenced in the@Permission annotation using the @ prefix.
PermissionPredicate Interface
Creating a Custom Predicate
Here’s an example of a predicate that checks if a player is in a specific world:Registering Permission Predicates
Register your custom predicates in the Blade builder:Using Permission Predicates
Reference predicates in the@Permission annotation using the @ prefix:
Advanced Predicate Examples
Time-Based Permissions
Restrict commands to certain times of day:Combining Permissions
Create predicates that combine multiple conditions:Data-Based Permissions
Check against external data sources:Permission Predicate Behavior
- If a permission predicate is referenced but not registered, the command will be executed without any permission check
- Predicate IDs are case-insensitive
- You can combine predicates with regular permissions by using multiple
@Permissionannotations (though note that only one@Permissionannotation is supported per command)
Best Practices
- Use clear predicate names: Make predicate IDs descriptive (
"admin-in-survival"instead of"check1") - Handle null senders: Always check if the sender is the expected type before casting
- Return false for invalid senders: Don’t throw exceptions; just return
false - Keep predicates simple: Complex logic should be in separate classes
- Document your predicates: Comment what each predicate checks
Permission Checking in Code
You can manually check permissions using theBladeCommand object: