Fix chest formspec protection (#540)

This closes #539.
This commit is contained in:
Hugo Locurcio 2020-04-26 11:32:42 +02:00 committed by GitHub
parent f3828c1943
commit 4a9ad94bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,6 +159,16 @@ local function get_receive_fields(name, data)
return function(pos, formname, fields, sender) return function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local page = "main" 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 if fields.sort or (data.autosort and fields.quit and meta:get_int("autosort") == 1) then
sort_inventory(meta:get_inventory()) sort_inventory(meta:get_inventory())
end end