forked from minetest/minetest_game
Creative: Prevent unauthorized item access (#1840)
This commit is contained in:
parent
c2f3c99cad
commit
a1d35f3d69
|
@ -10,22 +10,25 @@ function creative.init_creative_inventory(player)
|
||||||
|
|
||||||
minetest.create_detached_inventory("creative_" .. player_name, {
|
minetest.create_detached_inventory("creative_" .. player_name, {
|
||||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
||||||
if not to_list == "main" then
|
local name = player2 and player2:get_player_name() or ""
|
||||||
return count
|
if not creative.is_enabled_for(name) or
|
||||||
else
|
to_list == "main" then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
return count
|
||||||
end,
|
end,
|
||||||
allow_put = function(inv, listname, index, stack, player2)
|
allow_put = function(inv, listname, index, stack, player2)
|
||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
allow_take = function(inv, listname, index, stack, player2)
|
allow_take = function(inv, listname, index, stack, player2)
|
||||||
|
local name = player2 and player2:get_player_name() or ""
|
||||||
|
if not creative.is_enabled_for(name) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
return -1
|
return -1
|
||||||
end,
|
end,
|
||||||
on_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
on_move = function(inv, from_list, from_index, to_list, to_index, count, player2)
|
||||||
end,
|
end,
|
||||||
on_put = function(inv, listname, index, stack, player2)
|
|
||||||
end,
|
|
||||||
on_take = function(inv, listname, index, stack, player2)
|
on_take = function(inv, listname, index, stack, player2)
|
||||||
if stack and stack:get_count() > 0 then
|
if stack and stack:get_count() > 0 then
|
||||||
minetest.log("action", player_name .. " takes " .. stack:get_name().. " from creative inventory")
|
minetest.log("action", player_name .. " takes " .. stack:get_name().. " from creative inventory")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user