Exceptions from custom Brigadier commands do not show up in console #9808
Labels
status: accepted
Disputed bug is accepted as valid or Feature accepted as desired to be added.
type: bug
Something doesn't work as it was intended to.
version: 1.20.2
Game version 1.20.2
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:
Paper/patches/server/0140-Add-UnknownCommandEvent.patch
Lines 47 to 64 in 9df2066
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:Paper/patches/server/0140-Add-UnknownCommandEvent.patch
Lines 89 to 95 in 9df2066
Instead of having to call
dispatcher.vanillaCommandNodes.add(node)
,dispatcher.getDispatcher().getRoot().addChild(node)
already updatesthis.dispatcher.getRoot().getChildren()
.The text was updated successfully, but these errors were encountered: