From ca88a35f26c36eef8db06ebd9bd8d77738b505e3 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sun, 22 Jun 2014 22:20:51 -0400 Subject: [PATCH] use minetest built-in functions for node protection phase out the old hand-rolled protection function drops support for old protection mods --- flowers_plus/init.lua | 4 ++-- plants_lib/init.lua | 36 ------------------------------------ 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/flowers_plus/init.lua b/flowers_plus/init.lua index 8e8c533..96c26e0 100644 --- a/flowers_plus/init.lua +++ b/flowers_plus/init.lua @@ -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 diff --git a/plants_lib/init.lua b/plants_lib/init.lua index 9b8908d..232f633 100644 --- a/plants_lib/init.lua +++ b/plants_lib/init.lua @@ -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