Skip to content

Commit

Permalink
respect areas setting (#9)
Browse files Browse the repository at this point in the history
* respect [areas] setting
* de duplicate code
  • Loading branch information
SwissalpS authored Oct 4, 2024
1 parent b3a7ec7 commit ba10bcb
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions areas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@ end
-- protection check
local old_is_protected = minetest.is_protected
function minetest.is_protected(pos, name)
if areas.getSmallestAreaAtPos then
local area_list
if areas.config.use_smallest_area_precedence then
local _, id = areas:getSmallestAreaAtPos(pos)
if id then
local required_priv = priv_areas[id]
if required_priv and not minetest.check_player_privs(name, required_priv) then
-- required privililege not met, protected
return true
end
end
area_list = id and { [id] = true } or {}
else
local area_list = areas:getAreasAtPos(pos)
for id in pairs(area_list) do
local required_priv = priv_areas[id]

if required_priv and not minetest.check_player_privs(name, required_priv) then
-- required privililege not met, protected
return true
end
area_list = areas:getAreasAtPos(pos)
end
for id in pairs(area_list) do
local required_priv = priv_areas[id]

if required_priv and not minetest.check_player_privs(name, required_priv) then
-- required privililege not met, protected
return true
end
end

Expand Down

0 comments on commit ba10bcb

Please sign in to comment.