Fabric. A string as an argument to the command

41 Views Asked by At

I need to get a string as a command argument.

I am trying to get a string as a command argument in the following way:

CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
    dispatcher.register(CommandManager.literal("cmd_name")
     .then(RequiredArgumentBuilder.argument("msg", StringArgumentType.greedyString()))
     .executes(context -> {
        String message = StringArgumentType.getString(context, "msg");
        System.out.println(message);
        return 1;
    })
     .executes(context -> {
        System.out.println("ff");
        return 1;
      }));
});

This works fine with a command without a parameter, but refuses to work when I add a parameter. Screenshot of the error

0

There are 0 best solutions below