Skip to content

Commit

Permalink
prevent person from enabling spawnit in an area if they don't control…
Browse files Browse the repository at this point in the history
… the master area
  • Loading branch information
fluxionary committed Dec 22, 2023
1 parent 3fc72d5 commit e2582d6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions compat/areas.lua
Expand Up @@ -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("<area ID>"),
Expand All @@ -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
Expand Down

0 comments on commit e2582d6

Please sign in to comment.