From f5af1aed7063e2af70ab990ddec36b602c8e2a90 Mon Sep 17 00:00:00 2001 From: Tux Date: Mon, 18 Jan 2016 18:01:28 -0500 Subject: [PATCH] 0.3.8-INTERIM-4 --- .../minecraft/redisbungee/RedisBungee.java | 6 ++++++ .../redisbungee/RedisBungeeConfiguration.java | 3 --- .../minecraft/redisbungee/RedisBungeeListener.java | 13 +------------ src/main/resources/example_config.yml | 4 ---- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java index e9bad75..3f5f41f 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java @@ -55,6 +55,7 @@ public final class RedisBungee extends Plugin { private static OkHttpClient httpClient; private volatile List serverIds; private final AtomicInteger nagAboutServers = new AtomicInteger(); + private final AtomicInteger globalPlayerCount = new AtomicInteger(); private ScheduledTask integrityCheck; private ScheduledTask heartbeatTask; private boolean usingLua; @@ -152,6 +153,10 @@ public final class RedisBungee extends Plugin { } final int getCount() { + return globalPlayerCount.get(); + } + + final int getCurrentCount() { Long count = (Long) getPlayerCountScript.eval(ImmutableList.of(), ImmutableList.of()); return count.intValue(); } @@ -265,6 +270,7 @@ public final class RedisBungee extends Plugin { getLogger().log(Level.SEVERE, "Unable to update heartbeat - did your Redis server go away?", e); } serverIds = getCurrentServerIds(true, false); + globalPlayerCount.set(getCurrentCount()); } }, 0, 3, TimeUnit.SECONDS); dataManager = new DataManager(this); diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java index b3bd2e6..8555133 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeConfiguration.java @@ -18,14 +18,11 @@ 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 37a6404..b6a292c 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java @@ -144,18 +144,7 @@ public class RedisBungeeListener implements Listener { return; } - if (RedisBungee.getConfiguration().isUseAsyncPing()) { - event.registerIntent(plugin); - plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() { - @Override - public void run() { - event.getResponse().getPlayers().setOnline(plugin.getCount()); - event.completeIntent(plugin); - } - }); - } else { - event.getResponse().getPlayers().setOnline(plugin.getCount()); - } + event.getResponse().getPlayers().setOnline(plugin.getCount()); } @EventHandler diff --git a/src/main/resources/example_config.yml b/src/main/resources/example_config.yml index 67d3928..a597f9c 100644 --- a/src/main/resources/example_config.yml +++ b/src/main/resources/example_config.yml @@ -26,10 +26,6 @@ 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