Interface ArgumentReader.Mutable
- All Superinterfaces:
- ArgumentReader
- Enclosing interface:
- ArgumentReader
ArgumentReader where the cursor may move.- 
Nested Class SummaryNested classes/interfaces inherited from interface org.spongepowered.api.command.parameter.ArgumentReaderArgumentReader.Immutable, ArgumentReader.Mutable
- 
Method SummaryModifier and TypeMethodDescriptionReturns a immutable copy of theArgumentReader.booleanParses "true" or "false", else throws an exception.charReads a character and advances the cursor by oneParses aDataContainer, from a SNBT string, else throws an exception.doubleAttempts to read adoublefrom the input starting at the cursor position.floatAttempts to read afloatfrom the input starting at the cursor position.intparseInt()Attempts to read anintfrom the input starting at the cursor position.Parses a SNBT string, returning that string.Attempts to read a string that is in aResourceKeyformat, which isnamespace:identifier.parseResourceKey(String defaultNamespace) Attempts to read a string that is in aResourceKeyformat, which isnamespace:identifier.Gets aStringfrom the position of the cursor.Gets the next word in the input from the position of the cursor.Returns the nextStringbut does not advance the reader.voidsetState(ArgumentReader state) Attempts to reset the state of thisArgumentReader.Mutableto the state that the providedArgumentReaderis in.voidMoves the cursor to the next non-whitespace character.Methods inherited from interface org.spongepowered.api.command.parameter.ArgumentReadercanRead, createException, cursor, input, parsed, peekCharacter, remaining, remainingLength, totalLength
- 
Method Details- 
skipWhitespacevoid skipWhitespace()Moves the cursor to the next non-whitespace character. The cursor will not advance if it already refers to a non-whitespace character.
- 
parseCharchar parseChar()Reads a character and advances the cursor by one- Returns:
- The character
 
- 
parseIntAttempts to read anintfrom the input starting at the cursor position. The cursor will advance until it finds a non-number and will return anintbased on the consumed string.Numbers may begin with "-" to indicate a negative number When using this in your parser, you should set ValueParser.clientCompletionType()toClientCompletionTypes.WHOLE_NUMBERto tell the client that the client completion should be an integer.- Returns:
- The integer
- Throws:
- ArgumentParseException- if the cursor is not at a number character
 
- 
parseDoubleAttempts to read adoublefrom the input starting at the cursor position. The cursor will advance until it finds a non-number and will return adoublebased on the consumed string.Numbers may begin with "-" to indicate a negative number, and one period (".") may be present in the string. When using this in your parser, you should set ValueParser.clientCompletionType()toClientCompletionTypes.DECIMAL_NUMBERto tell the client that the client completion should be a floating point number.- Returns:
- The double
- Throws:
- ArgumentParseException- if the cursor is not at a number character
 
- 
parseFloatAttempts to read afloatfrom the input starting at the cursor position. The cursor will advance until it finds a non-number and will return afloatbased on the consumed string.Numbers may begin with "-" to indicate a negative number, and one period (".") may be present in the string. When using this in your parser, you should set ValueParser.clientCompletionType()toClientCompletionTypes.DECIMAL_NUMBERto tell the client that the client completion should be a floating point number.- Returns:
- The double
- Throws:
- ArgumentParseException- if the cursor is not at a number character
 
- 
parseResourceKeyAttempts to read a string that is in aResourceKeyformat, which isnamespace:identifier.This parser is a strict parser. If the input is not of the format specified above, this will fail. If you are potentially expecting a non-namespaced key, but would like to accept such strings with a default namespace, use parseResourceKey(String)When using this in your parser, you should set ValueParser.clientCompletionType()toClientCompletionTypes.RESOURCE_KEYto tell the client that the client completion should be aResourceKey, so that your users will not be told to put their argument in quotation marks.- Returns:
- The ResourceKey
- Throws:
- ArgumentParseException- if a key could not be parsed
 
