mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-14 11:05:10 -05:00
Added intended protocol state to PreConnectEvent
This commit is contained in:
parent
af9ff84fbb
commit
a0f35c8ae0
2 changed files with 9 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<Packet> {
|
|||
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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue