aikar / commands

Java Command Dispatch Framework - (Bukkit, Spigot, Paper, Sponge, Bungee, JDA, Velocity supported, generically usable anywhere)
https://acfspigot.emc.gs
MIT License
561 stars 145 forks source link

"Expected whitespace" error when using tilde or caret in string arguments with Brigadier enabled #373

Open Mowstyl opened 2 years ago

Mowstyl commented 2 years ago

I've been using some commands that get coordinates as arguments for some time. Recently I've noticed they stopped working when trying to use relative coordinates. The error I get each time I try to execute one of those commands is: "Expected whitespace to end one argument, but found trailing data" That is shown when Brigadier throws SimpleCommandExceptionType DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR.

As a simple example, I've written this small command: `

@Subcommand("coords")
@Syntax("<x> <y> <z>")
public static void coordsCommand(CommandSender sender, String rawX, String rawY, @Single String rawZ) {
    sender.sendMessage("Coords: " + rawX + " " + rawY + " " + rawZ);
}

`

When not having enabled brigadier unstable API, everything works fine for both the Console and Player sender. With brigadier support enabled, the Console still gets the right result for any input, but the player receives said error when any of the arguments contains a tilde ~ or a caret ^. For example, "/gp coords 1 3 2" works but "/gp coords ~ ~ ~" doesn't. As I said this only happens when brigadier support is enabled. I know it's unstable but I think this has to be a bug and it has to be reported.

Since I don't really need brigadier I'll work without enabling it, yet I wonder if a CommandContext could be added that turns three coordinates into a Vector, making use of the native methods Minecraft has to calculate coordinates using relative or local coordinates.

Thanks for your attention and for creating such an incredible framework!

chickeneer commented 2 years ago

This is an issue with how the commands are processed by the server. Recently commands are being executed by the brigadier parser which does not allow ~ in the arguments. There is not sufficient API (yet) to properly implement Minecraft brigadier.