Skip to content

Add variable length parameter #275

@SNWCreations

Description

@SNWCreations

I would like to add a variable-length parameter that wraps all known parameters (except itself).
It is like GreedyStringArgument, but it is enchanced.

Please supply examples of the desired inputs and outputs
Example:
Input: /test a
Output: a
But if we use /test a b c, it will say "a,b,c"
Or "/test 0 1 2", it will say "0,1,2"

Example for Developers:

new CommandAPICommand("test")
  .withArguments(
    new VariableLengthParameter("names", Object.class)
	// or the class of special arguments, this allows you to check whether the user-supplied parameters are instances of these classes.
	// I use Object.class to allow all possible argument.
  ).executes((sender, args) -> {
    Collection<Object> result = (Collection<Object>) args[0]; // or Object[]
	String message = String.join(",", Arrays.stream(result).map(IT -> String.valueOf(IT)).collect(Collectors.toList()).toArray());
	sender.sendMessage(message);
  }).register();

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions