Class StringArgumentType

java.lang.Object
dev.polv.taleapi.command.argument.StringArgumentType
All Implemented Interfaces:
ArgumentType<String>

public class StringArgumentType extends Object implements ArgumentType<String>
Argument type for string values.

Provides three modes:

  • word() - Single word (no spaces, stops at whitespace)
  • string() - Quoted string or single word
  • greedyString() - Consumes all remaining input

Example Usage


 // Single word argument
 Command.argument("name", StringArgumentType.word())

 // Quoted or single word
 Command.argument("message", StringArgumentType.string())

 // All remaining input
 Command.argument("reason", StringArgumentType.greedyString())
 
  • Method Details

    • word

      public static StringArgumentType word()
      Creates a word argument type (single word, no spaces).
      Returns:
      a new word argument type
    • string

      public static StringArgumentType string()
      Creates a string argument type (quoted or single word).
      Returns:
      a new string argument type
    • greedyString

      public static StringArgumentType greedyString()
      Creates a greedy string argument type (all remaining input).
      Returns:
      a new greedy string argument type
    • getType

      Returns the string type mode.
      Returns:
      the string type
    • parse

      public String parse(StringReader reader) throws CommandException
      Description copied from interface: ArgumentType
      Parses the argument from the input string.
      Specified by:
      parse in interface ArgumentType<String>
      Parameters:
      reader - the string reader positioned at the argument
      Returns:
      the parsed value
      Throws:
      CommandException - if the argument cannot be parsed
    • getResultType

      public Class<String> getResultType()
      Description copied from interface: ArgumentType
      Returns the Java type this argument parses to.
      Specified by:
      getResultType in interface ArgumentType<String>
      Returns:
      the result type class
    • getTypeName

      public String getTypeName()
      Description copied from interface: ArgumentType
      Returns a human-readable name for this argument type.

      Used in error messages and help text.

      Specified by:
      getTypeName in interface ArgumentType<String>
      Returns:
      the type name (e.g., "integer", "string", "player")
    • getExamples

      public String[] getExamples()
      Description copied from interface: ArgumentType
      Returns example values for this argument type.

      Used for documentation and error messages.

      Specified by:
      getExamples in interface ArgumentType<String>
      Returns:
      an array of example values