Skip to content

Commit 015a606

Browse files
committed
Replace some debug info with the actual cause
1 parent e34105e commit 015a606

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -582,35 +582,26 @@ protected void finishRead(ChannelHandlerContext ctx, Object msg) {
582582
* @param packet - the packet.
583583
*/
584584
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+
}
588589

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+
}
598598

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));
603602

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);
614605
}
615606
}
616607

0 commit comments

Comments
 (0)