Hello all,
I’m really banging my head against the wall on this one. I’ve followed the tutorials on the Sponge docs and I believe I have this set up correctly. For the record when I execute the command
/helpme view 3
It works as expected and the single argument is passed. But when I execute:
/helpme message 3 Adding to the message
I always get the following error:
Error occurred while executing command: No value present
Below is my command registration and the executor function associated with the child command in question. According to the stack trace in console, the error happens in the first line of the executor function trying to get the ticketnum. Any help is appreciated!
CommandSpec helpMeCommandAddMessage = CommandSpec.builder()
.description(Text.of("HelpMe Advanced. Add another message to the ticket"))
.permission("helpme.command.message")
.arguments(GenericArguments.onlyOne(GenericArguments.string(Text.of("ticketnum"))))
.arguments(GenericArguments.remainingJoinedStrings(Text.of("message")))
.executor(helpMeCommand.AddMessageCommand)
.build();
CommandSpec helpMeBaseCommand = CommandSpec.builder()
.description(Text.of("HelpMe Advanced Command"))
.permission("helpme.command.use")
.child(helpMeAdminViewCommand, "view")
.child(helpMeCommandAddMessage, "message")
.arguments(GenericArguments.remainingJoinedStrings(Text.of("message")))
.executor(helpMeCommand.BaseCommand)
.build();
Sponge.getCommandManager().register(this, helpMeBaseCommand, "helpme");
Executor:
public CommandExecutor AddMessageCommand = new CommandExecutor(){
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
String ticketNumber = args.<String>getOne("ticketnum").get();
String message = args.<String>getOne("message").get();
_dbHelper.createMessage(Integer.parseInt(ticketNumber), message);
Text returnMessage = Text.builder("===Ticket:" + ticketNumber + " Updated!===").color(TextColors.YELLOW).build();
src.sendMessage(returnMessage);
return CommandResult.success();
}
};