Skip to content

Commit

Permalink
0.3.8-INTERIM-4
Browse files Browse the repository at this point in the history
  • Loading branch information
minecrafter committed Jan 18, 2016
1 parent 11d93e8 commit f5af1ae
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public final class RedisBungee extends Plugin {
private static OkHttpClient httpClient;
private volatile List<String> serverIds;
private final AtomicInteger nagAboutServers = new AtomicInteger();
private final AtomicInteger globalPlayerCount = new AtomicInteger();
private ScheduledTask integrityCheck;
private ScheduledTask heartbeatTask;
private boolean usingLua;
Expand Down Expand Up @@ -152,6 +153,10 @@ public Multimap<String, UUID> call() throws Exception {
}

final int getCount() {
return globalPlayerCount.get();
}

final int getCurrentCount() {
Long count = (Long) getPlayerCountScript.eval(ImmutableList.<String>of(), ImmutableList.<String>of());
return count.intValue();
}
Expand Down Expand Up @@ -265,6 +270,7 @@ public void run() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,7 @@ public void onPing(final ProxyPingEvent event) {
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
Expand Down
4 changes: 0 additions & 4 deletions src/main/resources/example_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

0 comments on commit f5af1ae

Please sign in to comment.