mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-21 20:42:21 +01:00
/areas_cleanup for removing ownerless areas
This commit is contained in:
parent
800a93f5ee
commit
aa3e35acbe
@ -101,6 +101,9 @@ Commands
|
||||
|
||||
* `/area_pos2 [X,Y,Z|X Y Z]` -- Sets area position two to your position or
|
||||
the one supplied.
|
||||
|
||||
* `/areas_cleanup` -- Removes all ownerless areas.
|
||||
Useful for cleaning after user deletion, for example using /remove_player.
|
||||
|
||||
License
|
||||
-------
|
||||
|
@ -417,3 +417,28 @@ minetest.register_chatcommand("area_info", {
|
||||
return true, table.concat(lines, "\n")
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("areas_cleanup", {
|
||||
description = S("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
|
||||
})
|
||||
|
@ -65,6 +65,8 @@ You have extended area protection limits ("areas_high_limit" privilege).=
|
||||
You have the necessary privilege ("@1").=
|
||||
You need to select an area first.=
|
||||
|
||||
Removes all ownerless areas.=
|
||||
|
||||
### chatcommands.lua ###
|
||||
### pos.lua ###
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user