mirror of
https://github.com/minetest-mods/xban2.git
synced 2025-07-27 12:40:20 +02:00
Compare commits
7 Commits
new_auth
...
fa14efa9e2
Author | SHA1 | Date | |
---|---|---|---|
fa14efa9e2 | |||
e937f5ff67 | |||
43acd1c620 | |||
58e77ad16c | |||
af26ae75bd | |||
8fde3c240f | |||
d200b342e9 |
@ -104,3 +104,9 @@ the supported import plugins at the time of writing:
|
||||
* `v2`: Old format used by xban (`players.iplist.v2`).
|
||||
|
||||
**Example:** `/xban_dbi minetest`
|
||||
|
||||
### `xban_cleanup`
|
||||
|
||||
Removes all non-banned entries from the xban db.
|
||||
|
||||
**Usage:** `/xban_cleanup`
|
||||
|
27
init.lua
27
init.lua
@ -314,6 +314,7 @@ minetest.register_chatcommand("xban_wl", {
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
local function check_temp_bans()
|
||||
minetest.after(60, check_temp_bans)
|
||||
local to_rm = { }
|
||||
@ -374,6 +375,30 @@ local function load_db()
|
||||
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 old_count = #db
|
||||
|
||||
local i = 1
|
||||
while i <= #db do
|
||||
if not db[i].banned then
|
||||
-- not banned, remove from db
|
||||
table.remove(db, i)
|
||||
else
|
||||
-- banned, hold entry back
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- save immediately
|
||||
save_db()
|
||||
|
||||
return true, "Removed " .. (old_count - #db) .. " entries, new db entry-count: " .. #db
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_shutdown(save_db)
|
||||
minetest.after(SAVE_INTERVAL, save_db)
|
||||
load_db()
|
||||
@ -383,3 +408,5 @@ minetest.after(1, check_temp_bans)
|
||||
|
||||
dofile(xban.MP.."/dbimport.lua")
|
||||
dofile(xban.MP.."/gui.lua")
|
||||
|
||||
minetest.log("action", "[xban2] loaded.")
|
||||
|
Reference in New Issue
Block a user