#3192, #3210: Handle null ServerPing#getPlayers upon a legacy ping

This commit is contained in:
Ivan Pekov 2022-07-02 10:35:54 +10:00 committed by md_5
parent d221e52929
commit 587fb37bdf
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -208,14 +208,14 @@ public class InitialHandler extends PacketHandler implements PendingConnection
+ "\00" + 127 + "\00" + 127
+ '\00' + legacy.getVersion().getName() + '\00' + legacy.getVersion().getName()
+ '\00' + getFirstLine( legacy.getDescription() ) + '\00' + getFirstLine( legacy.getDescription() )
+ '\00' + legacy.getPlayers().getOnline() + '\00' + ( ( legacy.getPlayers() != null ) ? legacy.getPlayers().getOnline() : "-1" )
+ '\00' + legacy.getPlayers().getMax(); + '\00' + ( ( legacy.getPlayers() != null ) ? legacy.getPlayers().getMax() : "-1" );
} else } else
{ {
// Clients <= 1.3 don't support colored motds because the color char is used as delimiter // Clients <= 1.3 don't support colored motds because the color char is used as delimiter
kickMessage = ChatColor.stripColor( getFirstLine( legacy.getDescription() ) ) kickMessage = ChatColor.stripColor( getFirstLine( legacy.getDescription() ) )
+ '\u00a7' + legacy.getPlayers().getOnline() + '\u00a7' + ( ( legacy.getPlayers() != null ) ? legacy.getPlayers().getOnline() : "-1" )
+ '\u00a7' + legacy.getPlayers().getMax(); + '\u00a7' + ( ( legacy.getPlayers() != null ) ? legacy.getPlayers().getMax() : "-1" );
} }
ch.close( kickMessage ); ch.close( kickMessage );