Class PermissionValidator
- All Implemented Interfaces:
CommandValidator
As of 7.0, the Brigadier tree uses requires for class-level permissions and operator
requirements, and on exclusive mapping paths for method-level requirements. The tree hides
nodes a sender cannot use; shared prefixes remain available to their public mappings. Framework
usage replies omit unavailable mappings, including mappings ending at a shared node.
Visibility is not a replacement for this validator. A reachable execution still checks its actual sender and current permissions here, including console and panel senders, redirected execution, shared nodes, and case-normalized re-dispatch. Both permission and operator checks remain live rather than being captured when the command tree is registered.
In 6.x, visibility used Bukkit's PluginCommand#setPermission; that registration path
and BaseCommandExecutor.onCommand no longer exist.
- Since:
- 6.2.0
- Version:
- 2.0.0
- Author:
- wisdomme
-
Nested Class Summary
Nested classes/interfaces inherited from interface CommandValidator
CommandValidator.ValidationResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate static final intprivate final boolean -
Constructor Summary
ConstructorsConstructorDescriptionCreates a permission validator with no base permission requirement.PermissionValidator(String permission, boolean requireOp) Creates a permission validator with the specified permission. -
Method Summary
Modifier and TypeMethodDescriptionstatic PermissionValidatorfromAnnotation(CmdExecutor annotation) Creates a validator from a CmdExecutor annotation.getName()Gets the name of this validator for debugging and logging purposes.intgetOrder()Gets the order of this validator.validate(CommandContext context) Validates the command context.private static CommandValidator.ValidationResultvalidateMethodPermission(CommandContext context, Method method) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CommandValidator
onComplete, onRefused, shouldValidate
-
Field Details
-
ORDER
private static final int ORDER- See Also:
-
basePermission
-
requireOp
private final boolean requireOp
-
-
Constructor Details
-
PermissionValidator
public PermissionValidator()Creates a permission validator with no base permission requirement. -
PermissionValidator
Creates a permission validator with the specified permission.- Parameters:
permission- the required permissionrequireOp- whether OP is required
-
-
Method Details
-
validate
Description copied from interface:CommandValidatorValidates the command context.- Specified by:
validatein interfaceCommandValidator- Parameters:
context- the command context to validate- Returns:
- the validation result
-
validateMethodPermission
private static CommandValidator.ValidationResult validateMethodPermission(CommandContext context, Method method) -
getOrder
public int getOrder()Description copied from interface:CommandValidatorGets the order of this validator. Lower values are executed first.- Specified by:
getOrderin interfaceCommandValidator- Returns:
- the order value
-
getName
Description copied from interface:CommandValidatorGets the name of this validator for debugging and logging purposes.- Specified by:
getNamein interfaceCommandValidator- Returns:
- the validator name
-
fromAnnotation
Creates a validator from a CmdExecutor annotation.- Parameters:
annotation- the annotation- Returns:
- a new validator
-