diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java index cb6384d7a..49571ec9f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java @@ -24,9 +24,11 @@ import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation; import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket; import com.velocitypowered.proxy.network.packet.serverbound.ServerboundHandshakePacket; import java.net.InetSocketAddress; +import java.util.Locale; import java.util.Optional; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.translation.GlobalTranslator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -76,9 +78,11 @@ public final class InitialInboundConnection implements InboundConnection, * @param reason the reason for disconnecting */ public void disconnect(Component reason) { + Component translated = GlobalTranslator.render(reason, Locale.getDefault()); + logger.info("{} has disconnected: {}", this, - LegacyComponentSerializer.legacySection().serialize(reason)); - connection.closeWith(ClientboundDisconnectPacket.create(reason, protocolVersion())); + LegacyComponentSerializer.legacySection().serialize(translated)); + connection.closeWith(ClientboundDisconnectPacket.create(translated, protocolVersion())); } /** @@ -86,6 +90,7 @@ public final class InitialInboundConnection implements InboundConnection, * @param reason the reason for disconnecting */ public void disconnectQuietly(Component reason) { - connection.closeWith(ClientboundDisconnectPacket.create(reason, protocolVersion())); + Component translated = GlobalTranslator.render(reason, Locale.getDefault()); + connection.closeWith(ClientboundDisconnectPacket.create(translated, protocolVersion())); } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java index 36ec63cf8..008644ff3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java @@ -47,7 +47,6 @@ import com.velocitypowered.proxy.config.VelocityConfiguration; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.network.StateRegistry; -import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket; import com.velocitypowered.proxy.network.packet.clientbound.ClientboundEncryptionRequestPacket; import com.velocitypowered.proxy.network.packet.clientbound.ClientboundServerLoginSuccessPacket; import com.velocitypowered.proxy.network.packet.clientbound.ClientboundSetCompressionPacket; @@ -59,12 +58,14 @@ import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.MessageDigest; import java.util.Arrays; +import java.util.Locale; import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.ThreadLocalRandom; import net.kyori.adventure.text.Component; +import net.kyori.adventure.translation.GlobalTranslator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.asynchttpclient.ListenableFuture; @@ -191,8 +192,9 @@ public class LoginSessionHandler implements MinecraftSessionHandler { Optional disconnectReason = result.denialReason(); if (disconnectReason.isPresent()) { // The component is guaranteed to be provided if the connection was denied. - mcConnection.closeWith(ClientboundDisconnectPacket.create(disconnectReason.get(), - inbound.protocolVersion())); + Component disconnectReasonTranslated = GlobalTranslator.render(disconnectReason.get(), + Locale.getDefault()); + inbound.disconnect(disconnectReasonTranslated); return; }