mirror of
https://github.com/minetest-mods/xban2.git
synced 2025-04-30 13:41:40 -04:00
add /xban_cleanup command to compact db / purge unbanned entries
This commit is contained in:
parent
3b70045365
commit
486506ceff
1 changed files with 26 additions and 0 deletions
26
init.lua
26
init.lua
|
@ -314,6 +314,7 @@ minetest.register_chatcommand("xban_wl", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
local function check_temp_bans()
|
local function check_temp_bans()
|
||||||
minetest.after(60, check_temp_bans)
|
minetest.after(60, check_temp_bans)
|
||||||
local to_rm = { }
|
local to_rm = { }
|
||||||
|
@ -374,6 +375,31 @@ local function load_db()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_chatcommand("xban_cleanup", {
|
||||||
|
description = "Removes all non-banned entries from the xban db",
|
||||||
|
privs = { server=true },
|
||||||
|
func = function(name, params)
|
||||||
|
local rm_count = 0
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
while i <= #db do
|
||||||
|
if not db[i].banned then
|
||||||
|
-- not banned, remove from db
|
||||||
|
table.remove(db, i)
|
||||||
|
rm_count = rm_count + 1
|
||||||
|
else
|
||||||
|
-- banned, hold entry back
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- save immediately
|
||||||
|
save_db()
|
||||||
|
|
||||||
|
return true, "removed " .. rm_count .. " entries, new db entry-count: " .. #db
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_on_shutdown(save_db)
|
minetest.register_on_shutdown(save_db)
|
||||||
minetest.after(SAVE_INTERVAL, save_db)
|
minetest.after(SAVE_INTERVAL, save_db)
|
||||||
load_db()
|
load_db()
|
||||||
|
|
Loading…
Add table
Reference in a new issue