diff --git a/src/main/java/net/raphimc/viaproxy/plugins/events/PreConnectEvent.java b/src/main/java/net/raphimc/viaproxy/plugins/events/PreConnectEvent.java index 08dad74..3d0cefe 100644 --- a/src/main/java/net/raphimc/viaproxy/plugins/events/PreConnectEvent.java +++ b/src/main/java/net/raphimc/viaproxy/plugins/events/PreConnectEvent.java @@ -20,6 +20,7 @@ package net.raphimc.viaproxy.plugins.events; import com.google.common.net.HostAndPort; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import io.netty.channel.Channel; +import net.raphimc.netminecraft.constants.IntendedState; import net.raphimc.viaproxy.plugins.events.types.EventCancellable; import java.net.SocketAddress; @@ -30,15 +31,17 @@ public class PreConnectEvent extends EventCancellable { private ProtocolVersion serverVersion; private final ProtocolVersion clientVersion; private final HostAndPort clientHandshakeAddress; + private final IntendedState intendedState; private final Channel clientChannel; private String cancelMessage = "§cCould not connect to the backend server! (Server is blacklisted)"; - public PreConnectEvent(final SocketAddress serverAddress, final ProtocolVersion serverVersion, final ProtocolVersion clientVersion, final HostAndPort clientHandshakeAddress, final Channel clientChannel) { + public PreConnectEvent(final SocketAddress serverAddress, final ProtocolVersion serverVersion, final ProtocolVersion clientVersion, final HostAndPort clientHandshakeAddress, final IntendedState intendedState, final Channel clientChannel) { this.serverAddress = serverAddress; this.serverVersion = serverVersion; this.clientVersion = clientVersion; this.clientHandshakeAddress = clientHandshakeAddress; + this.intendedState = intendedState; this.clientChannel = clientChannel; } @@ -66,6 +69,10 @@ public class PreConnectEvent extends EventCancellable { return this.clientHandshakeAddress; } + public IntendedState getIntendedState() { + return this.intendedState; + } + public Channel getClientChannel() { return this.clientChannel; } diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java index c57aee4..88bca92 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java @@ -186,7 +186,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler { clientHandshakeAddress = null; } - final PreConnectEvent preConnectEvent = new PreConnectEvent(serverAddress, serverVersion, clientVersion, clientHandshakeAddress, this.proxyConnection.getC2P()); + final PreConnectEvent preConnectEvent = new PreConnectEvent(serverAddress, serverVersion, clientVersion, clientHandshakeAddress, packet.intendedState, this.proxyConnection.getC2P()); if (ViaProxy.EVENT_MANAGER.call(preConnectEvent).isCancelled()) { this.proxyConnection.kickClient(preConnectEvent.getCancelMessage()); }