ClientCommands icon indicating copy to clipboard operation
ClientCommands copied to clipboard

Tab complete does not honor requires()

Open unascribed opened this issue 5 years ago • 4 comments

Registering a client command that has a requires() check does not remove it from tab complete like it does on the server.

Accepting the completion shows an immediate syntax error and highlights the command in red, so the requirement is recognized, but the tab complete isn't honoring it.

Minecraft 1.16.3, Fabric Loader v0.10.0+build.208, Fabric API 0.22.0+build.408-1.16

Workaround: Just don't register the command. Works in my case as my requires() check was "integrated server is absent", but more complex checks don't have that luxury.

unascribed avatar Oct 25 '20 23:10 unascribed

So this is the result of a fundamental difference between commands originating on the server and client act. A command registered on the server will go through the requires check and will be omitted from the command tree the client receives if a player cannot access the command.

Likewise the command dispatcher on the client has no filtering of these "inaccessible" nodes, so some internal logic changes would be required to handle that.

i509VCB avatar Oct 26 '20 05:10 i509VCB

I see; still getting used to Brigadier.

If this is complicated to implement it's probably not worth bothering. Just noticed the discrepancy between server and client command behavior.

unascribed avatar Oct 26 '20 10:10 unascribed

Juuz has been working on integrating this into fabric api, so fixing this is going to be essential.

i509VCB avatar Oct 26 '20 17:10 i509VCB

I did this for the Fabric API PR (FabricMC/fabric#1115), but it'd need quite a lot of modification to fit CCC so I'm not most likely going to port them here. (If it doesn't get merged, I'll probably reuse the FabLabs API as a new major version of CCC.)

Juuxel avatar Oct 30 '20 18:10 Juuxel