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

fix backend not receiving brands from 1.20.2 clients (#1147)

Dieser Commit ist enthalten in:
AoElite 2023-11-30 15:18:40 -05:00 committet von GitHub
Ursprung 8dcc7ee37e
Commit e5176717a9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 14 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -32,6 +32,8 @@ import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate; import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate;
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -46,6 +48,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
private static final Logger logger = LogManager.getLogger(ClientConfigSessionHandler.class); private static final Logger logger = LogManager.getLogger(ClientConfigSessionHandler.class);
private final VelocityServer server; private final VelocityServer server;
private final ConnectedPlayer player; private final ConnectedPlayer player;
private String brandChannel = null;
private CompletableFuture<Void> configSwitchFuture; private CompletableFuture<Void> configSwitchFuture;
@ -116,8 +119,9 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
String brand = PluginMessageUtil.readBrandMessage(packet.content()); String brand = PluginMessageUtil.readBrandMessage(packet.content());
server.getEventManager().fireAndForget(new PlayerClientBrandEvent(player, brand)); server.getEventManager().fireAndForget(new PlayerClientBrandEvent(player, brand));
player.setClientBrand(brand); player.setClientBrand(brand);
brandChannel = packet.getChannel();
// Client sends `minecraft:brand` packet immediately after Login, // Client sends `minecraft:brand` packet immediately after Login,
// but at this time the backend server may not be ready, just discard it. // but at this time the backend server may not be ready
} else { } else {
serverConn.ensureConnected().write(packet.retain()); serverConn.ensureConnected().write(packet.retain());
} }
@ -182,6 +186,14 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
* @return a future that completes when the config stage is finished * @return a future that completes when the config stage is finished
*/ */
public CompletableFuture<Void> handleBackendFinishUpdate(VelocityServerConnection serverConn) { public CompletableFuture<Void> handleBackendFinishUpdate(VelocityServerConnection serverConn) {
String brand = serverConn.getPlayer().getClientBrand();
if (brand != null && brandChannel != null) {
ByteBuf buf = Unpooled.buffer();
buf.writeCharSequence(brand, StandardCharsets.UTF_8);
PluginMessage brandPacket = new PluginMessage(brandChannel, buf);
serverConn.ensureConnected().write(brandPacket);
}
player.getConnection().write(new FinishedUpdate()); player.getConnection().write(new FinishedUpdate());
serverConn.ensureConnected().write(new FinishedUpdate()); serverConn.ensureConnected().write(new FinishedUpdate());
return configSwitchFuture; return configSwitchFuture;

Datei anzeigen

@ -318,9 +318,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
String brand = PluginMessageUtil.readBrandMessage(packet.content()); String brand = PluginMessageUtil.readBrandMessage(packet.content());
server.getEventManager().fireAndForget(new PlayerClientBrandEvent(player, brand)); server.getEventManager().fireAndForget(new PlayerClientBrandEvent(player, brand));
player.setClientBrand(brand); player.setClientBrand(brand);
backendConn.write( backendConn.write(packet.retain());
PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(),
player.getProtocolVersion()));
} else if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) { } else if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) {
return true; return true;
} else { } else {