From bef2818537f3e4099849e5890a35d65df8c8d4c1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 14 Feb 2013 18:30:48 +1100 Subject: [PATCH] Fix forge support - #111 --- .../net/md_5/mendax/datainput/DataInputPacketReader.java | 6 +++++- proxy/src/main/java/net/md_5/bungee/InitialHandler.java | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/protocol/src/main/java/net/md_5/mendax/datainput/DataInputPacketReader.java b/protocol/src/main/java/net/md_5/mendax/datainput/DataInputPacketReader.java index 61f55d14..c697b9a0 100644 --- a/protocol/src/main/java/net/md_5/mendax/datainput/DataInputPacketReader.java +++ b/protocol/src/main/java/net/md_5/mendax/datainput/DataInputPacketReader.java @@ -61,7 +61,11 @@ public class DataInputPacketReader private static void readPacket(int packetId, DataInput in, byte[] buffer, int protocol) throws IOException { - Instruction[] packetDef = instructions[packetId + protocol]; + Instruction[] packetDef = null; + if ( packetId + protocol < instructions.length ) + { + packetDef = instructions[packetId + protocol]; + } if ( packetDef == null ) { diff --git a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java index 57eb988f..f8853531 100644 --- a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java @@ -61,7 +61,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo @Override public void handle(Packet1Login login) throws Exception { - Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting FORGE LOGIN" ); + Preconditions.checkState( thisState == State.LOGIN, "Not expecting FORGE LOGIN" ); Preconditions.checkState( forgeLogin == null, "Already received FORGE LOGIN" ); forgeLogin = login; stream.setProtocol( PacketDefinitions.FORGE_PROTOCOL ); @@ -149,7 +149,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo { Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" ); - UserConnection userCon = new UserConnection( socket, this, stream, handshake,forgeLogin,loginMessages ); + UserConnection userCon = new UserConnection( socket, this, stream, handshake, forgeLogin, loginMessages ); String server = ProxyServer.getInstance().getReconnectHandler().getServer( userCon ); ServerInfo s = BungeeCord.getInstance().config.getServers().get( server ); userCon.connect( s, true );