mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2024-11-08 19:30:32 +01:00
use minetest built-in functions for node protection
phase out the old hand-rolled protection function drops support for old protection mods
This commit is contained in:
parent
ce8433ac1e
commit
ca88a35f26
|
@ -94,7 +94,7 @@ for i in ipairs(lilies_list) do
|
|||
place_pos = pt.above
|
||||
end
|
||||
|
||||
if not plantslib:node_is_owned(place_pos, placer) then
|
||||
if not minetest.is_protected(place_pos, placer:get_player_name()) then
|
||||
|
||||
local nodename = "default:cobble" -- if this block appears, something went....wrong :-)
|
||||
|
||||
|
@ -194,7 +194,7 @@ for i in ipairs(algae_list) do
|
|||
place_pos = pt.above
|
||||
end
|
||||
|
||||
if not plantslib:node_is_owned(place_pos, placer) then
|
||||
if not minetest.is_protected(place_pos, placer:get_player_name()) then
|
||||
|
||||
local nodename = "default:cobble" -- :D
|
||||
|
||||
|
|
|
@ -439,42 +439,6 @@ function plantslib:grow_tree(pos, node_or_function_or_model)
|
|||
minetest.spawn_tree(pos, node_or_function_or_model)
|
||||
end
|
||||
|
||||
-- check if a node is owned before allowing manual placement of a node
|
||||
-- (used by flowers_plus)
|
||||
|
||||
function plantslib:node_is_owned(pos, placer)
|
||||
local ownername = false
|
||||
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
|
||||
if HasOwner(pos, placer) then -- returns true if the node is owned
|
||||
if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
|
||||
if type(getLastOwner) == "function" then -- ...is an old version
|
||||
ownername = getLastOwner(pos)
|
||||
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
|
||||
ownername = GetNodeOwnerName(pos)
|
||||
else
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif type(isprotect)=="function" then -- glomie's protection mod
|
||||
if not isprotect(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod
|
||||
if not protector.can_dig(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
|
||||
if ownername ~= false then
|
||||
minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Check for infinite stacks
|
||||
|
||||
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
|
||||
|
|
Loading…
Reference in New Issue
Block a user