From 02ea436a939071ce3cfd2b18f0b55d886aa5aa0a Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 4 Feb 2017 22:21:37 +0100 Subject: Add protection support (#3) --- init.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 10307d7..a26f7ab 100644 --- a/init.lua +++ b/init.lua @@ -8,7 +8,12 @@ else end end -function rgblightstone.autofill(pos,player) +function rgblightstone.autofill(pos, player) + local name = player:get_player_name() + if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, { protection_bypass = true }) then + minetest.record_protection_violation(pos, name) + return + end local meta = minetest.get_meta(pos) if (not meta:get_string("channel")) or meta:get_string("channel")=="" then local pos_above = {x=pos.x,y=pos.y+1,z=pos.z} @@ -48,6 +53,11 @@ minetest.register_node("rgblightstone:rgblightstone", { rgblightstone.autofill(pos,player) end, on_receive_fields = function(pos, formname, fields, sender) + local name = sender:get_player_name() + if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, { protection_bypass = true }) then + minetest.record_protection_violation(pos, name) + return + end local meta = minetest.get_meta(pos) if fields.autofill then rgblightstone.autofill(pos,sender) -- cgit v1.2.3