-
-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The /server command cannot be used for Chinese name servers #1362
Comments
This is a Brigadier issue, see Mojang/brigadier#103 |
Given that Velocity server names can contain non-ASCII characters, would it be more appropriate to use Brigadier's |
does brig auto quote them for you or would that need to be handled elsewhere? I didn't think that there was a solution here which didn't downgrade the UX in a manner which was pretty bleh to substantiate a setup which is niche and often caused other issues |
|
I believe the desired suggestions can be generated like so (low optimization code, just proof of concept with maximum readibility): RequiredArgumentBuilder.argument("SERVER_ARG", StringArgumentType.string())
.suggests((ctx, builder) -> {
String soFar = builder.getRemaining();
if (soFar.isEmpty()) {
// Suggest all names
for (final RegisteredServer sv : server.getAllServers()) {
final String serverName = sv.getServerInfo().getName();
// Note: Unquoted strings do not actually accept all of ASCII
// They only accept the characters defined by `StringReader#isAllowedInUnquotedString`
if (CharMatcher.ascii().matchesAllOf(serverName)) {
builder.suggest(serverName);
} else {
// Quote names that have characters which require quotes
builder.suggest('"' + serverName + '"');
}
}
return builder.buildFuture();
} else if (soFar.charAt(0) == '"') {
// Suggest all names within quotes
soFar = soFar.substring(1);
for (final RegisteredServer sv : server.getAllServers()) {
final String serverName = sv.getServerInfo().getName();
if (serverName.startsWith(soFar)) {
builder.suggest('"' + serverName + '"');
}
}
} else {
// Only suggest names that don't need quotes
for (final RegisteredServer sv : server.getAllServers()) {
final String serverName = sv.getServerInfo().getName();
if (CharMatcher.ascii().matchesAllOf(serverName) && serverName.startsWith(soFar)) {
builder.suggest(serverName);
}
}
}
return builder.buildFuture();
})
|
it's not something that I will be putting effort into, especially with my current state of health. If somebody wants to PR and test it, I or somebody might be able to get around to it, but, this is generally a bottom of the barrel sorta thing. |
I noticed this is a duplicate of #1220 |
When I try to use /server in my server, the Chinese name of the server is inaccessible
The text was updated successfully, but these errors were encountered: