forked from Mirrorlandia_minetest/minetest
Docs: Clarify where to check for 'protection_bypass' (#8675)
This commit is contained in:
parent
0c31946943
commit
47492386ec
@ -251,11 +251,6 @@ local function user_name(user)
|
|||||||
return user and user:get_player_name() or ""
|
return user and user:get_player_name() or ""
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_protected(pos, name)
|
|
||||||
return core.is_protected(pos, name) and
|
|
||||||
not minetest.check_player_privs(name, "protection_bypass")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Returns a logging function. For empty names, does not log.
|
-- Returns a logging function. For empty names, does not log.
|
||||||
local function make_log(name)
|
local function make_log(name)
|
||||||
return name ~= "" and core.log or function() end
|
return name ~= "" and core.log or function() end
|
||||||
@ -302,7 +297,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
|
|||||||
place_to = {x = under.x, y = under.y, z = under.z}
|
place_to = {x = under.x, y = under.y, z = under.z}
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_protected(place_to, playername) then
|
if core.is_protected(place_to, playername) then
|
||||||
log("action", playername
|
log("action", playername
|
||||||
.. " tried to place " .. def.name
|
.. " tried to place " .. def.name
|
||||||
.. " at protected position "
|
.. " at protected position "
|
||||||
@ -552,7 +547,7 @@ function core.node_dig(pos, node, digger)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_protected(pos, diggername) then
|
if core.is_protected(pos, diggername) then
|
||||||
log("action", diggername
|
log("action", diggername
|
||||||
.. " tried to dig " .. node.name
|
.. " tried to dig " .. node.name
|
||||||
.. " at protected position "
|
.. " at protected position "
|
||||||
|
@ -4856,15 +4856,13 @@ Misc.
|
|||||||
* `minetest.decode_base64(string)`: returns string
|
* `minetest.decode_base64(string)`: returns string
|
||||||
* Decodes a string encoded in base64.
|
* Decodes a string encoded in base64.
|
||||||
* `minetest.is_protected(pos, name)`: returns boolean
|
* `minetest.is_protected(pos, name)`: returns boolean
|
||||||
* Returns true, if player `name` shouldn't be able to dig at `pos` or do
|
* Returning `true` restricts the player `name` from modifying (i.e. digging,
|
||||||
other actions, definable by mods, due to some mod-defined ownership-like
|
placing) the node at position `pos`.
|
||||||
concept.
|
* `name` will be `""` for non-players or unknown players.
|
||||||
* Returns false or nil, if the player is allowed to do such actions.
|
* This function should be overridden by protection mods. It is highly
|
||||||
* `name` will be "" for non-players or unknown players.
|
recommended to grant access to players with the `protection_bypass` privilege.
|
||||||
* This function should be overridden by protection mods and should be used
|
* Cache and call the old version of this function if the position is
|
||||||
to check if a player can interact at a position.
|
not protected by the mod. This will allow using multiple protection mods.
|
||||||
* This function should call the old version of itself if the position is
|
|
||||||
not protected by the mod.
|
|
||||||
* Example:
|
* Example:
|
||||||
|
|
||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = minetest.is_protected
|
||||||
|
Loading…
Reference in New Issue
Block a user