From 06e732d8c7776eeb632064f3e833260a718ad34c Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 1 Jul 2013 21:20:18 +1000 Subject: [PATCH] Close #474 - 1.5 ping to 1.6 bungee --- .../bungee/connection/InitialHandler.java | 42 +++++++++++-------- .../reconnect/AbstractReconnectManager.java | 5 +++ 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 53536404..f76efc3e 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -142,25 +142,31 @@ public class InitialHandler extends PacketHandler implements PendingConnection private void respondToPing() { - ServerInfo forced = AbstractReconnectManager.getForcedHost( this ); - String motd = listener.getMotd(); - if ( forced != null ) + try { - motd = forced.getMotd(); + ServerInfo forced = AbstractReconnectManager.getForcedHost( this ); + String motd = listener.getMotd(); + if ( forced != null ) + { + motd = forced.getMotd(); + } + + ServerPing response = new ServerPing( bungee.getProtocolVersion(), bungee.getGameVersion(), + listener.getMotd(), bungee.getOnlineCount(), listener.getMaxPlayers() ); + + response = bungee.getPluginManager().callEvent( new ProxyPingEvent( InitialHandler.this, response ) ).getResponse(); + + String kickMessage = ChatColor.DARK_BLUE + + "\00" + response.getProtocolVersion() + + "\00" + response.getGameVersion() + + "\00" + response.getMotd() + + "\00" + response.getCurrentPlayers() + + "\00" + response.getMaxPlayers(); + disconnect( kickMessage ); + } catch ( Throwable t ) + { + t.printStackTrace(); } - - ServerPing response = new ServerPing( bungee.getProtocolVersion(), bungee.getGameVersion(), - listener.getMotd(), bungee.getOnlineCount(), listener.getMaxPlayers() ); - - response = bungee.getPluginManager().callEvent( new ProxyPingEvent( InitialHandler.this, response ) ).getResponse(); - - String kickMessage = ChatColor.DARK_BLUE - + "\00" + response.getProtocolVersion() - + "\00" + response.getGameVersion() - + "\00" + response.getMotd() - + "\00" + response.getCurrentPlayers() - + "\00" + response.getMaxPlayers(); - disconnect( kickMessage ); } @Override @@ -173,7 +179,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection { respondToPing(); } - }, 1000, TimeUnit.MILLISECONDS ); + }, 500, TimeUnit.MILLISECONDS ); } @Override diff --git a/proxy/src/main/java/net/md_5/bungee/reconnect/AbstractReconnectManager.java b/proxy/src/main/java/net/md_5/bungee/reconnect/AbstractReconnectManager.java index a675270e..2cd0c280 100644 --- a/proxy/src/main/java/net/md_5/bungee/reconnect/AbstractReconnectManager.java +++ b/proxy/src/main/java/net/md_5/bungee/reconnect/AbstractReconnectManager.java @@ -30,6 +30,11 @@ public abstract class AbstractReconnectManager implements ReconnectHandler public static ServerInfo getForcedHost(PendingConnection con) { + if ( con.getVirtualHost() == null ) + { + return null; + } + String forced = con.getListener().getForcedHosts().get( con.getVirtualHost().getHostString() ); if ( forced == null && con.getListener().isForceDefault() )