Allow async ping to be toggled off as needed

This commit is contained in:
Tux 2016-01-10 14:30:17 -05:00
parent ea2cb74be6
commit 11d93e8e91
3 changed files with 8 additions and 12 deletions

View File

@ -18,11 +18,14 @@ public class RedisBungeeConfiguration {
private final boolean registerBungeeCommands;
@Getter
private final List<InetAddress> exemptAddresses;
@Getter
private final boolean useAsyncPing;
public RedisBungeeConfiguration(JedisPool pool, Configuration configuration) {
this.pool = pool;
this.serverId = configuration.getString("server-id");
this.registerBungeeCommands = configuration.getBoolean("register-bungee-commands", true);
this.useAsyncPing = configuration.getBoolean("use-async-ping", true);
List<String> stringified = configuration.getStringList("exempt-ip-addresses");
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();

View File

@ -45,8 +45,6 @@ public class RedisBungeeListener implements Listener {
private final RedisBungee plugin;
private final List<InetAddress> exemptAddresses;
private static final List<String> ASYNC_PING_EVENT_HOSTILE = ImmutableList.of("ServerListPlus", "SwiftMOTD");
@EventHandler(priority = EventPriority.LOWEST)
public void onLogin(final LoginEvent event) {
event.registerIntent(plugin);
@ -146,15 +144,7 @@ public class RedisBungeeListener implements Listener {
return;
}
boolean runAsync = true;
for (String s : ASYNC_PING_EVENT_HOSTILE) {
if (ProxyServer.getInstance().getPluginManager().getPlugin(s) != null) {
runAsync = false;
break;
}
}
if (runAsync) {
if (RedisBungee.getConfiguration().isUseAsyncPing()) {
event.registerIntent(plugin);
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
@ -164,7 +154,6 @@ public class RedisBungeeListener implements Listener {
}
});
} else {
// Async ping event will not work as an async-hostile plugin was found, so perform the ping modification synchronously.
event.getResponse().getPlayers().setOnline(plugin.getCount());
}
}

View File

@ -26,6 +26,10 @@ server-id: test1
# modules, and these must be disabled or overridden yourself.
register-bungee-commands: true
# Whether or not to use asynchronous ping event handling. This will greatly reduce lag and issues when pinging servers,
# but this isn't compatible with some MOTD plugins.
use-async-ping: true
# A list of IP addresses for which RedisBungee will not modify the response for, useful for automatic
# restart scripts.
exempt-ip-addresses: []