Add require_protection and node_ownership_legacy settings

require_protection: Disallows interactions outside of owned areas
node_ownership_legacy: Skip 9+ year old compatibility code by default
This commit is contained in:
SmallJoker
2022-03-25 22:00:07 +01:00
parent 4018c0d204
commit f52454edec
4 changed files with 38 additions and 18 deletions

View File

@ -9,11 +9,20 @@ function minetest.is_protected(pos, name)
end
minetest.register_on_protection_violation(function(pos, name)
if not areas:canInteract(pos, name) then
local owners = areas:getNodeOwners(pos)
minetest.chat_send_player(name,
S("@1 is protected by @2.",
minetest.pos_to_string(pos),
table.concat(owners, ", ")))
if areas:canInteract(pos, name) then
return
end
local owners = areas:getNodeOwners(pos)
if #owners == 0 then
-- When require_protection=true
minetest.chat_send_player(name,
S("@1 may not be accessed.",
minetest.pos_to_string(pos)))
return
end
minetest.chat_send_player(name,
S("@1 is protected by @2.",
minetest.pos_to_string(pos),
table.concat(owners, ", ")))
end)