Interface Parameter.Value.Builder<T>

    • Method Detail

      • key

        Parameter.Value.Builder<T> key​(String key)
        The key that the parameter will place parsed values into.

        This is a mandatory element.

        Parameters:
        key - The key.
        Returns:
        This builder, for chaining
      • key

        Parameter.Value.Builder<T> key​(Parameter.Key<T> key)
        The key that the parameter will place parsed values into.

        This is a mandatory element.

        Parameters:
        key - The key.
        Returns:
        This builder, for chaining
      • completer

        Parameter.Value.Builder<T> completer​(@Nullable ValueCompleter completer)
        Provides a function that provides tab completions

        Optional. If this is null (or never set), completions will either be done via the supplied addParser(ValueParser) or will just return an empty list. If this is supplied, no modifiers will run on completion.

        Parameters:
        completer - The ValueCompleter
        Returns:
        This builder, for chaining
      • modifier

        Parameter.Value.Builder<T> modifier​(@Nullable ValueParameterModifier<T> modifier)
        Provides a modifier that allows for the modification of the outcome of an argument parse or a completion. This is primarily intended for use with Mojang/Sponge standard parameters, allowing developers to tweak the input of a standard parameter without having to worry about completion types.

        Developers should only use this when they use a parameter type that they do not control. If you are using this with a ValueParameter, ValueParser or ValueCompleter that you control (that is, able to modify the source of), it is strongly recommended that you do that instead. For more information about how a modifier should be used, read the ValueParameterModifier docs instead.

        Optional. If this is null (or never set), any outcomes will not be modified.

        Parameters:
        modifier - The modifier
        Returns:
        This builder, for chaning
      • usage

        Parameter.Value.Builder<T> usage​(@Nullable ValueUsage usage)
        Sets the usage. The Function accepts the parameter key and the calling Cause.

        Optional. If this is null (or never set), the usage string will either be provided via the supplied addParser(ValueParser) or will just return the parameter's key. If this is supplied, no modifiers will run on usage.

        Parameters:
        usage - The function
        Returns:
        This builder, for chaining
      • requiredPermission

        Parameter.Value.Builder<T> requiredPermission​(@Nullable String permission)
        Sets a function that determines what is required of the appropriate Subject in the provided Cause before this parameter is parsed.

        If the source does not have this permission, this parameter will simply be skipped. Consider combining this with optional() so that those with permission can also skip this parameter.

        Parameters:
        permission - The permission to check for, or null for no check.
        Returns:
        This builder, for chaining
      • requirements

        Parameter.Value.Builder<T> requirements​(@Nullable Predicate<CommandCause> executionRequirements)
        Sets a function that determines what is required of the provided Cause before this parameter attempts to parse.

        If this is set to null, this parameter will always attempt to parse, subject to other modifiers.

        Note: this will overwrite any requirements set using requiredPermission(String)}.

        Parameters:
        executionRequirements - A function that sets the
        Returns:
        This builder, for chaining
      • consumeAllRemaining

        Parameter.Value.Builder<T> consumeAllRemaining()
        If set, this parameter will repeat until the argument string has been parsed.

        For example, if you have the argument string,

             1 2 3 4
         

        and you use ResourceKeyedValueParameters.INTEGER without setting this method, this parameter will parse the first element, 1, and the remaining elements will be left for the next parameter in the chain. If you call this method, the resulting Parameter.Value will continuously parse the argument string until either:

        • The entire argument string has been parsed, in which case the parsing is considered complete and command execution will continue
        • A part of the argument string could not be parsed, in which case an exception will be raised. If this element is also marked as optional(), then parsing will continue as if nothing has been parsed.

        Unless marked as optional, this element must be able to consume at least one argument. This will automatically mark the element as terminal.

        Returns:
        This builder, for chaining
      • optional

        Parameter.Value.Builder<T> optional()
        Marks this parameter as optional, such that if an argument does not exist or cannot be parsed, an exception is not thrown, and no value is returned.
        Returns:
        This builder, for chaining
      • terminal

        Parameter.Value.Builder<T> terminal()
        Marks this parameter as a terminal parameter. Any terminal parameter can be considered as a point where argument parsing can stop, allowing control to pass to the command's associated CommandExecutor.

        Note that a parameter may be considered terminal even if this isn't set, including if the parameter will consume the rest of the argument string, or if all following arguments are optional(). In these scenarios, the built parameter may not be aware of its terminal status.

        Returns:
        This builder, for chaining.