Add "protection_bypass" priv.
authorAuke Kok <sofar@foo-projects.org>
Wed, 20 Jan 2016 14:29:48 +0000 (14:29 +0000)
committerparamat <mat.gregory@virginmedia.com>
Sun, 13 Mar 2016 04:48:57 +0000 (04:48 +0000)
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
mods/default/nodes.lua
mods/doors/init.lua

index c86deccd0077a7c25589f1b242de2a9f209ab638..71f8f1cbcb075edb14e93b82ea1f0e14302912e6 100644 (file)
@@ -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
index 7b03383d6150d7e1d8ea4c34a158f865058cdbc9..a7fd43fa18a2b21fdf3ab6bad99d9c9a1703fc33 100644 (file)
@@ -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
index 32d2845c39533717b9c91ef38763cb17b5a85686..e5962bd3a3f5452f6060c958c4849d83e40abccb 100644 (file)
@@ -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)