Add areas_high_limit privilege for trusted players

This commit is contained in:
ShadowNinja
2014-11-14 13:21:09 -05:00
parent fe52664043
commit e4aef02cb9
4 changed files with 43 additions and 22 deletions

View File

@ -52,12 +52,12 @@ end
-- Remove a area, and optionally it's children recursively.
-- If a area is deleted non-recursively the children will
-- have the removed area's parent as their new parent.
function areas:remove(id, recurse, secondrun)
function areas:remove(id, recurse)
if recurse then
-- Recursively find child entries and remove them
local cids = self:getChildren(id)
for _, cid in pairs(cids) do
self:remove(cid, true, true)
self:remove(cid, true)
end
else
-- Update parents
@ -109,22 +109,26 @@ end
-- Also checks the size of the area and if the user already
-- has more than max_areas.
function areas:canPlayerAddArea(pos1, pos2, name)
if minetest.check_player_privs(name, self.adminPrivs) then
local privs = minetest.get_player_privs(name)
if privs.areas then
return true
end
-- Check self protection privilege, if it is enabled,
-- and if the area is too big.
if (not self.self_protection) or
(not minetest.check_player_privs(name,
{[areas.self_protection_privilege]=true})) then
if not self.self_protection or
not privs[areas.self_protection_privilege] then
return false, "Self protection is disabled or you do not have"
.." the necessary privilege."
end
if (pos2.x - pos1.x) > self.self_protection_max_size.x or
(pos2.y - pos1.y) > self.self_protection_max_size.y or
(pos2.z - pos1.z) > self.self_protection_max_size.z then
local max_size = privs.areas_high_limit and
self.self_protection_max_size_high or
self.self_protection_max_size
if
(pos2.x - pos1.x) > max_size.x or
(pos2.y - pos1.y) > max_size.y or
(pos2.z - pos1.z) > max_size.z then
return false, "Area is too big."
end
@ -135,7 +139,10 @@ function areas:canPlayerAddArea(pos1, pos2, name)
count = count + 1
end
end
if count >= self.self_protection_max_areas then
local max_areas = privs.areas_high_limit and
self.self_protection_max_areas_high or
self.self_protection_max_areas
if count >= max_areas then
return false, "You have reached the maximum amount of"
.." areas that you are allowed to protect."
end
@ -144,7 +151,7 @@ function areas:canPlayerAddArea(pos1, pos2, name)
local can, id = self:canInteractInArea(pos1, pos2, name)
if not can then
local area = self.areas[id]
return false, ("The area intersects with %s [%u] owned by %s.")
return false, ("The area intersects with %s [%u] (%s).")
:format(area.name, id, area.owner)
end