Legacy forwarding fix

This commit is contained in:
Adrian Bergqvist 2023-02-09 18:13:01 +01:00
parent daac7c57d8
commit c751342ad8
No known key found for this signature in database
GPG Key ID: FAE7D8EDE225E686
2 changed files with 11 additions and 4 deletions

View File

@ -40,7 +40,7 @@ public class VelocityBackendChannelInitializer extends BackendChannelInitializer
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
ch.pipeline().addLast(ForgeConstants.MARKER_ADDER, new FMLMarkerAdder());
ch.pipeline().addLast(ForgeConstants.MARKER_ADDER, new FMLMarkerAdder(server));
ch.pipeline().addLast(ForgeConstants.HANDLER, new VelocityForgeBackendHandshakeHandler(server));
}
}

View File

@ -1,5 +1,8 @@
package org.adde0109.ambassador.velocity.backend;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
import com.velocitypowered.proxy.connection.ConnectionTypes;
import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
import com.velocitypowered.proxy.network.Connections;
@ -9,13 +12,17 @@ import io.netty.handler.codec.MessageToMessageEncoder;
import org.adde0109.ambassador.forge.ForgeConstants;
import org.adde0109.ambassador.forge.ForgeFMLConnectionType;
import java.util.ArrayList;
import java.util.List;
import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants.HANDSHAKE_HOSTNAME_TOKEN;
public class FMLMarkerAdder extends MessageToMessageEncoder<Handshake> {
public FMLMarkerAdder() {
final VelocityServer server;
public FMLMarkerAdder(VelocityServer server) {
super(Handshake.class);
this.server = server;
}
@Override
@ -23,7 +30,7 @@ public class FMLMarkerAdder extends MessageToMessageEncoder<Handshake> {
MinecraftConnection connection = (MinecraftConnection) ctx.pipeline().get(Connections.HANDLER);
VelocityServerConnection serverConnection = (VelocityServerConnection) connection.getAssociation();
if (serverConnection.getPlayer().getConnection().getType() instanceof ForgeFMLConnectionType FMLType) {
if (serverConnection.getPlayer().getConnection().getType() instanceof ForgeFMLConnectionType FMLType && server.getConfiguration().getPlayerInfoForwardingMode() != PlayerInfoForwarding.LEGACY) {
msg.setServerAddress(msg.getServerAddress() + (FMLType == ForgeConstants.ForgeFML3 ? ForgeConstants.FML3Marker : ForgeConstants.FML2Marker));
}
out.add(msg);