Fix chest formspec protection

This closes #539.
This commit is contained in:
Hugo Locurcio 2020-03-26 09:53:48 +01:00
parent f3828c1943
commit 8c222ea895
1 changed files with 10 additions and 0 deletions

View File

@ -159,6 +159,16 @@ local function get_receive_fields(name, data)
return function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local page = "main"
local owner = meta:get_string("owner")
if owner ~= "" then
-- prevent modification of locked chests
if owner ~= sender:get_player_name() then return end
elseif not fields.quit then
-- prevent modification of protected chests
if minetest.is_protected(pos, sender:get_player_name()) then return end
end
if fields.sort or (data.autosort and fields.quit and meta:get_int("autosort") == 1) then
sort_inventory(meta:get_inventory())
end