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 f88535319..1b0acc9d6 100644 --- a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java @@ -44,6 +44,10 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo private PacketFDEncryptionRequest request; private List loginMessages = new ArrayList<>(); private State thisState = State.HANDSHAKE; + private static final PacketFAPluginMessage forgeMods = new PacketFAPluginMessage( "FML", new byte[] + { + 0, 0, 0, 0, 0, 2 + } ); public InitialHandler(Socket socket, ListenerInfo info) throws IOException { @@ -106,6 +110,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo { Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" ); this.handshake = handshake; + stream.write( forgeMods ); request = EncryptionUtil.encryptRequest(); stream.write( request ); thisState = State.ENCRYPT; @@ -166,6 +171,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo { byte[] buf = stream.readPacket(); DefinedPacket packet = DefinedPacket.packet( buf ); + System.out.println( packet ); packet.handle( this ); } } catch ( Exception ex ) diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java index da3cd2d53..9c69902e1 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -55,18 +55,30 @@ public class ServerConnection extends GenericConnection implements Server } stream.write( handshake ); - for ( PacketFAPluginMessage message : user.loginMessages ) - { - stream.write( message ); - } - stream.write( PacketCDClientStatus.CLIENT_LOGIN ); stream.readPacket(); - byte[] loginResponse = stream.readPacket(); - if ( Util.getId( loginResponse ) == 0xFF ) + byte[] loginResponse = null; + loop: + while ( true ) { - throw new KickException( "[Kicked] " + new PacketFFKick( loginResponse ).message ); + loginResponse = stream.readPacket(); + int id = Util.getId( loginResponse ); + switch ( id ) + { + case 0x01: + break loop; + case 0xFA: + for ( PacketFAPluginMessage message : user.loginMessages ) + { + stream.write( message ); + } + break; + case 0xFF: + throw new KickException( "[Kicked] " + new PacketFFKick( loginResponse ).message ); + default: + throw new IllegalArgumentException( "Unknown login packet " + Util.hex( id ) ); + } } Packet1Login login = new Packet1Login( loginResponse );