Class CommandContext
-
- All Implemented Interfaces:
public final class CommandContext<T extends CommandSender>
The
CommandContext
class contains information to be used in method calls in run-time. It is most often used in executions, suggestions and requirements.
-
-
Constructor Summary
Constructors Constructor Description CommandContext(HashMap<String, Function1<CommandContext<CommandSender>, Object>> arguments, T sender, String input)
-
Method Summary
Modifier and Type Method Description final HashMap<String, Function1<CommandContext<CommandSender>, Object>>
getArguments()
final T
getSender()
final String
getInput()
final <T extends Any> T
getArgument(String name)
Gets the argument with name, in the type as specified by T. final <T extends Any> T
getArgument(Integer index)
Gets the argument at index, in the type as specified by T. final <T extends Any> T
getOrNull(String name)
Gets the argument with name, in the type as specified by T. final <T extends Any> T
getOrNull(Integer index)
Gets the argument at index, in the type as specified by T. final Object
get(String name)
Gets the argument with name. final Object
get(Integer index)
Gets the argument at index. -
-
Constructor Detail
-
CommandContext
CommandContext(HashMap<String, Function1<CommandContext<CommandSender>, Object>> arguments, T sender, String input)
- Parameters:
arguments
- A HashMap of arguments of with the key being the argument name, and the value being its return value.sender
- This property has the type of whatever you are specified in theCommandContext<T>
generic type.input
- A String that represents the entire command input excluding the/
.
-
-
Method Detail
-
getArguments
final HashMap<String, Function1<CommandContext<CommandSender>, Object>> getArguments()
-
getArgument
final <T extends Any> T getArgument(String name)
- Returns:
The argument with the type of T.
-
getArgument
final <T extends Any> T getArgument(Integer index)
- Returns:
The argument with the type of T.
-
getOrNull
final <T extends Any> T getOrNull(String name)
- Returns:
The argument with the type of T, which returns null if the argument cannot be cast successfully.
-
getOrNull
final <T extends Any> T getOrNull(Integer index)
- Returns:
The argument with the type of T, which returns null if the argument cannot be cast successfully.
-
-
-
-