Complex Brigadier Commands

Hello developers,

I am currently playing around with the new Brigadier Commands and want to create Commands with Mojang like Tooltips and Tab Completion. My results were close, but not nearly as good as the ones from Mojang directly. I know there’s a difference between commands from velocity and from spigot, but it has to be doable to get the same result.

Let’s use the /effect command as example.

The command takes to Required Arguments, either give or clear. If you input let’s say a c, of course only cleargets suggested. I already got this behavior working, maybe not smart, but working.


BUT if you input e.g. a, there is an error message appearing and the input gets marked red. In my implementation, it just suggests both arguments aigan.

This is what I can not recreate right now, I don’t have any approach, to set static Argument Possibilities.

There’s one more thing I am unable to recreate. Let’s use the /effect command again.
If you input something which is not suggested, a tooltip is shown with the correct Syntax.

I tried using the SuggestionsBuilder#suggest(String text, Message tooltip) but never got any tooltip displayed.

Let’s work it out on this snippet:

private static final String[] POSSIBLE_ARGS = {"info","out"};

public void register() {
    LiteralCommandNode<CommandSource> totalNode = LiteralArgumentBuilder
                .<CommandSource>literal("test")
                .executes(context -> {
                    context.getSource().sendMessage(Component.text("global node"));
                    return 1;
                }).build();

     ArgumentCommandNode<CommandSource,String> argNode = RequiredArgumentBuilder
                .<CommandSource,String>argument("arg", StringArgumentType.word())
                .suggests((context, builder) -> {
                   //TODO add suggestion handling
                    return builder.buildFuture();
                }).build();

    totalNode.addChild(argNode);
    getServer().getCommandManager().register(new BrigadierCommand(totalNode));
}

I would appreciate any kind of help!

Velocity works at a higher level than the Minecraft server - the latter feature you want to add here require custom argument types. This is not supported by Velocity primarily because adding custom command arguments requires all backend servers, the proxy, and the client to agree on the format.

You can get around the required arguments by using two literals as children of your root command.

1 Like

Thank you and sorry for the late response. Don’t know why i did not think of using literals as childs. Got it working perfectly fine now.

Would be cool tho, if someone could explain command forwarding and forking :slight_smile: