Add is_protected_action for some actions

This commit is contained in:
MoNTE48 2019-09-07 15:12:27 +02:00 committed by MoNTE48
parent 92be185b43
commit 6689051fb8
3 changed files with 8 additions and 3 deletions

View File

@ -17,7 +17,7 @@ bucket.liquids = {}
local S = intllib.make_gettext_pair()
local function check_protection(pos, name, text)
if minetest.is_protected(pos, name) then
if minetest.is_protected_action(pos, name) then
minetest.log("action", (name ~= "" and name or "A mod")
.. " tried to " .. text
.. " at protected position "

View File

@ -226,7 +226,7 @@ function doors.register(name, def)
end
local pn = placer and placer:get_player_name() or ""
if minetest.is_protected(pos, pn) or minetest.is_protected(above, pn) then
if minetest.is_protected_action(pos, pn) or minetest.is_protected(above, pn) then
return itemstack
end

View File

@ -2405,6 +2405,11 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
minetest.log("warning", "[mobs] Mod profiling enabled, damage not enabled")
return
end
-- is mob protected?
if hitter:is_player() and mobs.is_creative(hitter) and minetest.is_protected_action(self.object:get_pos(), hitter:get_player_name()) then
return
end
-- is mob protected?
if self.protected and hitter:is_player()
@ -3452,7 +3457,7 @@ end
local function spawn_mob(pos, mob, data, placer)
if not pos or not placer or not minetest.registered_entities[mob] or
minetest.is_protected(pos, placer:get_player_name()) then
minetest.is_protected_action(pos, placer:get_player_name()) then
return
end
pos.y = pos.y + 1