From 019bb30c09ee691f2051595d85e14fecb3ca8605 Mon Sep 17 00:00:00 2001 From: mohammed jasem alaajel Date: Sun, 17 Jul 2022 07:12:57 +0400 Subject: [PATCH] remove lua files and do it in java, due Redis not supporting lua quite well in cluster mode, some scripts were added recently will be kept --- .../redisbungee/api/util/lua/LuaManager.java | 2 +- .../main/resources/lua/get_player_count.lua | 24 ------------------- .../main/resources/lua/server_to_players.lua | 18 -------------- 3 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 RedisBungee-API/src/main/resources/lua/get_player_count.lua delete mode 100644 RedisBungee-API/src/main/resources/lua/server_to_players.lua diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/lua/LuaManager.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/lua/LuaManager.java index 16a20e1..60689af 100644 --- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/lua/LuaManager.java +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/lua/LuaManager.java @@ -27,7 +27,7 @@ public class LuaManager { @Override public Script clusterJedisTask(JedisCluster jedisCluster) { - String hash = jedisCluster.scriptLoad(script, null); + String hash = jedisCluster.scriptLoad(script, "0"); return new Script(script, hash); } }; diff --git a/RedisBungee-API/src/main/resources/lua/get_player_count.lua b/RedisBungee-API/src/main/resources/lua/get_player_count.lua deleted file mode 100644 index 0882aec..0000000 --- a/RedisBungee-API/src/main/resources/lua/get_player_count.lua +++ /dev/null @@ -1,24 +0,0 @@ -local c = redis.call - -local curTime = c("TIME") -local time = tonumber(curTime[1]) - -local heartbeats = c("HGETALL", "heartbeats") -local total = 0 -local key - -for _, v in ipairs(heartbeats) do - if not key then - key = v - else - local n = tonumber(v) - if n then - if n + 30 >= time then - total = total + c("SCARD", "proxy:" .. key .. ":usersOnline") - end - end - key = nil - end -end - -return total diff --git a/RedisBungee-API/src/main/resources/lua/server_to_players.lua b/RedisBungee-API/src/main/resources/lua/server_to_players.lua deleted file mode 100644 index ee66398..0000000 --- a/RedisBungee-API/src/main/resources/lua/server_to_players.lua +++ /dev/null @@ -1,18 +0,0 @@ -local call = redis.call -local ipairs = ipairs - -local serverToData = {} - -for _, proxy in ipairs(ARGV) do - local players = call("SMEMBERS", "proxy:" .. proxy .. ":usersOnline") - for _, player in ipairs(players) do - local server = call("HGET", "player:" .. player, "server") - if server then - local sz = #serverToData - serverToData[sz + 1] = server - serverToData[sz + 2] = player - end - end -end - -return serverToData \ No newline at end of file