mirror of
https://github.com/minetest-mods/throwing.git
synced 2025-01-10 10:10:25 +01:00
Record protection violations
This commit is contained in:
parent
13aaea70fa
commit
709bb4ec16
4
init.lua
4
init.lua
@ -68,6 +68,7 @@ local function arrow_step(self, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if node and minetest.is_protected(pos, self.player) then -- Forbid hitting nodes in protected areas
|
if node and minetest.is_protected(pos, self.player) then -- Forbid hitting nodes in protected areas
|
||||||
|
minetest.record_protection_violation(pos, self.player)
|
||||||
logging("hitted a node into a protected area")
|
logging("hitted a node into a protected area")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -172,12 +173,13 @@ function throwing.register_arrow(name, itemcraft, craft_quantity, description, t
|
|||||||
if minetest.setting_getbool("throwing.allow_arrow_placing") and pointed_thing.above then
|
if minetest.setting_getbool("throwing.allow_arrow_placing") and pointed_thing.above then
|
||||||
local playername = placer:get_player_name()
|
local playername = placer:get_player_name()
|
||||||
if not minetest.is_protected(pointed_thing.above, playername) then
|
if not minetest.is_protected(pointed_thing.above, playername) then
|
||||||
minetest.log("action", "Player "..playername.." placed arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
|
minetest.log("action", "Player "..playername.." placed arrow "..throwing.modname..":"..name.." at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
|
||||||
minetest.set_node(pointed_thing.above, {name = throwing.modname..":"..name})
|
minetest.set_node(pointed_thing.above, {name = throwing.modname..":"..name})
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack
|
return itemstack
|
||||||
else
|
else
|
||||||
minetest.log("warning", "Player "..playername.." tried to place arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
|
minetest.log("warning", "Player "..playername.." tried to place arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
|
||||||
|
minetest.record_protection_violation(pointed_thing.above, playername)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -112,6 +112,11 @@ if get_setting("build_arrow") then
|
|||||||
minetest.log("warning", "[throwing] BUG: node at last_pos was not air")
|
minetest.log("warning", "[throwing] BUG: node at last_pos was not air")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local playername = hitter:get_player_name()
|
||||||
|
if minetest.is_protected(last_pos, playername) then
|
||||||
|
minetest.record_protection_violation(last_pos, playername)
|
||||||
|
return false, "protected position"
|
||||||
|
end
|
||||||
return minetest.place_node(last_pos, {name="default:obsidian_glass"})
|
return minetest.place_node(last_pos, {name="default:obsidian_glass"})
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user