From 2fb40be4098cd6964b5247a7227c79be9576331a Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 20 Jan 2016 14:29:48 +0000 Subject: [PATCH] Add "protection_bypass" priv. The access privilege allows players that have it to bypass protection on locked doors/trapdoors, chests and bones. The priv also allows bypassing any minetest.is_protected() check, including digging nodes and placing them. It is meant for world moderators to clean up and fix map issues. Original patch by red-001. Split up and rebased/rewritten by sofar. This patch requires https://github.com/minetest/minetest/pull/3800 --- mods/bones/init.lua | 2 +- mods/default/nodes.lua | 3 +++ mods/doors/init.lua | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mods/bones/init.lua b/mods/bones/init.lua index c86deccd..71f8f1cb 100644 --- a/mods/bones/init.lua +++ b/mods/bones/init.lua @@ -5,7 +5,7 @@ bones = {} local function is_owner(pos, name) local owner = minetest.get_meta(pos):get_string("owner") - if owner == "" or owner == name then + if owner == "" or owner == name or minetest.check_player_privs(placer, "protection_bypass") then return true end return false diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 7b03383d..a7fd43fa 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -1414,6 +1414,9 @@ end local function has_locked_chest_privilege(meta, player) local name = "" if player then + if minetest.check_player_privs(player, "protection_bypass") then + return true + end name = player:get_player_name() end if name ~= meta:get_string("owner") then diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 32d2845c..e5962bd3 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -121,7 +121,7 @@ function _doors.door_toggle(pos, clicker) local def = minetest.registered_nodes[minetest.get_node(pos).name] local name = def.door.name - if clicker then + if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then local owner = meta:get_string("doors_owner") if owner ~= "" then if clicker:get_player_name() ~= owner then @@ -492,7 +492,7 @@ end ----trapdoor---- function _doors.trapdoor_toggle(pos, clicker) - if clicker then + if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then local meta = minetest.get_meta(pos) local owner = meta:get_string("doors_owner") if owner ~= "" then @@ -519,7 +519,7 @@ function doors.register_trapdoor(name, def) local name_opened = name.."_open" local function check_player_priv(pos, player) - if not def.protected then + if not def.protected or minetest.check_player_privs(player, "protection_bypass") then return true end local meta = minetest.get_meta(pos) -- 2.25.1