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