Fix server ping method.

This commit is contained in:
md_5 2013-02-10 20:18:08 +11:00
parent 154722eacc
commit c5e15697a4

View File

@ -48,24 +48,21 @@ public class BungeeServerInfo extends ServerInfo
@Override @Override
public void run() public void run()
{ {
try try ( Socket socket = new Socket(); )
{ {
Socket socket = new Socket();
socket.connect( getAddress() ); socket.connect( getAddress() );
try ( DataOutputStream out = new DataOutputStream( socket.getOutputStream() ) )
{
out.write( 0xFE );
out.write( 0x01 );
}
try ( PacketStream in = new PacketStream( socket.getInputStream() ) )
{
PacketFFKick response = new PacketFFKick( in.readPacket() );
String[] split = response.message.split( "\00" ); DataOutputStream out = new DataOutputStream( socket.getOutputStream() );
out.write( 0xFE );
out.write( 0x01 );
ServerPing ping = new ServerPing( Byte.parseByte( split[1] ), split[2], split[3], Integer.parseInt( split[4] ), Integer.parseInt( split[5] ) ); PacketStream in = new PacketStream( socket.getInputStream() );
callback.done( ping, null ); PacketFFKick response = new PacketFFKick( in.readPacket() );
}
String[] split = response.message.split( "\00" );
ServerPing ping = new ServerPing( Byte.parseByte( split[1] ), split[2], split[3], Integer.parseInt( split[4] ), Integer.parseInt( split[5] ) );
callback.done( ping, null );
} catch ( Throwable t ) } catch ( Throwable t )
{ {
callback.done( null, t ); callback.done( null, t );