2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-23 04:28:01 +00:00

change redis version check method.

This commit is contained in:
mohammed jasem alaajel 2021-08-09 14:16:07 +04:00
parent c9798e2371
commit a006c343a7
2 changed files with 9 additions and 4 deletions

View File

@ -66,7 +66,6 @@ public final class RedisBungee extends Plugin {
private final AtomicInteger globalPlayerCount = new AtomicInteger(); private final AtomicInteger globalPlayerCount = new AtomicInteger();
private Future<?> integrityCheck; private Future<?> integrityCheck;
private Future<?> heartbeatTask; private Future<?> heartbeatTask;
private boolean usingLua;
private LuaManager.Script serverToPlayersScript; private LuaManager.Script serverToPlayersScript;
private LuaManager.Script getPlayerCountScript; private LuaManager.Script getPlayerCountScript;
@ -258,7 +257,7 @@ public final class RedisBungee extends Plugin {
if (s.startsWith("redis_version:")) { if (s.startsWith("redis_version:")) {
String version = s.split(":")[1]; String version = s.split(":")[1];
getLogger().info(version + " <- redis version"); getLogger().info(version + " <- redis version");
if (!(usingLua = RedisUtil.canUseLua(version))) { if (!RedisUtil.isRedisVersionRight(version)) {
getLogger().warning("Your version of Redis (" + version + ") is not at least version 6.0 RedisBungee requires a newer version of Redis."); getLogger().warning("Your version of Redis (" + version + ") is not at least version 6.0 RedisBungee requires a newer version of Redis.");
throw new RuntimeException("Unsupported Redis version detected"); throw new RuntimeException("Unsupported Redis version detected");
} else { } else {

View File

@ -39,7 +39,7 @@ public class RedisUtil {
public static void cleanUpPlayer(String player, Jedis rsc) { public static void cleanUpPlayer(String player, Jedis rsc) {
rsc.srem("proxy:" + RedisBungee.getApi().getServerId() + ":usersOnline", player); rsc.srem("proxy:" + RedisBungee.getApi().getServerId() + ":usersOnline", player);
rsc.hdel("player:" + player, "server", "ip", "proxy"); rsc.hdel("player:" + player, "server", "ip", "proxy");
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
rsc.hset("player:" + player, "online", String.valueOf(timestamp)); rsc.hset("player:" + player, "online", String.valueOf(timestamp));
rsc.publish("redisbungee-data", RedisBungee.getGson().toJson(new DataManager.DataManagerMessage<>( rsc.publish("redisbungee-data", RedisBungee.getGson().toJson(new DataManager.DataManagerMessage<>(
@ -57,7 +57,7 @@ public class RedisUtil {
new DataManager.LogoutPayload(timestamp)))); new DataManager.LogoutPayload(timestamp))));
} }
public static boolean canUseLua(String redisVersion) { public static boolean isRedisVersionRight(String redisVersion) {
// Need to use >=6.2 to use Lua optimizations. // Need to use >=6.2 to use Lua optimizations.
String[] args = redisVersion.split("\\."); String[] args = redisVersion.split("\\.");
if (args.length < 2) { if (args.length < 2) {
@ -67,4 +67,10 @@ public class RedisUtil {
int minor = Integer.parseInt(args[1]); int minor = Integer.parseInt(args[1]);
return major >= 6 && minor >= 0; return major >= 6 && minor >= 0;
} }
// Ham1255: i am keeping this if some plugin uses this *IF*
@Deprecated
public static boolean canUseLua(String redisVersion) {
return isRedisVersionRight(redisVersion);
}
} }