From: SmallJoker Date: Sat, 22 Jul 2017 18:16:25 +0000 (+0200) Subject: Creative: Prevent unauthorized item access (#1840) X-Git-Tag: 0.4.17.1~30 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1aeb2baa91f96151c18e389cbfc7e27f44bc6170;p=oweals%2Fminetest_game.git Creative: Prevent unauthorized item access (#1840) --- diff --git a/mods/creative/inventory.lua b/mods/creative/inventory.lua index 0e1d813e..00b2aa55 100644 --- a/mods/creative/inventory.lua +++ b/mods/creative/inventory.lua @@ -10,22 +10,25 @@ function creative.init_creative_inventory(player) minetest.create_detached_inventory("creative_" .. player_name, { allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2) - if not to_list == "main" then - return count - else + local name = player2 and player2:get_player_name() or "" + if not creative.is_enabled_for(name) or + to_list == "main" then return 0 end + return count end, allow_put = function(inv, listname, index, stack, player2) return 0 end, 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 end, on_move = function(inv, from_list, from_index, to_list, to_index, count, player2) end, - on_put = function(inv, listname, index, stack, player2) - end, on_take = function(inv, listname, index, stack, player2) if stack and stack:get_count() > 0 then minetest.log("action", player_name .. " takes " .. stack:get_name().. " from creative inventory")