diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java index 8555133..b3bd2e6 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java @@ -18,11 +18,14 @@ public class RedisBungeeConfiguration { private final boolean registerBungeeCommands; @Getter private final List 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 stringified = configuration.getStringList("exempt-ip-addresses"); ImmutableList.Builder addressBuilder = ImmutableList.builder(); diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java index dda2122..37a6404 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java @@ -45,8 +45,6 @@ public class RedisBungeeListener implements Listener { private final RedisBungee plugin; private final List exemptAddresses; - private static final List 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()); } } diff --git a/src/main/resources/example_config.yml b/src/main/resources/example_config.yml index a597f9c..67d3928 100644 --- a/src/main/resources/example_config.yml +++ b/src/main/resources/example_config.yml @@ -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: [] \ No newline at end of file