Skip to content

Commit f627ef3

Browse files
sofarparamat
authored andcommittedMar 11, 2016
Introduce "protection_bypass" privilege.
This privilege allows map protection bypassing for server operators and world moderators. Initially I had thought that bypassing protection mods would have been something that could entirely be done inside mods and minetest_game, but the concept of protection is defined in core, in the code of core.is_protected(). I don't feel that it would be logical to introduce a protection concept in core, but not some way around that for server operators to maintain map parts that need fixing, de-griefing or cleanup. Others had noticed the same problems, and proposed a patch to minetest_game. That patch is fine by itself, but it fails to add protection bypass functionality for digging normal nodes and placing nodes. So, instead, we indroduce the new priv "protection_bypass" in core, and modify 'on_place_node' and 'node_dig' to allow bypassing node protections if the player holds this priv. This priv was tested with protector redo by tenplus1. A followup patch to Minetest Game will include allowing special checks for doors, trapdoors, chests in Minetest Game. Protection mods will likely want to mimic the changes in their relevant code sections.
1 parent dc8bf4e commit f627ef3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎builtin/game/item.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2)
233233
place_to = {x = under.x, y = under.y, z = under.z}
234234
end
235235

236-
if core.is_protected(place_to, placer:get_player_name()) then
236+
if core.is_protected(place_to, placer:get_player_name()) and
237+
not minetest.check_player_privs(placer, "protection_bypass") then
237238
core.log("action", placer:get_player_name()
238239
.. " tried to place " .. def.name
239240
.. " at protected position "
@@ -444,7 +445,8 @@ function core.node_dig(pos, node, digger)
444445
return
445446
end
446447

447-
if core.is_protected(pos, digger:get_player_name()) then
448+
if core.is_protected(pos, digger:get_player_name()) and
449+
not minetest.check_player_privs(digger, "protection_bypass") then
448450
core.log("action", digger:get_player_name()
449451
.. " tried to dig " .. node.name
450452
.. " at protected position "

‎builtin/game/privileges.lua

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ core.register_privilege("settime", "Can use /time")
3232
core.register_privilege("privs", "Can modify privileges")
3333
core.register_privilege("basic_privs", "Can modify 'shout' and 'interact' privileges")
3434
core.register_privilege("server", "Can do server maintenance stuff")
35+
core.register_privilege("protection_bypass", "Can bypass node protection in the world")
3536
core.register_privilege("shout", "Can speak in chat")
3637
core.register_privilege("ban", "Can ban and unban players")
3738
core.register_privilege("kick", "Can kick players")

0 commit comments

Comments
 (0)
Please sign in to comment.