Command Parameter error when use other language in sponge 8.0

This is my Command Parameters.

public static final Parameter.Value NAME = Parameter.string().key(“name”).build();

This is my command “/mycommand create español”

Then When i typing in the chat It shows this error in chat.

Expected whitespace to end one argument, but found trailing data.

but When I use english language e.g. “/mycommand create spain” It not error.

How can I use other language in command parameter without error ?

Please help me.

So I was curious about this so I took a look myself.

Congratulations, you have found a bug in Minecraft. In particular the brigadier system. At least as far as I can trace it (I havent decompiled anything). This is as far as I got.

Anyway solutions. First I would report it to MC. But as for a solution.

  1. using remainingJoinedStrings does bypass the issue. Not ideal

  2. using a custom parser that runs remaining. Also not ideal. But you maybe able to set the cursor to the end of the word. If so the rest of the command system should work normally from that point

Edit:

playing around with the second option, I think I have found a solution. This is my custom parser

    .addParser((parameterKey, reader, context) -> {
        String remaining = reader.remaining();
	    int index = remaining.indexOf(" ");
	    if (index == -1 && remaining.isEmpty()) { //If no data was entered then reject
	        return Optional.empty();
        } else if (index == -1) {
	        index = remaining.length(); //If no more arguments left, then this is the last
        }
	    String result = remaining.substring(0, index); //gets the word

	    //this moves the cursor over the word
					
	    for (int i = 0; i < result.length(); i++) {
	        reader.parseChar();
            //reader.skipWhitespace(); <--- this doesn't do what I expected which was to move the cursor over by one so I used parseChar to replicate that
	    }
	    return Optional.of(result);
    })
1 Like

Thank for you care!