Interface TypeParser<T>
- Type Parameters:
T- the target type to parse into
- All Known Implementing Classes:
EnchantmentParser,GameModeParser,LocationParser,TypeParserRegistry.SimpleTypeParser,WorldParser
public interface TypeParser<T>
Interface for parsing command argument strings into specific types.
Implementations should be thread-safe and stateless.
- Since:
- 6.2.0
- Version:
- 2.0.0
- Author:
- wisdomme
-
Method Summary
Modifier and TypeMethodDescriptionGets the primary type this parser handles.default intGets the priority of this parser.Gets all types this parser can handle, including array types.Parses a string value into the target type.default T[]parseArray(String[] values) Parses multiple string values into an array of the target type.default booleanChecks if this parser can handle the specified type.
-
Method Details
-
getPrimaryType
Gets the primary type this parser handles.- Returns:
- the primary type class
-
getSupportedTypes
Gets all types this parser can handle, including array types.- Returns:
- list of supported types
-
parse
Parses a string value into the target type.- Parameters:
value- the string value to parse- Returns:
- the parsed value, or null if parsing fails
- Throws:
TypeParseException- if parsing fails with an error
-
parseArray
Parses multiple string values into an array of the target type. Default implementation calls parse() for each value.- Parameters:
values- the string values to parse- Returns:
- the parsed array
- Throws:
TypeParseException- if parsing fails with an error
-
supports
Checks if this parser can handle the specified type.- Parameters:
type- the type to check- Returns:
- true if this parser can handle the type
-
getPriority
default int getPriority()Gets the priority of this parser. Higher priority parsers are checked first. Default priority is 0.- Returns:
- the parser priority
-