diff --git a/szutil_pruneplayers/init.lua b/szutil_pruneplayers/init.lua index f90479f..9f89ca7 100644 --- a/szutil_pruneplayers/init.lua +++ b/szutil_pruneplayers/init.lua @@ -60,6 +60,12 @@ end ------------------------------------------------------------------------ +local lastauth = {} +minetest.register_on_authplayer(function(name, _, is_success) + if not is_success then return end + lastauth[name] = os_time() + end) + local function check(pname) if protectnames[pname] or minetest.get_player_by_name(pname) then return end @@ -69,10 +75,14 @@ local function check(pname) if data.privileges[noprune] then return end + local seen = data.last_login + local authtime = lastauth[pname] + if authtime and authtime > seen then seen = authtime end local now = os_time() - local daysago = (now - data.last_login) / 86400 + local daysago = (now - seen) / 86400 if daysago <= maxdays then return end + lastauth[pname] = nil minetest.log("warning", string_format( "Deleting player %q last seen %0.1f day(s) ago", pname, daysago))