mirror of
https://github.com/minetest-mods/areas.git
synced 2024-10-02 16:03:17 +02:00
f52454edec
require_protection: Disallows interactions outside of owned areas node_ownership_legacy: Skip 9+ year old compatibility code by default
29 lines
693 B
Lua
29 lines
693 B
Lua
local S = minetest.get_translator("areas")
|
|
|
|
local old_is_protected = minetest.is_protected
|
|
function minetest.is_protected(pos, name)
|
|
if not areas:canInteract(pos, name) then
|
|
return true
|
|
end
|
|
return old_is_protected(pos, name)
|
|
end
|
|
|
|
minetest.register_on_protection_violation(function(pos, name)
|
|
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)
|