summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorgpcf <gabriel@gpcf.eu>2017-10-10 20:17:43 +0200
committerLNJ <git@lnj.li>2017-10-10 20:17:43 +0200
commitf6a89e19bf2e9ea48691157a352a79697e276ba7 (patch)
tree42e92c9aaa7fe9cf3d449e6a9508ac3873be9fe4 /lua
parent8209b58b9a42b1228d511bea69f198db13b55e53 (diff)
Add support for protections (#10)
Diffstat (limited to 'lua')
-rwxr-xr-xlua/visual.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/lua/visual.lua b/lua/visual.lua
index db0f570..ca7db07 100755
--- a/lua/visual.lua
+++ b/lua/visual.lua
@@ -147,6 +147,10 @@ core.register_entity("drawers:visual", {
end,
on_rightclick = function(self, clicker)
+ if core.is_protected(self.drawer_pos, clicker:get_player_name()) then
+ core.record_protection_violation(self.drawer_pos, clicker:get_player_name())
+ return
+ end
local leftover = self.try_insert_stack(self, clicker:get_wielded_item(),
not clicker:get_player_control().sneak)
@@ -160,7 +164,10 @@ core.register_entity("drawers:visual", {
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
local add_stack = not puncher:get_player_control().sneak
-
+ if core.is_protected(self.drawer_pos, puncher:get_player_name()) then
+ core.record_protection_violation(self.drawer_pos, puncher:get_player_name())
+ return
+ end
local inv = puncher:get_inventory()
local spaceChecker = ItemStack(self.itemName)
if add_stack then