From 709bb4ec16c60aa7cfa1357ae59cd2d0ccb54b0f Mon Sep 17 00:00:00 2001 From: upsilon Date: Sun, 15 Jan 2017 13:05:05 +0100 Subject: [PATCH] Record protection violations --- init.lua | 4 +++- registration.lua | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 479e04f..3caa1a0 100644 --- a/init.lua +++ b/init.lua @@ -68,6 +68,7 @@ local function arrow_step(self, dtime) end 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") return 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 local playername = placer:get_player_name() 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}) itemstack:take_item() return itemstack 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.record_protection_violation(pointed_thing.above, playername) return itemstack end else diff --git a/registration.lua b/registration.lua index 7517e0e..6003d19 100644 --- a/registration.lua +++ b/registration.lua @@ -112,6 +112,11 @@ if get_setting("build_arrow") then minetest.log("warning", "[throwing] BUG: node at last_pos was not air") return 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"}) end) end