Skip to content

Commit

Permalink
Fixes some exceptions regarding legacy connections on Velocity 1.7 cl…
Browse files Browse the repository at this point in the history
…ients
  • Loading branch information
paulzhng committed Aug 13, 2020
1 parent f8da84d commit 32142f9
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@

public class VelocityPlayerImpl implements IPlayer {

private static final Class<?> initialInboundConnectionClass;
private static final Field MINECRAFT_CONNECTION_FIELD;
private static final Field LEGACY_MINECRAFT_CONNECTION_FIELD;
private static final Field REMOTE_ADDRESS_FIELD;
private static final Method CLOSE_CHANNEL_METHOD;

static {
try {
MINECRAFT_CONNECTION_FIELD = ReflectionUtils.getPrivateField(Class.forName("com.velocitypowered.proxy.connection.client.InitialInboundConnection"), "connection");
initialInboundConnectionClass = Class.forName("com.velocitypowered.proxy.connection.client.InitialInboundConnection");
MINECRAFT_CONNECTION_FIELD = ReflectionUtils.getPrivateField(initialInboundConnectionClass, "connection");
LEGACY_MINECRAFT_CONNECTION_FIELD = ReflectionUtils.getPrivateField(Class.forName("com.velocitypowered.proxy.connection.client.HandshakeSessionHandler$LegacyInboundConnection"), "connection");

Class<?> minecraftConnection = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection");
Expand All @@ -36,7 +38,7 @@ public class VelocityPlayerImpl implements IPlayer {

public VelocityPlayerImpl(InboundConnection inboundConnection) {
this.inboundConnection = inboundConnection;
this.legacy = inboundConnection.getProtocolVersion().isUnknown() || inboundConnection.getProtocolVersion().isLegacy();
this.legacy = inboundConnection.getClass() != initialInboundConnectionClass;
this.ip = inboundConnection.getRemoteAddress().getAddress().getHostAddress();
}

Expand Down

0 comments on commit 32142f9

Please sign in to comment.