2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-12-23 10:38:01 +00:00

Better support Redis on ports other than 6379. Also improve the anti-clone.

This commit is contained in:
Tux 2013-12-02 22:02:55 -05:00
parent 7ff324c6d8
commit 70c3f5fcdc
2 changed files with 12 additions and 1 deletions

View File

@ -39,6 +39,7 @@ public class RedisBungee extends Plugin implements Listener {
private static final ServerPing.PlayerInfo[] EMPTY_PLAYERINFO = new ServerPing.PlayerInfo[]{};
private RedisBungeeCommandSender commandSender = new RedisBungeeCommandSender();
private static RedisBungeeConfiguration configuration = new RedisBungeeConfiguration();
private List<String> forcefullyKicked = new ArrayList<>();
private JedisPool pool;
private RedisBungee plugin;
private static RedisBungeeAPI api;
@ -208,10 +209,15 @@ public class RedisBungee extends Plugin implements Listener {
}
String redisServer = "localhost";
int redisPort = 6379;
try {
redisServer = ((String) rawYaml.get("redis-server"));
} catch (NullPointerException ignored) {
}
try {
redisPort = ((Integer) rawYaml.get("redis-port"));
} catch (NullPointerException ignored) {
}
try {
configuration.setServerId((String) rawYaml.get("server-id"));
} catch (NullPointerException ignored) {
@ -238,7 +244,7 @@ public class RedisBungee extends Plugin implements Listener {
if (redisServer != null) {
if (!redisServer.equals("")) {
pool = new JedisPool(new JedisPoolConfig(), redisServer);
pool = new JedisPool(new JedisPoolConfig(), redisServer, redisPort);
}
}
}
@ -248,6 +254,7 @@ public class RedisBungee extends Plugin implements Listener {
Jedis rsc = pool.getResource();
try {
if (rsc.hexists("player:" + event.getPlayer().getName(), "server")) {
forcefullyKicked.add(event.getPlayer().getName());
event.getPlayer().disconnect("You are already logged on this server.");
} else {
rsc.sadd("server:" + configuration.getServerId() + ":usersOnline", event.getPlayer().getName());
@ -263,6 +270,9 @@ public class RedisBungee extends Plugin implements Listener {
@EventHandler
public void onPlayerDisconnect(final PlayerDisconnectEvent event) {
if (forcefullyKicked.contains(event.getPlayer().getName()))
return;
if (pool != null) {
Jedis rsc = pool.getResource();
try {

View File

@ -1,6 +1,7 @@
# The Redis server you use.
# Get Redis from http://redis.io/
redis-server: 127.0.0.1
redis-port: 6379
# An identifier for this BungeeCord instance.
server-id: iluvbungee