From c7f0dbbbdac8ffdc4d6b90eb38a2221977f36666 Mon Sep 17 00:00:00 2001 From: gpcf Date: Sun, 28 Jul 2024 11:46:19 +0200 Subject: Add unit tests, fix broken new player handling --- init.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index 576e0d0..a3376ba 100644 --- a/init.lua +++ b/init.lua @@ -313,14 +313,6 @@ minetest.register_chatcommand("is_afk", { minetest.register_on_prejoinplayer(function(name, ip) local wl = db.whitelist or { } if wl[name] or wl[ip] then return end - local e = xban.find_entry(name) or xban.find_entry(ip) - if not e then return end - if e.banned then - local date = (e.expires and os.date("%c", e.expires) - or "the end of time") - return ("Banned: Expires: %s, Reason: %s"):format( - date, e.reason) - end if minetest.player_exists(name) and not xban.has_password(name) then ACTION("Passwordless account %s attempted to log in", name) return "This account has been deactivated. Please, contact the server owner on the forums." @@ -333,8 +325,17 @@ minetest.register_on_prejoinplayer(function(name, ip) return end end + ACTION("New player %s tried to join while no active moderators were present, rejected.", name) return "No new accounts are allowed while there is no moderator online. Please try rejoining later!" end + local e = xban.find_entry(name) or xban.find_entry(ip) + if not e then return end + if e.banned then + local date = (e.expires and os.date("%c", e.expires) + or "the end of time") + return ("Banned: Expires: %s, Reason: %s"):format( + date, e.reason) + end end) minetest.register_on_newplayer(function(player) -- cgit v1.2.3