[SPIGOT-7187] Support non-ASCII characters in Brigadier commands Created: 23/Nov/22  Updated: 25/Dec/24

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Matthias Ngeo Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: Craftbukkit
Environment:

NIL


Version: 3608-Spigot-6198b5a-b5aa0be (1.19.2)
Guidelines Read: Yes

 Description   

Firstly, I apologize if this isn't the right place for discussing this.

I figured it will be better if I got a general consensus on whether Spigot is willing to accept a pull request for this.

In recent versions of Spigot (1.19+), executing/parsing of commands performed by players is routed through Brigadier. However, Brigadier's `StringReader.readUnquoted()` method only understands ASCII characters, https://github.com/Mojang/brigadier/blob/master/src/main/java/com/mojang/brigadier/StringReader.java#L169, what this means for end-users is the inability to use non-ASCII as arguments/command names, https://github.com/Pante/chimera/issues/329#issuecomment-962440145.

I've tried creating a issue for it in Brigadier, almost a year ago, https://github.com/Mojang/brigadier/issues/103, but like all other issues was ignored.

I've noticed that Spigot contains its own copy of modified Brigadier classes like `CommandDispatcher` and `CommandNode`. Will Spigot be willing to accept a patch which contains a modified `StringReader.readUnquoted()` that fixes this issue?



 Comments   
Comment by Matthias Ngeo [ 26/Nov/22 ]

Yup, I understand that. I guess the question is whether incorrect highlighting but able to execute is better than completely not working?

Comment by Black Hole [ 24/Nov/22 ]

The client is parsing the whole command tree. So non-standard args will work for value arguments. But for literal arguments, like sub commands, it will fail to parse the command node and likely display red for every argument behind that, too.

Comment by Matthias Ngeo [ 24/Nov/22 ]

Re-thinking about it, nuking `StringReader.readUnquoted()` may not be the best approach since it's also used to parse SNBT strings which doesn't support unquoted non-ASCII characters

Comment by Matthias Ngeo [ 24/Nov/22 ]

From what I understand, it is possible to alter the behavior of ` StringReader.readUnquoted()` while maintaining the interface, similar to the `CommandNode,canUse(...)`.

// CraftBukkit start
    public synchronized boolean canUse(final S source) {
        if (source instanceof CommandListenerWrapper) {
            try
{                 ((CommandListenerWrapper) source).currentCommand = this;                 return requirement.test(source);             }
finally
{                 ((CommandListenerWrapper) source).currentCommand = null;             }
        }
        // CraftBukkit end
        return requirement.test(source);
    }

 

How so will the client fail though? I believe that the client will only crash if we return a type that's unsupported. Highlighting might not work as intended but I believe that it's still a major improvement over completely not working.

Comment by Black Hole [ 23/Nov/22 ]

Even if Spigot patches that class the client is also using Brigadier and will likely fail.

Generated at Tue Apr 15 09:41:54 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.