MultiLiteralArgument returns null parsedArgument on 11.0.1-SNAPSHOT
CommandAPI version
11.0.1-SNAPSHOT
Minecraft version
1.21.10
Are you shading the CommandAPI?
Yes
What I did
When using MultiLiteralArgument in CommandAPI 11.0.1-SNAPSHOT (tested on Paper 1.21.10), executing the command causes a NullPointerException inside CommandAPIHandler#getRawArgumentInput.
The issue seems to be that parsedArgument is null for MultiLiteralArgument, even though the argument is correctly registered and visible in tab completion.
Minimal reproducible example:
@Override
public void onEnable() {
CommandAPI.onEnable();
new CommandAPICommand("changegamemode")
.withArguments(new MultiLiteralArgument("gamemodes", "survival", "creative", "adventure", "spectator"))
.executes((sender, args) -> {
String gm = (String) args.get("gamemodes");
sender.sendMessage("Selected: " + gm);
})
.register();
}
This issue does not occur in CommandAPI 11.0.0 - the same code works correctly there. It only happens in 11.0.1-SNAPSHOT.
What actually happened
Steps to reproduce:
- Run a Paper 1.21.10 server with CommandAPI 11.0.1-SNAPSHOT (commandapi-paper-shade)
- Load the above plugin
- Execute /changegamemode creative
What should have happened
The command should execute normally and return "Selected: creative", without throwing any exception.
Server logs and CommandAPI config
https://pastes.dev/JN6RzO4Emx
Other
No response
Ah, whoops. This issue is caused by the fix for #310: https://github.com/CommandAPI/CommandAPI/commit/09dfda571d968c4320a2ae8d1b6d51130052f029. I cherry-picked that fix from dev/command-build-rewrite, where this did not happen due to MultiLiteralArguments being reworked.
As a hotfix for this issue, I've restored the behavior in 11.0.0 where the raw input of a MultiLiteralArgument is an empty String. I think it's fine to leave it like that for now, since the correct raw input is identical to the parsed input of a MultiLiteralArgument. dev/command-build-rewrite will properly fix this.
We also should probably get our automated tests working again. I'm pretty sure it would have caught this issue.