- 
parseResourceKeyAttempts to read a string that is in aResourceKeyformat, which isnamespace:identifier.If no colon is encountered, the default namespace defined below will be used as the namespace. When using this in your parser, you should set ValueParser.clientCompletionType()toClientCompletionTypes.RESOURCE_KEYto tell the client that the client completion should be aResourceKey, so that your users will not be told to put their argument in quotation marks.- Parameters:
- defaultNamespace- The default namespace to use when parsing a string that does not contain a colon.
- Returns:
- The ResourceKey
- Throws:
- ArgumentParseException- if a key could not be parsed
 
- 
parseUnquotedStringGets the next word in the input from the position of the cursor. This will return a string that contains the characters up to, but excluding, whitespace. The cursor will then be moved to the whitespace after the word.As an example, if the input string is eggs bacon spamand the cursor is at position zero (at the beginning), after this operation, the cursor will be at the whitespace between "eggs" and "bacon".In general, you will likely wish to use parseString()instead unless you are expecting a double quote mark at the beginning of your string and this is part of the argument you wish to return.The following characters will be parsed as part of a valid string without the need for quotation marks. - Alphanumeric symbols
- Underscores (_)
- Hyphens (-)
- Periods (.)
- Plus signs (+)
 If you require other symbols, use parseString()and ensure that users are aware they need to surround their inputs with double quotation marks. Alternatively, consider whether other parse types are suitable (for example, if you are expecting aResourceKey, useparseResourceKey()orparseResourceKey(String).- Returns:
- The parsed String
- Throws:
- ArgumentParseException- if a- Stringcould not be read
 
- 
parseStringGets aStringfrom the position of the cursor. The parsing of the argument depends on whether a double quote mark is the next character to be consumed.- If a double quote is at the beginning of the string , the parser will read characters until a second quotation mark is found and return the string between the two marks. The cursor will then be set to the position after the second mark.
- If the first character is not a double quote
     , parseUnquotedString()will parse the string
 If part of the string is quoted, such as "eggs bacon" spam, this method will returneggs baconon first invocation, then (after runningskipWhitespace(),spamon the second.- Returns:
- The parsed String
- Throws:
- ArgumentParseException- if a- Stringcould not be read
 
- 
peekStringReturns the nextStringbut does not advance the reader.This call will return the same result as parseString(). Calling this multiple times in succession will return the same result each time until anotherparse*method orsetState(ArgumentReader)is called.- Returns:
- The next string to be read
- Throws:
- ArgumentParseException- if a- Stringcould not be read
 
- 
parseBooleanParses "true" or "false", else throws an exception.- Returns:
- A boolean
- Throws:
- ArgumentParseException- if a- booleancould not be read
 
- 
parseNBTStringParses a SNBT string, returning that string.When using this in your parser, you should set ValueParser.clientCompletionType()toClientCompletionTypes.SNBTto tell the client that the client completion should be a SNBT string.- Returns:
- The string
- Throws:
- ArgumentParseException- if a SNBT string could not be read
 
- 
parseDataContainerParses aDataContainer, from a SNBT string, else throws an exception.When using this in your parser, you should set ValueParser.clientCompletionType()toClientCompletionTypes.SNBTto tell the client that the client completion should be a string in Mojang's SNBT format.- Returns:
- A JsonObject
- Throws:
- ArgumentParseException- if a- JsonObjectcould not be read
 
- 
immutableArgumentReader.Immutable immutable()Returns a immutable copy of theArgumentReader. This can be used to get and restore the state of this reader when coupled withsetState(ArgumentReader).- Returns:
- An ArgumentReader.Immutable
 
- 
setStateAttempts to reset the state of thisArgumentReader.Mutableto the state that the providedArgumentReaderis in. This is generally used withimmutable().If the provided statedoes not have the sameArgumentReader.input(), this will throw aIllegalArgumentException- Parameters:
- state- The state to restore this to
- Throws:
- IllegalArgumentException
 
 
-