Paul2708 / simple-commands

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

Define argument usage string #16

Open Paul2708 opened 5 years ago

Paul2708 commented 5 years ago

Description

Every argument provides its own "usage" notation. This message appears if the player types in a false order of the arguments. As the usage notation for arguments is very general (e.g. [Int], [Word]) it would be a nice addition to specify the usage by argument itself instead of argument type.

Usage

Implementation idea That can be implemented by adding an annotation like @Named("usage") to the method parameter, that holds a specific usage.

Screenshots or code

@Command(name = "test)
public void test(Player sender, @Namend("x") int x, @Namend("y") int y, @Namend("z") int z) {
  // ...
}

The usage will be: /test [x] [y] [z] instead of /test [Int] [Int] [Int]

nea89o commented 5 years ago

One could do this and would probably implement this by using a wrapper class again. Since at this point there would be a lot in wrapper classes of wrapper classes resulting in a lot of obfuscation, i would suggest to create a new argumenttype class which encorporates all features of an argument like: the type/argument converter, the name, the optionality, and possible other features like custom verifiers or restrictions.

Also as a quick site note: my name is Roman not Ramon. (See #45)