Paul2708 / simple-commands

An (even more) simplified and intuitive command framework for Spigot.
MIT License
14 stars 2 forks source link

Array command argument #8

Open Paul2708 opened 4 years ago

Paul2708 commented 4 years ago

Description

The array argument should be used to accept only a certain number of argument types or unlimited of those.

Usage

Implementation idea Unlimited arguments can be implemented by using varargs. A positive side-effect is, that varargs are only allowed at the end of an method - like in command.

Screenshots or code

@Command(name = "kick")
public void test(Player sender, Player target, String... reason) {
  String message = "";
  for (String word : reason) a += message + " ";

  target.kickPlayer(message);
}
nea89o commented 4 years ago

This could be put in a argument wrapper like #16. The actual argument parsing shouldn't be too hard either, but i would extract all that argument parsing in a seperate class for all those aspects.