Paul2708 / simple-commands

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

Command argument bundle #9

Open Paul2708 opened 5 years ago

Paul2708 commented 5 years ago

Description

Sometimes an object contains multiple arguments. E.g. Location as it contains three coordinates. It would be nice to have a command argument bundle that bundles multiple arguments into one.

Usage

Screenshots or code Something like that:

interface CommandBundle {
  CommandArgument<?>[] getArguments();
}
class LocationBundle implements CommandBundle {
  @Override
  public CommandArgument<?>[] getArguments() {
    return new CommandArgument<?>[] { new IntArgument(),  new IntArgument()  new IntArgument() };
  }
}
@Command(name = "test")
public void test(Player sender, Location loc) {

}
Paul2708 commented 4 years ago

I appreciate your interest in this project. As the command parsing is basically the core of the whole project, it should be refactored. I agree with that. You mentioned in #8 and #16 to add a new argument type that wraps all of the functionalities like:

the type/argument converter, the name, the optionality, and possible other features like custom verifiers or restrictions.

How would you integrate this argument type? And can you describe your idea of parsing in a few sentences?

Paul2708 commented 4 years ago

Okay, I see your point. It would be good to map the command properties (name, optional, etc.) to the actual argument. But I think CommandArgument is a good name for what the class is actual doing. If you want to, you can create a class that holds meta information for an argument in a command. The properties would be set while parsing the command, correct? If it is so, you can go ahead and refactor the command parsing (if you want to of cause).