@@ -582,35 +582,26 @@ protected void finishRead(ChannelHandlerContext ctx, Object msg) {
582
582
* @param packet - the packet.
583
583
*/
584
584
protected void handleLogin (Class <?> packetClass , Object packet ) {
585
- try {
586
- Class <?> loginClass = PACKET_LOGIN_CLIENT ;
587
- FieldAccessor loginClient = LOGIN_GAME_PROFILE ;
585
+ // Try to find the login packet class
586
+ if (PACKET_LOGIN_CLIENT == null ) {
587
+ PACKET_LOGIN_CLIENT = PacketType .Login .Client .START .getPacketClass ();
588
+ }
588
589
589
- // Initialize packet class and login
590
- if (loginClass == null ) {
591
- loginClass = PacketType .Login .Client .START .getPacketClass ();
592
- PACKET_LOGIN_CLIENT = loginClass ;
593
- }
594
- if (loginClient == null ) {
595
- loginClient = Accessors .getFieldAccessor (PACKET_LOGIN_CLIENT , MinecraftReflection .getGameProfileClass (), true );
596
- LOGIN_GAME_PROFILE = loginClient ;
597
- }
590
+ // If we can't, there's an issue
591
+ if (PACKET_LOGIN_CLIENT == null ) {
592
+ throw new IllegalStateException ("Failed to obtain login start packet. Did you build Spigot with BuildTools?" );
593
+ }
594
+
595
+ if (LOGIN_GAME_PROFILE == null ) {
596
+ LOGIN_GAME_PROFILE = Accessors .getFieldAccessor (PACKET_LOGIN_CLIENT , MinecraftReflection .getGameProfileClass (), true );
597
+ }
598
598
599
- // See if we are dealing with the login packet
600
- if (loginClass .equals (packetClass )) {
601
- // GameProfile profile = (GameProfile) loginClient.get(packet);
602
- WrappedGameProfile profile = WrappedGameProfile .fromHandle (loginClient .get (packet ));
599
+ // See if we are dealing with the login packet
600
+ if (PACKET_LOGIN_CLIENT .equals (packetClass )) {
601
+ WrappedGameProfile profile = WrappedGameProfile .fromHandle (LOGIN_GAME_PROFILE .get (packet ));
603
602
604
- // Save the channel injector
605
- factory .cacheInjector (profile .getName (), this );
606
- }
607
- } catch (IllegalArgumentException ex ) { // Thrown by FuzzyReflection#getFields()
608
- System .err .println (String .format ("[ProtocolLib] Encountered NPE in handleLogin(%s, %s)" , packetClass , packet ));
609
- System .err .println ("PACKET_LOGIN_CLIENT = " + PACKET_LOGIN_CLIENT );
610
- System .err .println ("LOGIN_GAME_PROFILE = " + LOGIN_GAME_PROFILE );
611
- System .err .println ("GameProfile class = " + MinecraftReflection .getGameProfileClass ());
612
- System .err .println ("Provide this information in a new or existing issue" );
613
- throw ex ;
603
+ // Save the channel injector
604
+ factory .cacheInjector (profile .getName (), this );
614
605
}
615
606
}
616
607
0 commit comments