mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
Better support Redis on ports other than 6379. Also improve the anti-clone.
This commit is contained in:
parent
7ff324c6d8
commit
70c3f5fcdc
@ -39,6 +39,7 @@ public class RedisBungee extends Plugin implements Listener {
|
|||||||
private static final ServerPing.PlayerInfo[] EMPTY_PLAYERINFO = new ServerPing.PlayerInfo[]{};
|
private static final ServerPing.PlayerInfo[] EMPTY_PLAYERINFO = new ServerPing.PlayerInfo[]{};
|
||||||
private RedisBungeeCommandSender commandSender = new RedisBungeeCommandSender();
|
private RedisBungeeCommandSender commandSender = new RedisBungeeCommandSender();
|
||||||
private static RedisBungeeConfiguration configuration = new RedisBungeeConfiguration();
|
private static RedisBungeeConfiguration configuration = new RedisBungeeConfiguration();
|
||||||
|
private List<String> forcefullyKicked = new ArrayList<>();
|
||||||
private JedisPool pool;
|
private JedisPool pool;
|
||||||
private RedisBungee plugin;
|
private RedisBungee plugin;
|
||||||
private static RedisBungeeAPI api;
|
private static RedisBungeeAPI api;
|
||||||
@ -208,10 +209,15 @@ public class RedisBungee extends Plugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String redisServer = "localhost";
|
String redisServer = "localhost";
|
||||||
|
int redisPort = 6379;
|
||||||
try {
|
try {
|
||||||
redisServer = ((String) rawYaml.get("redis-server"));
|
redisServer = ((String) rawYaml.get("redis-server"));
|
||||||
} catch (NullPointerException ignored) {
|
} catch (NullPointerException ignored) {
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
redisPort = ((Integer) rawYaml.get("redis-port"));
|
||||||
|
} catch (NullPointerException ignored) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
configuration.setServerId((String) rawYaml.get("server-id"));
|
configuration.setServerId((String) rawYaml.get("server-id"));
|
||||||
} catch (NullPointerException ignored) {
|
} catch (NullPointerException ignored) {
|
||||||
@ -238,7 +244,7 @@ public class RedisBungee extends Plugin implements Listener {
|
|||||||
|
|
||||||
if (redisServer != null) {
|
if (redisServer != null) {
|
||||||
if (!redisServer.equals("")) {
|
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();
|
Jedis rsc = pool.getResource();
|
||||||
try {
|
try {
|
||||||
if (rsc.hexists("player:" + event.getPlayer().getName(), "server")) {
|
if (rsc.hexists("player:" + event.getPlayer().getName(), "server")) {
|
||||||
|
forcefullyKicked.add(event.getPlayer().getName());
|
||||||
event.getPlayer().disconnect("You are already logged on this server.");
|
event.getPlayer().disconnect("You are already logged on this server.");
|
||||||
} else {
|
} else {
|
||||||
rsc.sadd("server:" + configuration.getServerId() + ":usersOnline", event.getPlayer().getName());
|
rsc.sadd("server:" + configuration.getServerId() + ":usersOnline", event.getPlayer().getName());
|
||||||
@ -263,6 +270,9 @@ public class RedisBungee extends Plugin implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDisconnect(final PlayerDisconnectEvent event) {
|
public void onPlayerDisconnect(final PlayerDisconnectEvent event) {
|
||||||
|
if (forcefullyKicked.contains(event.getPlayer().getName()))
|
||||||
|
return;
|
||||||
|
|
||||||
if (pool != null) {
|
if (pool != null) {
|
||||||
Jedis rsc = pool.getResource();
|
Jedis rsc = pool.getResource();
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# The Redis server you use.
|
# The Redis server you use.
|
||||||
# Get Redis from http://redis.io/
|
# Get Redis from http://redis.io/
|
||||||
redis-server: 127.0.0.1
|
redis-server: 127.0.0.1
|
||||||
|
redis-port: 6379
|
||||||
|
|
||||||
# An identifier for this BungeeCord instance.
|
# An identifier for this BungeeCord instance.
|
||||||
server-id: iluvbungee
|
server-id: iluvbungee
|
||||||
|
Loading…
Reference in New Issue
Block a user