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 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 the CommandContext<T> generic type.
        input - A String that represents the entire command input excluding the /.
    • Method Detail

      • getArgument

         final <T extends Any> T getArgument(String name)

        Gets the argument with name, in the type as specified by T.

        Returns:

        The argument with the type of T.

      • getArgument

         final <T extends Any> T getArgument(Integer index)

        Gets the argument at index, in the type as specified by T.

        Returns:

        The argument with the type of T.

      • getOrNull

         final <T extends Any> T getOrNull(String name)

        Gets the argument with name, in the type as specified by T.

        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)

        Gets the argument at index, in the type as specified by T.

        Returns:

        The argument with the type of T, which returns null if the argument cannot be cast successfully.

      • get

         final Object get(String name)

        Gets the argument with name.

        Returns:

        The argument as an Object or a Any (in Kotlin), which returns null if the argument cannot be cast successfully.

      • get

         final Object get(Integer index)

        Gets the argument at index.

        Returns:

        The argument as an Object or a Any (in Kotlin), which returns null if the argument cannot be cast successfully.