2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +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 Future<?> integrityCheck;
private Future<?> heartbeatTask;
private boolean usingLua;
private LuaManager.Script serverToPlayersScript;
private LuaManager.Script getPlayerCountScript;
@ -258,7 +257,7 @@ public final class RedisBungee extends Plugin {
if (s.startsWith("redis_version:")) {
String version = s.split(":")[1];
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.");
throw new RuntimeException("Unsupported Redis version detected");
} else {

View File

@ -39,7 +39,7 @@ public class RedisUtil {
public static void cleanUpPlayer(String player, Jedis rsc) {
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();
rsc.hset("player:" + player, "online", String.valueOf(timestamp));
rsc.publish("redisbungee-data", RedisBungee.getGson().toJson(new DataManager.DataManagerMessage<>(
@ -57,7 +57,7 @@ public class RedisUtil {
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.
String[] args = redisVersion.split("\\.");
if (args.length < 2) {
@ -67,4 +67,10 @@ public class RedisUtil {
int minor = Integer.parseInt(args[1]);
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);
}
}