public final class CommandContext extends Object
Constructor and Description |
---|
CommandContext()
Create a new empty CommandContext.
|
Modifier and Type | Method and Description |
---|---|
void |
checkPermission(CommandSource commander,
String permission)
Perform a permissions check, throwing an exception if the required permissions are not present.
|
<T> Collection<T> |
getAll(String key)
Get all values for the given argument.
|
<T> Optional<T> |
getOne(String key)
Gets the value for the given key if the key has only one value.
|
boolean |
hasAny(String key)
Returns whether this context has any value for the given argument key.
|
void |
putArg(String key,
Object value)
Insert an argument into this context.
|
public <T> Collection<T> getAll(String key)
T
- the type of value to getkey
- The key to get values forpublic <T> Optional<T> getOne(String key)
T
- the expected type of the argumentkey
- the key to getpublic void putArg(String key, Object value)
key
- the key to store the arg undervalue
- the value for this argumentpublic void checkPermission(CommandSource commander, String permission) throws CommandException
commander
- the source to check againstpermission
- The permission to checkCommandException
- if the source does not have permissionpublic boolean hasAny(String key)
key
- The key to look up