From 550ca58a0956255b317dfac68ffbdb13dbb80785 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 10 Oct 2023 18:05:05 +0100 Subject: [PATCH] Actually send plugin message registration to backend servers I don't see where this was ever done, and don't see how plugin messaging could of ever worked, at least within the confines of CB and co, given the fact that we never seemed to be sending this to the backend? --- .../backend/BackendPlaySessionHandler.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index ffa0c8391..5a42d2922 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -18,6 +18,7 @@ package com.velocitypowered.proxy.connection.backend; import static com.velocitypowered.proxy.connection.backend.BungeeCordMessageResponder.getBungeeCordChannel; +import static com.velocitypowered.proxy.protocol.util.PluginMessageUtil.constructChannelsPacket; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -61,6 +62,8 @@ import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.handler.timeout.ReadTimeoutException; + +import java.util.Collection; import java.util.regex.Pattern; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -105,12 +108,20 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { public void activated() { serverConn.getServer().addPlayer(serverConn.getPlayer()); + MinecraftConnection serverMc = serverConn.ensureConnected(); if (server.getConfiguration().isBungeePluginChannelEnabled()) { - MinecraftConnection serverMc = serverConn.ensureConnected(); serverMc.write(PluginMessageUtil.constructChannelsPacket(serverMc.getProtocolVersion(), ImmutableList.of(getBungeeCordChannel(serverMc.getProtocolVersion())) )); } + + Collection channels = + server.getChannelRegistrar().getChannelsForProtocol(serverConn.getPlayer().getProtocolVersion()); + if (!channels.isEmpty()) { + PluginMessage register = constructChannelsPacket(serverConn.getPlayer().getProtocolVersion(), channels); + serverMc.write(register); + } + } @Override