Skip to content

Commit a1d35f3

Browse files
authoredJul 22, 2017
Creative: Prevent unauthorized item access (#1840)
1 parent c2f3c99 commit a1d35f3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
 

‎mods/creative/inventory.lua

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,25 @@ function creative.init_creative_inventory(player)
1010

1111
minetest.create_detached_inventory("creative_" .. player_name, {
1212
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
13-
if not to_list == "main" then
14-
return count
15-
else
13+
local name = player2 and player2:get_player_name() or ""
14+
if not creative.is_enabled_for(name) or
15+
to_list == "main" then
1616
return 0
1717
end
18+
return count
1819
end,
1920
allow_put = function(inv, listname, index, stack, player2)
2021
return 0
2122
end,
2223
allow_take = function(inv, listname, index, stack, player2)
24+
local name = player2 and player2:get_player_name() or ""
25+
if not creative.is_enabled_for(name) then
26+
return 0
27+
end
2328
return -1
2429
end,
2530
on_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
2631
end,
27-
on_put = function(inv, listname, index, stack, player2)
28-
end,
2932
on_take = function(inv, listname, index, stack, player2)
3033
if stack and stack:get_count() > 0 then
3134
minetest.log("action", player_name .. " takes " .. stack:get_name().. " from creative inventory")

0 commit comments

Comments
 (0)