public final class GenericArguments extends Object
Modifier and Type | Method and Description |
---|---|
static CommandElement |
allOf(CommandElement element)
Require all remaining args to match as many instances of CommandElement as will fit
Command element values will be stored under their provided keys in the CommandContext.
|
static CommandElement |
bool(Text key)
Require an argument to be a boolean.
|
static <T extends CatalogType> |
catalogedElement(Text key,
Game game,
Class<T> catalogType)
Expect an argument that is a member of the specified catalog type T.
|
static CommandElement |
choices(Text key,
Map<String,?> choices)
Return an argument that allows selecting from a limited set of values.
|
static CommandElement |
choices(Text key,
Map<String,?> choices,
boolean choicesInUsage)
Return an argument that allows selecting from a limited set of values.
|
static CommandElement |
dimension(Text key,
Game game)
Expect an argument to represent a dimension.
|
static <T extends Enum<T>> |
enumValue(Text key,
Class<T> type)
Require the argument to be a key under the provided enum.
|
static CommandElement |
firstParsing(CommandElement... elements)
Returns a command element that matches the first of the provided elements that parses.
|
static org.spongepowered.api.util.command.args.CommandFlags.Builder |
flags()
Get a builder to create a command element that parses flags.
|
static CommandElement |
integer(Text key)
Require an argument to be an integer (base 10).
|
static CommandElement |
literal(Text key,
Object putValue,
String... expectedArgs)
Expect a literal sequence of arguments.
|
static CommandElement |
literal(Text key,
String... expectedArgs)
Expect a literal sequence of arguments.
|
static CommandElement |
location(Text key,
Game game)
Expect an argument to represent a
Location . |
static CommandElement |
none()
Expects no arguments.
|
static CommandElement |
onlyOne(CommandElement element)
Restricts the given command element to only insert one value into the context at the provided key.
|
static CommandElement |
optional(CommandElement element)
Make the provided command element optional
This means the command element is not required.
|
static CommandElement |
optional(CommandElement element,
Object value)
Make the provided command element optional
This means the command element is not required.
|
static CommandElement |
optionalWeak(CommandElement element)
Make the provided command element optional
This means the command element is not required.
|
static CommandElement |
optionalWeak(CommandElement element,
Object value)
Make the provided command element optional
This means the command element is not required.
|
static CommandElement |
player(Text key,
Game game)
Expect an argument to represent an online player.
|
static CommandElement |
playerOrSource(Text key,
Game game)
Expect an argument to represent an online player,
or if nothing matches and the source is a
Player , give the player. |
static CommandElement |
remainingJoinedStrings(Text key)
Require one or more strings, which are combined into a single, space-separated string.
|
static CommandElement |
repeated(CommandElement element,
int times)
Require a given command element to be provided a certain number of times
Command values will be stored under their provided keys in the CommandContext
|
static CommandElement |
requiringPermission(CommandElement element,
String permission)
Checks a permission for a given command argument to be used.
|
static CommandElement |
seq(CommandElement... elements)
Consumes a series of arguments.
|
static CommandElement |
string(Text key)
Require an argument to be a string.
|
static CommandElement |
vector3d(Text key)
Expect an argument to represent a
Vector3d . |
static CommandElement |
world(Text key,
Game game)
Expect an argument to represent a world.
|
public static CommandElement none()
public static CommandElement playerOrSource(Text key, Game game)
Player
, give the player. If nothing matches and the source is not a player, throw an
exception
Gives value of type Player
key
- The key to store undergame
- The game to find players inpublic static CommandElement player(Text key, Game game)
Player
key
- The key to store undergame
- The game to find players inpublic static CommandElement world(Text key, Game game)
WorldProperties
key
- The key to store undergame
- The game to find worlds frompublic static CommandElement dimension(Text key, Game game)
DimensionType
key
- The key to store undergame
- The game to find dimensions frompublic static CommandElement vector3d(Text key)
Vector3d
.key
- The key to store underpublic static CommandElement location(Text key, Game game)
Location
.key
- The key to store undergame
- The game to find worlds frompublic static <T extends CatalogType> CommandElement catalogedElement(Text key, Game game, Class<T> catalogType)
T
- The type to returnkey
- The key to store the resolved value undergame
- The game to get the registry fromcatalogType
- The type expectedpublic static org.spongepowered.api.util.command.args.CommandFlags.Builder flags()
public static CommandElement seq(CommandElement... elements)
elements
- The series of arguments to expectpublic static CommandElement choices(Text key, Map<String,?> choices)
choices(Text, Map, boolean)
.key
- The key to store the resulting value underchoices
- The choices users can choose frompublic static CommandElement choices(Text key, Map<String,?> choices, boolean choicesInUsage)
choicesInUsage
is true, general command usage will only display the provided keykey
- The key to store the resulting value underchoices
- The choices users can choose fromchoicesInUsage
- Whether to display the available choices, or simply the provided key, as part of usagepublic static CommandElement firstParsing(CommandElement... elements)
elements
- The elements to check againstpublic static CommandElement optional(CommandElement element)
element
- The element to optionally requirepublic static CommandElement optional(CommandElement element, Object value)
value
are not
null and this element is not provided the element's key will be set to the given value.element
- The element to optionally requirevalue
- The default value to setpublic static CommandElement optionalWeak(CommandElement element)
element
- The element to optionally requirepublic static CommandElement optionalWeak(CommandElement element, Object value)
value
are not null and this element is not provided the element's key will
be set to the given value.element
- The element to optionally requirevalue
- The default value to setpublic static CommandElement repeated(CommandElement element, int times)
element
- The element to repeattimes
- The number of times to repeat the element.public static CommandElement allOf(CommandElement element)
element
- The element to repeatpublic static CommandElement string(Text key)
String
.key
- The key to store the parsed argument underpublic static CommandElement integer(Text key)
Integer
key
- The key to store the parsed argument underpublic static CommandElement bool(Text key)
Boolean
key
- The key to store the parsed argument underpublic static <T extends Enum<T>> CommandElement enumValue(Text key, Class<T> type)
T
- The type of enumkey
- The key to store the matched enum value undertype
- The enum class to get enum constants frompublic static CommandElement remainingJoinedStrings(Text key)
String
key
- The key to store the parsed argument underpublic static CommandElement literal(Text key, String... expectedArgs)
key
- The key to add to the context. Will be set to a value of true if this element matchesexpectedArgs
- The sequence of arguments expectedpublic static CommandElement literal(Text key, @Nullable Object putValue, String... expectedArgs)
key
- The key to store this argument asputValue
- The value to put at key if this argument matches. May be nullexpectedArgs
- The sequence of arguments expectedpublic static CommandElement onlyOne(CommandElement element)
element
- The element to restrictpublic static CommandElement requiringPermission(CommandElement element, String permission)
element
- The element to wrappermission
- The permission to check