FabricMC / fabric

Essential hooks for modding with Fabric.
Apache License 2.0
2.33k stars 410 forks source link

[Suggestion] Better Command API #3488

Closed LoboMetalurgico closed 9 months ago

LoboMetalurgico commented 9 months ago

Mojang brigadier is... weird. It has no optional arguments and to create it you need to repeat the code for each different behavior based on whether or not it has a certain argument (see /TP command). Command aliases are another complicated thing to understand and do.

Therefore, I would like to suggest a new command API, similar to what other server software such as Bukkit/Spigot/Paper, Sponge, Bungeecord/Waterfall, Velocity, and others have

This would make mod development simpler, as well as attract more people to the Fabric Ecosystem, as many avoid it due to the complexity of creating commands and events.

maityyy commented 9 months ago

Fabric API is designed to improve mod compatibility and eliminate copy-paste code. What you are proposing is not part of FAPI's goals.

Bukkit/Spigot/Paper Command API in my opinion is much worse and less flexible than Brigadier API, but the optional argument idea makes sense, perhaps FAPI should have an ArgumentType wrapper called OptionalArgumentType

modmuss50 commented 9 months ago

I agree, this is out of scope for Fabric API. There is nothing stopping a 3rd party library to do this.

maityyy commented 9 months ago

Actually OptionalArgumentType would be very useful, should I open a new issue?

apple502j commented 9 months ago

I don't know how it would function without adding a proper backtracking. Also, adding a new argument type breaks vanilla clients.