mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
0.3.8-INTERIM-4
This commit is contained in:
parent
11d93e8e91
commit
f5af1aed70
@ -55,6 +55,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
private static OkHttpClient httpClient;
|
private static OkHttpClient httpClient;
|
||||||
private volatile List<String> serverIds;
|
private volatile List<String> serverIds;
|
||||||
private final AtomicInteger nagAboutServers = new AtomicInteger();
|
private final AtomicInteger nagAboutServers = new AtomicInteger();
|
||||||
|
private final AtomicInteger globalPlayerCount = new AtomicInteger();
|
||||||
private ScheduledTask integrityCheck;
|
private ScheduledTask integrityCheck;
|
||||||
private ScheduledTask heartbeatTask;
|
private ScheduledTask heartbeatTask;
|
||||||
private boolean usingLua;
|
private boolean usingLua;
|
||||||
@ -152,6 +153,10 @@ public final class RedisBungee extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int getCount() {
|
final int getCount() {
|
||||||
|
return globalPlayerCount.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
final int getCurrentCount() {
|
||||||
Long count = (Long) getPlayerCountScript.eval(ImmutableList.<String>of(), ImmutableList.<String>of());
|
Long count = (Long) getPlayerCountScript.eval(ImmutableList.<String>of(), ImmutableList.<String>of());
|
||||||
return count.intValue();
|
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);
|
getLogger().log(Level.SEVERE, "Unable to update heartbeat - did your Redis server go away?", e);
|
||||||
}
|
}
|
||||||
serverIds = getCurrentServerIds(true, false);
|
serverIds = getCurrentServerIds(true, false);
|
||||||
|
globalPlayerCount.set(getCurrentCount());
|
||||||
}
|
}
|
||||||
}, 0, 3, TimeUnit.SECONDS);
|
}, 0, 3, TimeUnit.SECONDS);
|
||||||
dataManager = new DataManager(this);
|
dataManager = new DataManager(this);
|
||||||
|
@ -18,14 +18,11 @@ public class RedisBungeeConfiguration {
|
|||||||
private final boolean registerBungeeCommands;
|
private final boolean registerBungeeCommands;
|
||||||
@Getter
|
@Getter
|
||||||
private final List<InetAddress> exemptAddresses;
|
private final List<InetAddress> exemptAddresses;
|
||||||
@Getter
|
|
||||||
private final boolean useAsyncPing;
|
|
||||||
|
|
||||||
public RedisBungeeConfiguration(JedisPool pool, Configuration configuration) {
|
public RedisBungeeConfiguration(JedisPool pool, Configuration configuration) {
|
||||||
this.pool = pool;
|
this.pool = pool;
|
||||||
this.serverId = configuration.getString("server-id");
|
this.serverId = configuration.getString("server-id");
|
||||||
this.registerBungeeCommands = configuration.getBoolean("register-bungee-commands", true);
|
this.registerBungeeCommands = configuration.getBoolean("register-bungee-commands", true);
|
||||||
this.useAsyncPing = configuration.getBoolean("use-async-ping", true);
|
|
||||||
|
|
||||||
List<String> stringified = configuration.getStringList("exempt-ip-addresses");
|
List<String> stringified = configuration.getStringList("exempt-ip-addresses");
|
||||||
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
|
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
|
||||||
|
@ -144,18 +144,7 @@ public class RedisBungeeListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RedisBungee.getConfiguration().isUseAsyncPing()) {
|
event.getResponse().getPlayers().setOnline(plugin.getCount());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -26,10 +26,6 @@ server-id: test1
|
|||||||
# modules, and these must be disabled or overridden yourself.
|
# modules, and these must be disabled or overridden yourself.
|
||||||
register-bungee-commands: true
|
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
|
# A list of IP addresses for which RedisBungee will not modify the response for, useful for automatic
|
||||||
# restart scripts.
|
# restart scripts.
|
||||||
exempt-ip-addresses: []
|
exempt-ip-addresses: []
|
Loading…
Reference in New Issue
Block a user