Rollczi / LiteCommands

☄️ LiteCommands - Command framework for Velocity, Bukkit, Paper, BungeeCord, Minestom, Sponge, Fabric, JDA and future implementations.
https://docs.rollczi.dev/
Apache License 2.0
146 stars 21 forks source link

VarArgs Support #308

Closed creatorfromhell closed 10 months ago

creatorfromhell commented 12 months ago

I think a feature to support VarArgs for commands would be nice. This could be specified by using an array in the argument type.

An example would be with a gamerule command: /world setrules worldname rule1:true rule2:true rule3:true

Code:

public void gamerule(Player sender, @Arg @Name("world") World world, @Arg @Name("gamerule") Gamerule[] rules)

Alternative code:

public void gamerule(Player sender, @Arg @Name("world") World world, @VarArg @Name("gamerule") Gamerule[] rules)
CarmJos commented 12 months ago

I think this feature can be implement by creating a new argument type like GameruleSetup with join resolve to process all values.

CarmJos commented 12 months ago

The single @VarArg may not support what you want, it only Gamerule[], not Map<Gamerule,Boolean>.

So, using the @Join GameruleSetup[] setups may be the best solution for you.