From e2582d65dbb97cc6bc10e1926ad07664c71167e7 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Fri, 22 Dec 2023 12:09:09 -0800 Subject: [PATCH] prevent person from enabling spawnit in an area if they don't control the master area --- compat/areas.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/compat/areas.lua b/compat/areas.lua index 6601269..9cfc60b 100644 --- a/compat/areas.lua +++ b/compat/areas.lua @@ -36,6 +36,17 @@ if spawnit.settings.spawn_in_protected_area then return true end) else + local function get_master_area(id) + local area = areas.areas[id] + local parent_id = area.parent + while parent_id do + id = parent_id + area = areas.areas[parent_id] + parent_id = area.parent + end + return id + end + minetest.register_chatcommand("area_spawnit", { description = S("toggle mob spawning in an area (i.e. allow safe spawns in the area)"), params = S(""), @@ -48,6 +59,9 @@ else if not areas:isAreaOwner(id, name) then return false, S("area @1 does not exist or is not owned by you.", tostring(id)) end + if not areas:isAreaOwner(get_master_area(id), name) then + return false, S("you do not control the master area here.") + end local previous_spawnit_enabled = areas.areas[id].spawnit_enabled if previous_spawnit_enabled == nil or previous_spawnit_enabled == false then