public final class Context
extends java.lang.Object
| Constructor and Description |
|---|
Context(Blade blade,
Sender<?> sender,
java.lang.String label,
java.lang.String[] arguments) |
| Modifier and Type | Method and Description |
|---|---|
@Nullable java.lang.String |
argument(int index)
Gets the argument at the specified index.
|
@NotNull java.lang.String[] |
arguments()
Gets all provided arguments.
|
@NotNull Blade |
blade()
The Blade instance.
|
@NotNull java.lang.String |
label()
The label that was used to invoke the command.
|
Context |
label(java.lang.String label) |
<T> T |
parseArgument(int index,
@NotNull ArgumentProvider<T> provider)
Attempts to parse the argument at the specified index using the provided argument provider.
|
<T> T |
parseArgument(int index,
@NotNull ArgumentProvider<T> provider,
@NotNull java.lang.String defaultValue)
Attempts to parse the argument at the specified index using the provided argument provider and default value.
|
<T> T |
parseArgument(int index,
@NotNull java.lang.Class<T> argumentClass)
Attempts to parse the argument at the specified index using the provided argument class.
|
<T> T |
parseArgument(int index,
@NotNull java.lang.Class<T> classOfT,
@NotNull ArgumentProvider<T> provider,
@NotNull java.lang.String defaultValue)
Attempts to parse the argument at the specified index using the provided argument class and provider.
|
<T> T |
parseArgument(int index,
@NotNull java.lang.Class<T> argumentClass,
@NotNull java.lang.String defaultValue)
Attempts to parse the argument at the specified index using the provided argument class and default value.
|
@NotNull Sender<?> |
sender()
The sender of the command.
|
void |
updateArgumentsFromInput(@NotNull CommandInput input)
Updates the arguments from the given command input.
|
@NotNull public @NotNull java.lang.String[] arguments()
@Nullable public @Nullable java.lang.String argument(int index)
index - the index@Nullable
public <T> T parseArgument(int index,
@NotNull
@NotNull java.lang.Class<T> argumentClass)
T - the type of the argumentindex - the indexargumentClass - the argument class@Nullable
public <T> T parseArgument(int index,
@NotNull
@NotNull java.lang.Class<T> argumentClass,
@NotNull
@NotNull java.lang.String defaultValue)
T - the type of the argumentindex - the indexargumentClass - the argument classdefaultValue - the default value to use if the argument is not present@Nullable
public <T> T parseArgument(int index,
@NotNull
@NotNull ArgumentProvider<T> provider)
T - the type of the argumentindex - the indexprovider - the argument provider@Nullable
public <T> T parseArgument(int index,
@NotNull
@NotNull ArgumentProvider<T> provider,
@NotNull
@NotNull java.lang.String defaultValue)
T - the type of the argumentindex - the indexprovider - the argument providerdefaultValue - the default value to use if the argument is not present@Nullable
public <T> T parseArgument(int index,
@NotNull
@NotNull java.lang.Class<T> classOfT,
@NotNull
@NotNull ArgumentProvider<T> provider,
@NotNull
@NotNull java.lang.String defaultValue)
T - the type of the argumentindex - the indexclassOfT - the argument classprovider - the argument providerdefaultValue - the default value to use if the argument is not present@NotNull public @NotNull java.lang.String label()
@NotNull public @NotNull Sender<?> sender()
@NotNull public @NotNull Blade blade()
@ApiStatus.Internal
public void updateArgumentsFromInput(@NotNull
@NotNull CommandInput input)
input - the command input@ApiStatus.Internal public Context label(java.lang.String label)
this.