Skip to content

Commit e8bcfdc

Browse files
EkdohibsShadowNinja
authored andcommittedDec 14, 2013
Check for area protection in buckets
1 parent 64fdb49 commit e8bcfdc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

‎mods/bucket/init.lua

+24
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ minetest.register_craft({
1818
bucket = {}
1919
bucket.liquids = {}
2020

21+
local function check_protection(pos, name, text)
22+
if minetest.is_protected(pos, name) then
23+
minetest.log("action", name
24+
.. " tried to " .. text
25+
.. " at protected position "
26+
.. minetest.pos_to_string(pos)
27+
.. " with a bucket")
28+
minetest.record_protection_violation(pos, name)
29+
return true
30+
end
31+
return false
32+
end
33+
2134
-- Register a new liquid
2235
-- source = name of the source node
2336
-- flowing = name of the flowing node
@@ -55,6 +68,11 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
5568
end
5669

5770
local place_liquid = function(pos, node, source, flowing, fullness)
71+
if check_protection(pos,
72+
user:get_player_name(),
73+
"place "..source) then
74+
return
75+
end
5876
if math.floor(fullness/128) == 1 or (not minetest.setting_getbool("liquid_finite")) then
5977
minetest.add_node(pos, {name=source, param2=fullness})
6078
return
@@ -112,6 +130,12 @@ minetest.register_craftitem("bucket:bucket_empty", {
112130
if liquiddef ~= nil and liquiddef.itemname ~= nil and (node.name == liquiddef.source or
113131
(node.name == liquiddef.flowing and minetest.setting_getbool("liquid_finite"))) then
114132

133+
if check_protection(pointed_thing.under,
134+
user:get_player_name(),
135+
"take ".. node.name) then
136+
return
137+
end
138+
115139
minetest.add_node(pointed_thing.under, {name="air"})
116140

117141
if node.name == liquiddef.source then node.param2 = LIQUID_MAX end

0 commit comments

Comments
 (0)
Please sign in to comment.