java.lang.Object
com.ultikits.ultitools.abstracts.command.validation.validators.PermissionValidator
All Implemented Interfaces:
CommandValidator

public class PermissionValidator extends Object implements 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
  • Field Details

    • ORDER

      private static final int ORDER
      See Also:
    • basePermission

      private final String basePermission
    • requireOp

      private final boolean requireOp
  • Constructor Details

    • PermissionValidator

      public PermissionValidator()
      Creates a permission validator with no base permission requirement. 创建一个没有基本权限要求的权限验证器。
    • PermissionValidator

      public PermissionValidator(String permission, boolean requireOp)
      Creates a permission validator with the specified permission. 创建具有指定权限的权限验证器。
      Parameters:
      permission - the required permission
      requireOp - whether OP is required
  • Method Details

    • validate

      Description copied from interface: CommandValidator
      Validates the command context. 验证命令上下文。
      Specified by:
      validate in interface CommandValidator
      Parameters:
      context - the command context to validate
      Returns:
      the validation result
    • getOrder

      public int getOrder()
      Description copied from interface: CommandValidator
      Gets the order of this validator. Lower values are executed first. 获取此验证器的顺序。较低的值优先执行。
      Specified by:
      getOrder in interface CommandValidator
      Returns:
      the order value
    • getName

      public String getName()
      Description copied from interface: CommandValidator
      Gets the name of this validator for debugging and logging purposes. 获取此验证器的名称,用于调试和日志记录。
      Specified by:
      getName in interface CommandValidator
      Returns:
      the validator name
    • fromAnnotation

      public static PermissionValidator fromAnnotation(CmdExecutor annotation)
      Creates a validator from a CmdExecutor annotation. 从 CmdExecutor 注解创建验证器。
      Parameters:
      annotation - the annotation
      Returns:
      a new validator