Closed willkroboth closed 2 months ago
Are you able to see, is this fixed by https://github.com/PaperMC/Paper/pull/8235?
I can't use the original test plugin, since the changes made by #8235 are currently incompatible with the CommandAPI (https://github.com/JorelAli/CommandAPI/issues/554).
However, using #8235's API like so:
@Override
public void onEnable() {
getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> {
event.registrar().register(
Commands.literal("test")
.executes(context -> {
throw new SimpleCommandExceptionType(() -> "Custom exception message").create();
})
.build()
);
});
}
I am able to see the exception in the console
and it looks to work the same as with the client
I tested the original TestPlugin
with an updated CommandAPI plugin that works with #8235, and verified that the orginal comment of this issue has been resolved.
Expected behavior
On Spigot, if a custom Brigadier command throws a
CommandSyntaxException
, that exception can appear in the console:Observed/Actual behavior
On Paper, instead of showing the exception message, the
Unknown command
message is given:Steps/models to reproduce
I am using the CommandAPI plugin (currently version 9.2.0) to register custom Brigadier commands. You can download the latest jar from here: https://commandapi.jorel.dev/.
Using the CommandAPI, I registered this command:
Here is my TestPlugin that uses this code TestPlugin-1.0-SNAPSHOT.zip. Alternatively, you can build my TestPlugin yourself with this maven project: TestPluginProject.zip.
To reproduce this issue, run the
test
command in the console, giving it a player selector that will not find any players. For example,test @p
when there are no players connected.Note that in the Spigot console, or for a player, when the command fails the
This is a custom exception message: No players were found
message will appear. However, the Paper console will sayUnknown command. Type "/help" for help.
when the command fails.Plugin and Datapack List
Paper version
Other
I believe the inconsistency here between Spigot and Paper comes from this patch:
https://github.com/PaperMC/Paper/blob/9df2066642d32a1f7a372ce528930d48f9fe51f7/patches/server/0140-Add-UnknownCommandEvent.patch#L47-L64
Specifically, line 54, where if the statement is true, it will send the
Unknown command
messageI think the semantics here are wrong. Instead, it should just be:
If the parse results are empty, then the
Unknown command
message should be sent. There's no reason to check if the node it found is in thevanillaCommandNodes
list. If it found a node, then the command is known.I'm also not really sure why the
vanillaCommandNodes
list exists. The value should be equivalent tothis.dispatcher.getRoot().getChildren()
. Relying on the dispatcher would also be safer, since code doesn't need to worry about updating two lists. For example, this code in CraftServer:https://github.com/PaperMC/Paper/blob/9df2066642d32a1f7a372ce528930d48f9fe51f7/patches/server/0140-Add-UnknownCommandEvent.patch#L89-L95
Instead of having to call
dispatcher.vanillaCommandNodes.add(node)
,dispatcher.getDispatcher().getRoot().addChild(node)
already updatesthis.dispatcher.getRoot().getChildren()
.