From 2252bb27c67b306f20a727ebd2860b992a369ed9 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 29 Oct 2012 18:23:12 +1100 Subject: [PATCH] Support 1.3 pings. --- src/main/java/net/md_5/bungee/InitialHandler.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/md_5/bungee/InitialHandler.java b/src/main/java/net/md_5/bungee/InitialHandler.java index 724f1dfb..b4c67776 100644 --- a/src/main/java/net/md_5/bungee/InitialHandler.java +++ b/src/main/java/net/md_5/bungee/InitialHandler.java @@ -77,13 +77,24 @@ public class InitialHandler implements Runnable userCon.connect(BungeeCord.instance.config.getServer(handshake.username, handshake.host)); break; case 0xFE: + socket.setSoTimeout(100); + boolean newPing = true; + try + { + socket.getInputStream().read(); + newPing = false; + } catch (IOException ex) + { + } Configuration conf = BungeeCord.instance.config; - throw new KickException(ChatColor.COLOR_CHAR + "1" + String ping = (newPing) ? ChatColor.COLOR_CHAR + "1" + "\00" + conf.protcolVersion + "\00" + conf.gameVersion + "\00" + conf.motd + "\00" + BungeeCord.instance.connections.size() - + "\00" + conf.maxPlayers); + + "\00" + conf.maxPlayers + : conf.motd + ChatColor.COLOR_CHAR + BungeeCord.instance.connections.size() + ChatColor.COLOR_CHAR + conf.maxPlayers; + throw new KickException(ping); default: throw new IllegalArgumentException("Wasn't ready for packet id " + Util.hex(id)); }