3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Fix some localization and API issues

Resolves #536
Dieser Commit ist enthalten in:
Andrew Steinborn 2021-07-08 03:08:02 -04:00
Ursprung a037aebfa0
Commit 0e0a14498f
2 geänderte Dateien mit 23 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -281,18 +281,20 @@ public class VelocityCommand implements SimpleCommand {
return; return;
} }
TranslatableComponent.Builder output = Component.translatable() TextComponent.Builder listBuilder = Component.text();
.key("velocity.command.plugins-list")
.color(NamedTextColor.YELLOW);
for (int i = 0; i < pluginCount; i++) { for (int i = 0; i < pluginCount; i++) {
PluginContainer plugin = plugins.get(i); PluginContainer plugin = plugins.get(i);
output.append(componentForPlugin(plugin.getDescription())); listBuilder.append(componentForPlugin(plugin.getDescription()));
if (i + 1 < pluginCount) { if (i + 1 < pluginCount) {
output.append(Component.text(", ")); listBuilder.append(Component.text(", "));
} }
} }
source.sendMessage(Identity.nil(), output.build()); TranslatableComponent.Builder output = Component.translatable()
.key("velocity.command.plugins-list")
.color(NamedTextColor.YELLOW)
.args(listBuilder.build());
source.sendMessage(Identity.nil(), output);
} }
private TextComponent componentForPlugin(PluginDescription description) { private TextComponent componentForPlugin(PluginDescription description) {
@ -361,8 +363,8 @@ public class VelocityCommand implements SimpleCommand {
JsonArray connectOrder = new JsonArray(); JsonArray connectOrder = new JsonArray();
List<String> attemptedConnectionOrder = ImmutableList.copyOf( List<String> attemptedConnectionOrder = ImmutableList.copyOf(
server.getConfiguration().getAttemptConnectionOrder()); server.getConfiguration().getAttemptConnectionOrder());
for (int i = 0; i < attemptedConnectionOrder.size(); i++) { for (String s : attemptedConnectionOrder) {
connectOrder.add(attemptedConnectionOrder.get(i)); connectOrder.add(s);
} }
JsonObject proxyConfig = InformationUtils.collectProxyConfig(server.getConfiguration()); JsonObject proxyConfig = InformationUtils.collectProxyConfig(server.getConfiguration());

Datei anzeigen

@ -614,7 +614,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
case CONNECTION_IN_PROGRESS: case CONNECTION_IN_PROGRESS:
// Fatal case // Fatal case
case CONNECTION_CANCELLED: case CONNECTION_CANCELLED:
disconnect(status.getReasonComponent().orElse(res.getMessageComponent())); Component fallbackMsg = res.getMessageComponent();
if (fallbackMsg == null) {
fallbackMsg = friendlyReason;
}
disconnect(status.getReasonComponent().orElse(fallbackMsg));
break; break;
case SERVER_DISCONNECTED: case SERVER_DISCONNECTED:
Component reason = status.getReasonComponent() Component reason = status.getReasonComponent()
@ -623,10 +627,14 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
getProtocolVersion()), ((Impl) status).isSafe()); getProtocolVersion()), ((Impl) status).isSafe());
break; break;
case SUCCESS: case SUCCESS:
sendMessage(Component.translatable("velocity.error.moved-to-new-server", Component requestedMessage = res.getMessageComponent();
if (requestedMessage == null) {
requestedMessage = Component.translatable("velocity.error.moved-to-new-server",
NamedTextColor.RED, NamedTextColor.RED,
Component.text(originalEvent.getServer().getServerInfo().getName()), Component.text(originalEvent.getServer().getServerInfo().getName()),
friendlyReason)); friendlyReason);
}
sendMessage(requestedMessage);
break; break;
default: default:
// The only remaining value is successful (no need to do anything!) // The only remaining value is successful (no need to do anything!)