Add functionality to replicate #336
This commit is contained in:
parent
702f434db1
commit
d67acd7bc9
@ -56,4 +56,9 @@ public class ListenerInfo
|
||||
* Whether to set the local address when connecting to servers.
|
||||
*/
|
||||
private final boolean setLocalAddress;
|
||||
/**
|
||||
* Whether to pass the ping through when we can reliably get the target
|
||||
* server (force default server).
|
||||
*/
|
||||
private final boolean pingPassthrough;
|
||||
}
|
||||
|
@ -11,9 +11,6 @@ import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.tab.GlobalPing;
|
||||
import net.md_5.bungee.tab.Global;
|
||||
import net.md_5.bungee.tab.ServerUnique;
|
||||
import net.md_5.bungee.util.CaseInsensitiveMap;
|
||||
import net.md_5.bungee.util.CaseInsensitiveSet;
|
||||
|
||||
|
@ -213,8 +213,9 @@ public class YamlConfig implements ConfigurationAdapter
|
||||
value = DefaultTabList.GLOBAL_PING;
|
||||
}
|
||||
boolean setLocalAddress = get( "bind_local_address", true, val );
|
||||
boolean pingPassthrough = get( "ping_passthrough", false, val );
|
||||
|
||||
ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, fallbackServer, forceDefault, forced, value.clazz, setLocalAddress );
|
||||
ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, fallbackServer, forceDefault, forced, value.clazz, setLocalAddress, pingPassthrough );
|
||||
ret.add( info );
|
||||
}
|
||||
|
||||
|
@ -133,31 +133,37 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
|
||||
private void respondToPing()
|
||||
{
|
||||
try
|
||||
ServerInfo forced = AbstractReconnectManager.getForcedHost( this );
|
||||
final String motd = ( forced != null ) ? forced.getMotd() : listener.getMotd();
|
||||
|
||||
Callback<ServerPing> pingBack = new Callback<ServerPing>()
|
||||
{
|
||||
ServerInfo forced = AbstractReconnectManager.getForcedHost( this );
|
||||
String motd = listener.getMotd();
|
||||
if ( forced != null )
|
||||
@Override
|
||||
public void done(ServerPing result, Throwable error)
|
||||
{
|
||||
motd = forced.getMotd();
|
||||
if ( error != null )
|
||||
{
|
||||
result = new ServerPing( (byte) -1, "-1", "Error pinging remote server: " + Util.exception( error ), -1, -1 );
|
||||
}
|
||||
result = bungee.getPluginManager().callEvent( new ProxyPingEvent( InitialHandler.this, result ) ).getResponse();
|
||||
|
||||
String kickMessage = ChatColor.DARK_BLUE
|
||||
+ "\00" + result.getProtocolVersion()
|
||||
+ "\00" + result.getGameVersion()
|
||||
+ "\00" + result.getMotd()
|
||||
+ "\00" + result.getCurrentPlayers()
|
||||
+ "\00" + result.getMaxPlayers();
|
||||
BungeeCord.getInstance().getConnectionThrottle().unthrottle( getAddress().getAddress() );
|
||||
disconnect( kickMessage );
|
||||
}
|
||||
};
|
||||
|
||||
ServerPing response = new ServerPing( bungee.getProtocolVersion(), bungee.getGameVersion(),
|
||||
motd, 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();
|
||||
BungeeCord.getInstance().getConnectionThrottle().unthrottle( getAddress().getAddress() );
|
||||
disconnect( kickMessage );
|
||||
} catch ( Throwable t )
|
||||
if ( forced != null && listener.isPingPassthrough() )
|
||||
{
|
||||
t.printStackTrace();
|
||||
forced.ping( pingBack );
|
||||
} else
|
||||
{
|
||||
pingBack.done( new ServerPing( bungee.getProtocolVersion(), bungee.getGameVersion(), motd, bungee.getOnlineCount(), listener.getMaxPlayers() ), null );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user