@@ -18,6 +18,19 @@ minetest.register_craft({
18
18
bucket = {}
19
19
bucket .liquids = {}
20
20
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
+
21
34
-- Register a new liquid
22
35
-- source = name of the source node
23
36
-- flowing = name of the flowing node
@@ -55,6 +68,11 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
55
68
end
56
69
57
70
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
58
76
if math.floor (fullness / 128 ) == 1 or (not minetest .setting_getbool (" liquid_finite" )) then
59
77
minetest .add_node (pos , {name = source , param2 = fullness })
60
78
return
@@ -112,6 +130,12 @@ minetest.register_craftitem("bucket:bucket_empty", {
112
130
if liquiddef ~= nil and liquiddef .itemname ~= nil and (node .name == liquiddef .source or
113
131
(node .name == liquiddef .flowing and minetest .setting_getbool (" liquid_finite" ))) then
114
132
133
+ if check_protection (pointed_thing .under ,
134
+ user :get_player_name (),
135
+ " take " .. node .name ) then
136
+ return
137
+ end
138
+
115
139
minetest .add_node (pointed_thing .under , {name = " air" })
116
140
117
141
if node .name == liquiddef .source then node .param2 = LIQUID_MAX end
0 commit comments