PoweredByApartium / cocoa-beans

General purpose library for Java & Spigot
https://cocoa-beans.apartium.net/
MIT License
9 stars 1 forks source link

Command System Add parameter name for argument mapping #105

Open ikfir opened 3 months ago

ikfir commented 3 months ago

For example

@SubCommand("<int=amount> <int=id>")
public void give(@Param("id") int id, Sender sender, @Param("amount") int amount) {
  // Do something
}

This could be useful in some cases to just save you time and will be easier to understand where each parameter go also it can still be use in the old way as queue

and even combine for example

@SubCommand("<int=amount> <int> <int=id>")
public void give(@Param("id") int id, Sender sender, int magicValue, @Param("amount") int amount) {
  // Do something
}
// Or even
@SubCommand("<int=amount> <int> <int=id>")
public void give(int magicValue, @Param("id") int id, Sender sender, @Param("amount") int amount) {
  // Do something
}

It will know base on that isn't tagged but we can do another thing as well

@SubCommand("<int=amount> <int> <int=id>")
public void give(int magicValue, int idNum, Sender sender, @Param("amount") int amount) {
  // Do something
}
liorsl commented 3 months ago

Alternatives for =:

IdanKoblik commented 3 months ago

~@:Integer

IdanKoblik commented 3 months ago

<{amount}:int> <{name}:String>

ikfir commented 3 months ago

Vote for what you like the most

:heart: <int as amount> :rocket: <amount: int> :tada: <int=amount>

IdanKoblik commented 2 months ago

All of them available for use

ikfir commented 2 months ago

@IdanKoblik

All of them available for use

That would be a bad idea for couple reason

  1. Implemention will be harder for parsing but is do able
  2. Can make code not consistent For example
    @SubCommand("<int as amount> <cost: double> <string=name> <int>")