Class PermissionValidator
java.lang.Object
com.ultikits.ultitools.abstracts.command.validation.validators.PermissionValidator
- All Implemented Interfaces:
CommandValidator
Validates that the command sender has the required permission.
Supports both class-level and method-level permission requirements.
验证命令发送者是否具有所需权限。 支持类级别和方法级别的权限要求。
- Since:
- 6.2.0
- Version:
- 2.0.0
- Author:
- wisdomme
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.ultikits.ultitools.abstracts.command.validation.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.ultikits.ultitools.abstracts.command.validation.CommandValidator
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
-
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. 从 CmdExecutor 注解创建验证器。- Parameters:
annotation- the annotation- Returns:
- a new validator
-