Merge remote-tracking branch 'origin/non-api' into non-api

This commit is contained in:
Adrian Bergqvist 2023-09-02 00:52:47 +02:00
commit 6983b7abf1
No known key found for this signature in database
GPG Key ID: FAE7D8EDE225E686
2 changed files with 7 additions and 4 deletions

View File

@ -17,10 +17,12 @@ public class VelocityServerChannelInitializer extends ServerChannelInitializer {
private Method INIT_CHANNEL;
private final ChannelInitializer<?> delegate;
private final VelocityServer server;
public VelocityServerChannelInitializer(ChannelInitializer<?> delegate,VelocityServer server) {
super(server);
this.delegate = delegate;
this.server = server;
try {
INIT_CHANNEL = delegate.getClass().getDeclaredMethod("initChannel", Channel.class);
INIT_CHANNEL.setAccessible(true);
@ -41,7 +43,7 @@ public class VelocityServerChannelInitializer extends ServerChannelInitializer {
super.initChannel(ch);
MinecraftConnection handler = ch.pipeline().get(MinecraftConnection.class);
HandshakeSessionHandler originalSessionHandler = (HandshakeSessionHandler) handler.getSessionHandler();
handler.setSessionHandler(new VelocityHandshakeSessionHandler(originalSessionHandler, handler));
handler.setSessionHandler(new VelocityHandshakeSessionHandler(originalSessionHandler, handler, server));
}
}
}

View File

@ -1,8 +1,8 @@
package org.adde0109.ambassador.velocity.client;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.ConnectionTypes;
import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler;
import com.velocitypowered.proxy.network.Connections;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
@ -11,11 +11,12 @@ import com.velocitypowered.proxy.protocol.packet.Handshake;
import io.netty.buffer.ByteBuf;
import org.adde0109.ambassador.forge.ForgeConstants;
public class VelocityHandshakeSessionHandler implements MinecraftSessionHandler {
public class VelocityHandshakeSessionHandler extends HandshakeSessionHandler {
private final HandshakeSessionHandler original;
private final MinecraftConnection connection;
public VelocityHandshakeSessionHandler(HandshakeSessionHandler original, MinecraftConnection connection) {
public VelocityHandshakeSessionHandler(HandshakeSessionHandler original, MinecraftConnection connection, VelocityServer server) {
super(connection, server);
this.original = original;
this.connection = connection;
}