Class CommandArgument.Builder

java.lang.Object
dev.ua.theroer.magicutils.commands.CommandArgument.Builder
Enclosing class:
CommandArgument

public static class CommandArgument.Builder extends Object
Builder for CommandArgument.
  • Constructor Details

    • Builder

      public Builder(String name, Class<?> type)
      Constructs a new Builder for CommandArgument.
      Parameters:
      name - the argument name
      type - the argument type
  • Method Details

    • optional

      public CommandArgument.Builder optional()
      Sets the argument as optional.
      Returns:
      this builder
    • defaultValue

      public CommandArgument.Builder defaultValue(String defaultValue)
      Sets the default value for the argument.
      Parameters:
      defaultValue - the default value
      Returns:
      this builder
    • suggestions

      public CommandArgument.Builder suggestions(String... suggestions)
      Adds suggestions for the argument.
      Parameters:
      suggestions - the suggestions
      Returns:
      this builder
    • suggestions

      public CommandArgument.Builder suggestions(List<String> suggestions)
      Adds suggestions for the argument.
      Parameters:
      suggestions - the suggestions list
      Returns:
      this builder
    • suggestionHost

      public CommandArgument.Builder suggestionHost(Object suggestionHost)
      Sets the object on which @Suggest("methodName") provider methods resolve. Used when a carrier is mounted/merged into another root so the suggestion methods still resolve against the original carrier instance rather than the registered wrapper command.
      Parameters:
      suggestionHost - the carrier instance, or null
      Returns:
      this builder
    • permission

      public CommandArgument.Builder permission(String permission)
      Sets the required permission for the argument.
      Parameters:
      permission - the permission string
      Returns:
      this builder
    • permissionCondition

      public CommandArgument.Builder permissionCondition(PermissionConditionType condition)
      Sets structured permission condition.
      Parameters:
      condition - condition type
      Returns:
      this builder
    • permissionConditionArgs

      public CommandArgument.Builder permissionConditionArgs(String[] args)
      Sets arguments used in the permission condition.
      Parameters:
      args - argument names
      Returns:
      this builder
    • compareMode

      public CommandArgument.Builder compareMode(CompareMode mode)
      Sets comparison strategy for permission checks.
      Parameters:
      mode - compare mode
      Returns:
      this builder
    • permissionNode

      public CommandArgument.Builder permissionNode(String node)
      Overrides generated permission node segment.
      Parameters:
      node - custom node
      Returns:
      this builder
    • includeArgumentSegment

      public CommandArgument.Builder includeArgumentSegment(boolean include)
      Controls whether to include ".argument." segment in generated node.
      Parameters:
      include - true to include, false to omit
      Returns:
      this builder
    • permissionDefault

      public CommandArgument.Builder permissionDefault(MagicPermissionDefault defaultValue)
      Sets default permission state.
      Parameters:
      defaultValue - default permission
      Returns:
      this builder
    • markPermissionDeclared

      public CommandArgument.Builder markPermissionDeclared()
      Explicitly mark that a permission annotation exists even if value is empty.
      Returns:
      this builder
    • permissionCondition

      @Deprecated public CommandArgument.Builder permissionCondition(String condition)
      Deprecated.
      Sets the permission condition for the argument.
      Parameters:
      condition - the permission condition
      Returns:
      this builder
    • permissionMessage

      public CommandArgument.Builder permissionMessage(String message)
      Sets the permission denied message for the argument.
      Parameters:
      message - the permission message
      Returns:
      this builder
    • greedy

      public CommandArgument.Builder greedy()
      Marks this argument as greedy (consume remaining input).
      Returns:
      this builder
    • sender

      public CommandArgument.Builder sender(AllowedSender[] allowed)
      Mark this parameter as the executing sender and restrict allowed sender types.
      Parameters:
      allowed - allowed sender kinds
      Returns:
      this builder
    • option

      public CommandArgument.Builder option(String[] shortNames, String[] longNames)
      Defines named options for this argument.
      Parameters:
      shortNames - short option names without "-" prefix
      longNames - long option names without "--" prefix
      Returns:
      this builder
    • option

      public CommandArgument.Builder option(String[] shortNames, String[] longNames, boolean flag)
      Defines named options for this argument.
      Parameters:
      shortNames - short option names without "-" prefix
      longNames - long option names without "--" prefix
      flag - whether this option is a flag
      Returns:
      this builder
    • contextArgs

      public CommandArgument.Builder contextArgs(String... contextArgs)
      Adds names of arguments whose parsed values should be available as context for suggestions.
      Parameters:
      contextArgs - the names of context arguments
      Returns:
      this builder
    • build

      public CommandArgument build()
      Builds the CommandArgument instance.
      Returns:
      the CommandArgument