diff --git a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua index 58097213a7..1feb888987 100644 --- a/mods/ITEMS/REDSTONE/mcl_comparators/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_comparators/init.lua @@ -153,7 +153,12 @@ end local make_rightclick_handler = function(state, mode) local newnodename = "mcl_comparators:comparator_"..state.."_"..flipmode(mode) - return function (pos, node) + return function (pos, node, clicker) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end minetest.swap_node(pos, {name = newnodename, param2 = node.param2 }) end end diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 0642f7f102..2c3c6b7892 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -50,6 +50,33 @@ end local dispenserdef = { is_ground_content = false, sounds = mcl_sounds.node_sound_stone_defaults(), + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return count + end + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) local meta2 = meta diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index f67cfc4b44..be42e79a4f 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -63,6 +63,33 @@ local dropperdef = { end meta:from_table(meta2:to_table()) end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return count + end + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, _mcl_blast_resistance = 17.5, _mcl_hardness = 3.5, mesecons = {effector = { diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 4047a926a9..acb1a9d001 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -131,9 +131,14 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing) if not minetest.settings:get_bool("creative_mode") then return end - local privs = minetest.get_player_privs(player:get_player_name()) + local pname = player:get_player_name() + if minetest.is_protected(pos, pname) then + minetest.record_protection_violation(pos, pname) + return + end + local privs = minetest.get_player_privs(pname) if not privs.maphack then - minetest.chat_send_player(player:get_player_name(), "Access denied. You need the “maphack” privilege to edit command blocks.") + minetest.chat_send_player(pname, "Access denied. You need the “maphack” privilege to edit command blocks.") return end @@ -152,7 +157,7 @@ local on_rightclick = function(pos, node, player, itemstack, pointed_thing) "image_button[8,4.5;1,1;doc_button_icon_lores.png;doc;]" .. "label[0,4;"..minetest.formspec_escape(commanderstr).."]" .. "tooltip[doc;Help]" - minetest.show_formspec(player:get_player_name(), "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec) + minetest.show_formspec(pname, "commandblock_"..pos.x.."_"..pos.y.."_"..pos.z, formspec) end local on_place = function(itemstack, placer, pointed_thing) diff --git a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua index d6c1f95bb0..ea4638442c 100644 --- a/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_delayer/init.lua @@ -254,7 +254,12 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { sunlight_propagates = false, is_ground_content = false, drop = 'mesecons_delayer:delayer_off_1', - on_rightclick = function (pos, node) + on_rightclick = function (pos, node, clicker) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.report_protection_violation(pos, protname) + return + end if node.name=="mesecons_delayer:delayer_off_1" then minetest.set_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) elseif node.name=="mesecons_delayer:delayer_off_2" then @@ -317,7 +322,12 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { sunlight_propagates = false, is_ground_content = false, drop = 'mesecons_delayer:delayer_off_1', - on_rightclick = function (pos, node) + on_rightclick = function (pos, node, clicker) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.report_protection_violation(pos, protname) + return + end if node.name=="mesecons_delayer:delayer_on_1" then minetest.set_node(pos, {name="mesecons_delayer:delayer_on_2",param2=node.param2}) elseif node.name=="mesecons_delayer:delayer_on_2" then diff --git a/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua index 191c443694..9d1737ac63 100644 --- a/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_noteblock/init.lua @@ -14,7 +14,12 @@ The note block will only play a note when it is below air, otherwise, it stays s groups = {handy=1,axey=1, material_wood=1}, is_ground_content = false, place_param2 = 0, - on_rightclick = function (pos, node) -- change sound when rightclicked + on_rightclick = function (pos, node, clicker) -- change sound when rightclicked + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end node.param2 = (node.param2+1)%24 mesecon.noteblock_play(pos, node.param2) minetest.set_node(pos, node) diff --git a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua index 1c66b61910..0bd0b737a3 100644 --- a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua @@ -27,6 +27,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", { rules = mesecon.rules.pplate, }}, on_rightclick = function(pos, node, clicker, pointed_thing) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_off"}) mesecon.receptor_off(pos, mesecon.rules.pplate) end, @@ -60,6 +65,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", { rules = mesecon.rules.pplate, }}, on_rightclick = function(pos, node, clicker, pointed_thing) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_on"}) mesecon.receptor_on(pos, mesecon.rules.pplate) end, @@ -134,6 +144,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_inverted_on", { rules = mesecon.rules.pplate, }}, on_rightclick = function(pos, node, clicker, pointed_thing) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_off"}) mesecon.receptor_off(pos, mesecon.rules.pplate) end, @@ -168,6 +183,11 @@ minetest.register_node("mesecons_solarpanel:solar_panel_inverted_off", { rules = mesecon.rules.pplate, }}, on_rightclick = function(pos, node, clicker, pointed_thing) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_on"}) mesecon.receptor_on(pos, mesecon.rules.pplate) end, diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index 78db3ba9cf..3863583f7e 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -277,15 +277,32 @@ local anvildef = { drop_anvil_items(pos, meta) meta:from_table(meta2:to_table()) end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) - if listname == "output" then + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + elseif listname == "output" then return 0 else return stack:get_count() end end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - if to_list == "output" then + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + elseif to_list == "output" then return 0 elseif from_list == "output" and to_list == "input" then local meta = minetest.get_meta(pos) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 5eac32eff9..f53cad4cec 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -53,7 +53,8 @@ end -- name = user-visible bucket description -- longdesc = long explanatory description (for help) -- usagehelp = short usage explanation (for help) --- extra_check = optional function(pos) which can returns false to avoid placing the liquid +-- extra_check(pos, placer) = optional function(pos) which can returns false to avoid placing the liquid. +-- placer is object/player who is placing the liquid, can be nil -- groups = optional list of item groups -- -- This function can be called from any mod (which depends on this one) @@ -103,12 +104,13 @@ function mcl_buckets.register_liquid(source_place, source_take, itemname, invent -- Check if pointing to a buildable node local item = itemstack:get_name() - if extra_check and extra_check(place_pos) == false then + if extra_check and extra_check(place_pos, user) == false then -- Fail placement of liquid elseif minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then -- buildable; replace the node local pns = user:get_player_name() if minetest.is_protected(place_pos, pns) then + minetest.record_protection_violation(place_pos, pns) return itemstack end place_liquid(place_pos, node_place) @@ -122,6 +124,7 @@ function mcl_buckets.register_liquid(source_place, source_take, itemname, invent if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then local pn = user:get_player_name() if minetest.is_protected(pointed_thing.above, pn) then + minetest.record_protection_violation(pointed_thing.above, pn) return itemstack end place_liquid(pointed_thing.above, node_place) @@ -159,11 +162,12 @@ function mcl_buckets.register_liquid(source_place, source_take, itemname, invent local iname = stack:get_name() local buildable = minetest.registered_nodes[dropnode.name].buildable_to - if extra_check and extra_check(droppos) == false then + if extra_check and extra_check(droppos, nil) == false then -- Fail placement of liquid elseif buildable then -- buildable; replace the node if minetest.is_protected(droppos, "") then + minetest.record_protection_violation(droppos, "") return stack end local node_place @@ -192,7 +196,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { on_place = function(itemstack, user, pointed_thing) -- Must be pointing to node if pointed_thing.type ~= "node" then - return + return itemstack end -- Call on_rightclick if the pointed node defines it @@ -204,6 +208,12 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { end end + -- Can't steal liquids + if minetest.is_protected(pointed_thing.above, pointed_thing.under) then + minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) + return itemstack + end + -- Check if pointing to a liquid source local liquiddef = mcl_buckets.liquids[nn] local new_bucket @@ -257,6 +267,11 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { end end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) + if minetest.is_protected(droppos, "") then + minetest.record_protection_violation(droppos, "") + return stack + end + -- Fill empty bucket with liquid or drop bucket if no liquid local collect_liquid = false @@ -310,7 +325,13 @@ if mod_mcl_core then "Water Bucket", "A bucket can be used to collect and release liquids. This one is filled with water.", "Right-click on any block to empty the bucket and put a water source on this spot.", - function(pos) + function(pos, placer) + -- Check protection + local placer_name = placer:get_player_name() + if minetest.is_protected(pos, placer_name) then + minetest.record_protection_violation(pos, placer_name) + return false + end local nn = minetest.get_node(pos).name -- Pour water into cauldron if minetest.get_item_group(nn, "cauldron") ~= 0 then @@ -343,7 +364,13 @@ if mod_mclx_core then "River Water Bucket", "A bucket can be used to collect and release liquids. This one is filled with river water.", "Right-click on any block to empty the bucket and put a river water source on this spot.", - function(pos) + function(pos, placer) + -- Check protection + local placer_name = placer:get_player_name() + if minetest.is_protected(pos, placer_name) then + minetest.record_protection_violation(pos, placer_name) + return false + end local nn = minetest.get_node(pos).name -- Pour into cauldron if minetest.get_item_group(nn, "cauldron") ~= 0 then diff --git a/mods/ITEMS/mcl_cake/init.lua b/mods/ITEMS/mcl_cake/init.lua index 75542fb936..ca6f7a5564 100644 --- a/mods/ITEMS/mcl_cake/init.lua +++ b/mods/ITEMS/mcl_cake/init.lua @@ -49,6 +49,12 @@ minetest.register_node("mcl_cake:cake", { groups = {handy=1, cake=7, food=2,no_eat_delay=1, attached_node=1, dig_by_piston=1, comparator_signal=14}, drop = '', on_rightclick = function(pos, node, clicker, itemstack) + -- Cake is subject to protection + local name = clicker:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return + end local newcake = minetest.do_item_eat(2, ItemStack("mcl_cake:cake_6"), ItemStack("mcl_cake:cake"), clicker, {type="nothing"}) -- Check if we were allowed to eat if newcake:get_name() ~= "mcl_cake:cake" or minetest.settings:get_bool("creative_mode") == true then @@ -69,6 +75,11 @@ local register_slice = function(level, nodebox, desc) local on_rightclick if level > 1 then on_rightclick = function(pos, node, clicker, itemstack) + local name = clicker:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return + end local newcake = minetest.do_item_eat(2, ItemStack(after_eat), ItemStack(this), clicker, {type="nothing"}) -- Check if we were allowed to eat if newcake:get_name() ~= this or minetest.settings:get_bool("creative_mode") == true then @@ -78,6 +89,11 @@ local register_slice = function(level, nodebox, desc) else -- Last slice on_rightclick = function(pos, node, clicker, itemstack) + local name = clicker:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return + end local newcake = minetest.do_item_eat(2, ItemStack("mcl:cake:cake 0"), ItemStack("mcl_cake:cake_1"), clicker, {type="nothing"}) -- Check if we were allowed to eat if newcake:get_name() ~= this or minetest.settings:get_bool("creative_mode") == true then diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index e17dcd5978..57c991ce3f 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -15,6 +15,26 @@ local player_chest_open = function(player, pos) open_chests[player:get_player_name()] = { pos = pos } end +-- Simple protection checking functions +local protection_check_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return count + end +end +local protection_check_put_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end +end + local trapped_chest_mesecons_rules = mesecon.rules.pplate -- To be called if a player closed a chest @@ -122,6 +142,9 @@ minetest.register_node("mcl_chests:"..basename, { end meta:from_table(meta2:to_table()) end, + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, + allow_metadata_inventory_put = protection_check_put_take, on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) minetest.log("action", player:get_player_name().. " moves stuff in chest at "..minetest.pos_to_string(pos)) @@ -211,9 +234,15 @@ minetest.register_node("mcl_chests:"..basename.."_left", { end meta:from_table(meta2:to_table()) end, - -- BEGIN OF LISTRING WORKAROUND + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, allow_metadata_inventory_put = function(pos, listname, index, stack, player) - if listname == "input" then + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + -- BEGIN OF LISTRING WORKAROUND + elseif listname == "input" then local inv = minetest.get_inventory({type="node", pos=pos}) if inv:room_for_item("main", stack) then return -1 @@ -226,11 +255,11 @@ minetest.register_node("mcl_chests:"..basename.."_left", { return 0 end end + -- END OF LISTRING WORKAROUND else return stack:get_count() end end, - -- END OF LISTRING WORKAROUND on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) minetest.log("action", player:get_player_name().. " moves stuff in chest at "..minetest.pos_to_string(pos)) @@ -326,9 +355,15 @@ minetest.register_node("mcl_chests:"..basename.."_right", { end meta:from_table(meta2:to_table()) end, - -- BEGIN OF LISTRING WORKAROUND + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, allow_metadata_inventory_put = function(pos, listname, index, stack, player) - if listname == "input" then + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + -- BEGIN OF LISTRING WORKAROUND + elseif listname == "input" then local other_pos = mcl_util.get_double_container_neighbor_pos(pos, minetest.get_node(pos).param2, "right") local other_inv = minetest.get_inventory({type="node", pos=other_pos}) if other_inv:room_for_item("main", stack) then @@ -341,11 +376,11 @@ minetest.register_node("mcl_chests:"..basename.."_right", { return 0 end end + -- END OF LISTRING WORKAROUND else return stack:get_count() end end, - -- END OF LISTRING WORKAROUND on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) minetest.log("action", player:get_player_name().. " moves stuff in chest at "..minetest.pos_to_string(pos)) @@ -738,7 +773,14 @@ for color, desc in pairs(boxtypes) do minetest.add_item(pos, boxitem) end end, + allow_metadata_inventory_move = protection_check_move, + allow_metadata_inventory_take = protection_check_put_take, allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + end -- Do not allow to place shulker boxes into shulker boxes local group = minetest.get_item_group(stack:get_name(), "shulker_box") if group == 0 or group == nil then diff --git a/mods/ITEMS/mcl_flowerpots/init.lua b/mods/ITEMS/mcl_flowerpots/init.lua index c9187eed14..e4df4459ce 100644 --- a/mods/ITEMS/mcl_flowerpots/init.lua +++ b/mods/ITEMS/mcl_flowerpots/init.lua @@ -53,6 +53,11 @@ minetest.register_node("mcl_flowerpots:flower_pot", { groups = {dig_immediate=3, deco_block=1, attached_node=1, dig_by_piston=1, flower_pot=1}, sounds = mcl_sounds.node_sound_stone_defaults(), on_rightclick = function(pos, node, clicker, itemstack) + local name = clicker:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return + end local item = clicker:get_wielded_item():get_name() for _, row in ipairs(flowers) do local flower = row[1] @@ -120,6 +125,11 @@ minetest.register_node("mcl_flowerpots:flower_pot_"..flower, { groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2}, sounds = mcl_sounds.node_sound_stone_defaults(), on_rightclick = function(pos, item, clicker) + local name = clicker:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return + end minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node) minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"}) end, @@ -163,6 +173,14 @@ minetest.register_node("mcl_flowerpots:flower_pot_"..flower, { groups = {dig_immediate=3, attached_node=1, dig_by_piston=1, not_in_creative_inventory=1, flower_pot=2}, sounds = mcl_sounds.node_sound_stone_defaults(), on_rightclick = function(pos, item, clicker) + local name = "" + if clicker:is_player() then + name = clicker:get_player_name() + end + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return + end minetest.add_item({x=pos.x, y=pos.y+0.5, z=pos.z}, flower_node) minetest.set_node(pos, {name="mcl_flowerpots:flower_pot"}) end, diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index e409bd30b7..9a8804fde1 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -60,7 +60,9 @@ end -- local function allow_metadata_inventory_put(pos, listname, index, stack, player) - if minetest.is_protected(pos, player:get_player_name()) then + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) return 0 end local meta = minetest.get_meta(pos) @@ -111,7 +113,9 @@ local function allow_metadata_inventory_move(pos, from_list, from_index, to_list end local function allow_metadata_inventory_take(pos, listname, index, stack, player) - if minetest.is_protected(pos, player:get_player_name()) then + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) return 0 end return stack:get_count() diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index a05646b732..c7f7b0b9a9 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -71,6 +71,33 @@ local def_hopper = { end meta:from_table(meta2:to_table()) end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return count + end + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) minetest.log("action", player:get_player_name().. " moves stuff in mcl_hoppers at "..minetest.pos_to_string(pos)) @@ -230,6 +257,33 @@ local def_hopper_side = { end meta:from_table(meta2:to_table()) end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return count + end + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) minetest.log("action", player:get_player_name().. " moves stuff in mcl_hoppers at "..minetest.pos_to_string(pos)) diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index b674a1cd18..14170e3b29 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -125,6 +125,11 @@ minetest.register_node("mcl_itemframes:item_frame",{ if not itemstack then return end + local pname = clicker:get_player_name() + if minetest.is_protected(pos, pname) then + minetest.record_protection_violation(pos, pname) + return + end local meta = minetest.get_meta(pos) drop_item(pos, node, meta) local inv = meta:get_inventory() @@ -150,6 +155,33 @@ minetest.register_node("mcl_itemframes:item_frame",{ end return itemstack end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return count + end + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, on_destruct = function(pos) local meta = minetest.get_meta(pos) local node = minetest.get_node(pos) diff --git a/mods/ITEMS/mcl_jukebox/init.lua b/mods/ITEMS/mcl_jukebox/init.lua index 2ee8f8c113..efa29399be 100644 --- a/mods/ITEMS/mcl_jukebox/init.lua +++ b/mods/ITEMS/mcl_jukebox/init.lua @@ -138,7 +138,10 @@ minetest.register_node("mcl_jukebox:jukebox", { on_rightclick= function(pos, node, clicker, itemstack, pointed_thing) if not clicker then return end local cname = clicker:get_player_name() - + if minetest.is_protected(pos, cname) then + minetest.record_protection_violation(pos, cname) + return + end local meta = minetest.get_meta(pos) local inv = meta:get_inventory() if not inv:is_empty("main") then @@ -172,6 +175,33 @@ minetest.register_node("mcl_jukebox:jukebox", { end return itemstack end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return count + end + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, after_dig_node = function(pos, oldnode, oldmetadata, digger) local name = digger:get_player_name() local meta = minetest.get_meta(pos) diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index c172eacfb3..bca803dc15 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -376,6 +376,11 @@ minetest.override_item("mcl_end:ender_eye", { -- Place eye of ender into end portal frame if pointed_thing.under and node.name == "mcl_portals:end_portal_frame" then + local protname = user:get_player_name() + if minetest.is_protected(pointed_thing.under, protname) then + minetest.record_protection_violation(pointed_thing.under, protname) + return itemstack + end minetest.set_node(pointed_thing.under, { name = "mcl_portals:end_portal_frame_eye", param2 = node.param2 }) if minetest.get_modpath("doc") then diff --git a/mods/ITEMS/minetest-3d_armor/3d_armor_stand/init.lua b/mods/ITEMS/minetest-3d_armor/3d_armor_stand/init.lua index d6212e3790..75a050e750 100644 --- a/mods/ITEMS/minetest-3d_armor/3d_armor_stand/init.lua +++ b/mods/ITEMS/minetest-3d_armor/3d_armor_stand/init.lua @@ -120,6 +120,11 @@ minetest.register_node("3d_armor_stand:armor_stand", { on_destruct = drop_armor, -- Put piece of armor on armor stand, or take one away on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + local protname = clicker:get_player_name() + if minetest.is_protected(pos, protname) then + minetest.record_protection_violation(pos, protname) + return + end -- Check if player wields armor local name = itemstack:get_name() local list @@ -177,7 +182,21 @@ minetest.register_node("3d_armor_stand:armor_stand", { after_place_node = function(pos) minetest.add_entity(pos, "3d_armor_stand:armor_entity") end, - allow_metadata_inventory_put = function(pos, listname, index, stack) + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + else + return stack:get_count() + end + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) + return 0 + end local def = stack:get_definition() or {} local groups = def.groups or {} if groups[listname] then @@ -185,7 +204,7 @@ minetest.register_node("3d_armor_stand:armor_stand", { end return 0 end, - allow_metadata_inventory_move = function(pos) + allow_metadata_inventory_move = function() return 0 end, on_metadata_inventory_put = function(pos)