Skip to content

Commit

Permalink
Add "protection_bypass" priv.
Browse files Browse the repository at this point in the history
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 minetest/minetest#3800
  • Loading branch information
sofar authored and paramat committed Mar 13, 2016
1 parent f8f7502 commit 2fb40be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mods/bones/init.lua
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions mods/default/nodes.lua
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions mods/doors/init.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 2fb40be

Please sign in to comment.