Interface CommandValidator
- All Known Implementing Classes:
CooldownValidator,PermissionValidator,SenderTypeValidator,UsageLockValidator
public interface CommandValidator
Interface for command validation following the Chain of Responsibility pattern.
Validators are executed in order and can stop the chain by returning a failed result.
遵循责任链模式的命令验证接口。 验证器按顺序执行,可以通过返回失败结果来停止链。
- Since:
- 6.2.0
- Version:
- 2.0.0
- Author:
- wisdomme
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classResult of a validation operation. -
Method Summary
Modifier and TypeMethodDescriptiondefault StringgetName()Gets the name of this validator for debugging and logging purposes.default intgetOrder()Gets the order of this validator.default booleanshouldValidate(CommandContext context) Checks if this validator should be applied to the given context.validate(CommandContext context) Validates the command context.
-
Method Details
-
validate
Validates the command context. 验证命令上下文。- Parameters:
context- the command context to validate- Returns:
- the validation result
-
getOrder
default int getOrder()Gets the order of this validator. Lower values are executed first. 获取此验证器的顺序。较低的值优先执行。- Returns:
- the order value
-
shouldValidate
Checks if this validator should be applied to the given context. 检查此验证器是否应应用于给定的上下文。- Parameters:
context- the command context- Returns:
- true if this validator should be applied
-
getName
Gets the name of this validator for debugging and logging purposes. 获取此验证器的名称,用于调试和日志记录。- Returns:
- the validator name
-