Add "areas_cleanup" chatcommand

master
MoNTE48 2020-03-22 21:03:09 +01:00
parent 92afd99b31
commit cf7882aae2
1 changed files with 25 additions and 0 deletions

View File

@ -421,3 +421,28 @@ minetest.register_chatcommand("area_info", {
return true, table.concat(lines, "\n")
end,
})
minetest.register_chatcommand("areas_cleanup", {
params = "<id>",
description = "Removes all ownerless areas",
privs = areas.adminPrivs,
func = function()
local total, count = 0, 0
local aareas = areas.areas
for id, _ in pairs(aareas) do
local owner = aareas[id].owner
if not areas:player_exists(owner) then
areas:remove(id)
count = count + 1
end
total = total + 1
end
areas:save()
return true, "Total areas: " .. total .. ", Removed: " .. count .. " areas! New count: " .. total - count
end
})