From b723d0ae6d8f7ea7ba6b3ff93e7104ddc73f7748 Mon Sep 17 00:00:00 2001 From: Adrian Bergqvist Date: Thu, 27 Oct 2022 23:00:04 +0200 Subject: [PATCH] Works with newer Velocity versions --- .../ambassador/forge/FML2ClientConnectionPhase.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/adde0109/ambassador/forge/FML2ClientConnectionPhase.java b/src/main/java/org/adde0109/ambassador/forge/FML2ClientConnectionPhase.java index af889e5..0f3d5f3 100644 --- a/src/main/java/org/adde0109/ambassador/forge/FML2ClientConnectionPhase.java +++ b/src/main/java/org/adde0109/ambassador/forge/FML2ClientConnectionPhase.java @@ -7,7 +7,6 @@ import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.connection.client.LoginSessionHandler; import com.velocitypowered.proxy.protocol.ProtocolUtils; import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage; import io.netty.buffer.ByteBuf; @@ -36,8 +35,18 @@ public class FML2ClientConnectionPhase extends VelocityForgeClientConnectionPhas private static final Method CONNECT_TO_INITIAL_SERVER; static { + Class clazz; try { - CONNECT_TO_INITIAL_SERVER = LoginSessionHandler.class.getDeclaredMethod("connectToInitialServer", ConnectedPlayer.class); + clazz = Class.forName("com.velocitypowered.proxy.connection.client.LoginSessionHandler"); + } catch (ClassNotFoundException ignored){ + try { + clazz = Class.forName("com.velocitypowered.proxy.connection.client.AuthSessionHandler"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + try { + CONNECT_TO_INITIAL_SERVER = clazz.getDeclaredMethod("connectToInitialServer", ConnectedPlayer.class); CONNECT_TO_INITIAL_SERVER.setAccessible(true); } catch (ReflectiveOperationException e) { throw new RuntimeException(e);