mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-25 02:00:40 +01:00
Remove legacy protection method
This commit is contained in:
parent
db1d87c008
commit
a747c2f505
60
interact.lua
60
interact.lua
@ -1,51 +1,19 @@
|
|||||||
|
|
||||||
-- Gives a player a warning message about a area being protected
|
old_is_protected = minetest.is_protected
|
||||||
local function printWarning(pos, name)
|
function minetest.is_protected(pos, name)
|
||||||
local owners = areas:getNodeOwners(pos)
|
if not areas:canInteract(pos, name) then
|
||||||
minetest.chat_send_player(name, ("%s is protected by %s.")
|
return true
|
||||||
:format(minetest.pos_to_string(pos), table.concat(owners, ", ")))
|
end
|
||||||
|
return old_is_protected(pos, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.is_protected then
|
minetest.register_on_protection_violation(function(pos, name)
|
||||||
old_is_protected = minetest.is_protected
|
if not areas:canInteract(pos, name) then
|
||||||
function minetest.is_protected(pos, name)
|
local owners = areas:getNodeOwners(pos)
|
||||||
if not areas:canInteract(pos, name) then
|
minetest.chat_send_player(name,
|
||||||
return true
|
("%s is protected by %s."):format(
|
||||||
end
|
minetest.pos_to_string(pos),
|
||||||
return old_is_protected(pos, name)
|
table.concat(owners, ", ")))
|
||||||
end
|
end
|
||||||
|
end)
|
||||||
minetest.register_on_protection_violation(function(pos, name)
|
|
||||||
if not areas:canInteract(pos, name) then
|
|
||||||
printWarning(pos, name)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
else
|
|
||||||
local old_node_place = minetest.item_place_node
|
|
||||||
function minetest.item_place_node(itemstack, placer, pointed_thing)
|
|
||||||
local pos = pointed_thing.above
|
|
||||||
local under_node = minetest.get_node(pointed_thing.under)
|
|
||||||
local under_def = minetest.registered_nodes[under_node.name]
|
|
||||||
|
|
||||||
if under_def and under_def.buildable_to then
|
|
||||||
pos = pointed_thing.under
|
|
||||||
end
|
|
||||||
|
|
||||||
if not areas:canInteract(pos, placer:get_player_name()) then
|
|
||||||
printWarning(pos, placer:get_player_name())
|
|
||||||
return itemstack -- Abort place.
|
|
||||||
end
|
|
||||||
return old_node_place(itemstack, placer, pointed_thing)
|
|
||||||
end
|
|
||||||
|
|
||||||
local old_node_dig = minetest.node_dig
|
|
||||||
function minetest.node_dig(pos, node, digger)
|
|
||||||
if not areas:canInteract(pos, digger:get_player_name()) then
|
|
||||||
printWarning(pos, digger:get_player_name())
|
|
||||||
return -- Abort dig.
|
|
||||||
end
|
|
||||||
return old_node_dig(pos, node, digger)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user