add protection and ownership checks to default metal sign

This commit is contained in:
Vanessa Dannenberg 2019-05-25 04:45:30 -04:00
parent 34a7242616
commit dfa47c2519

View File

@ -920,7 +920,6 @@ minetest.register_node(":locked_sign:sign_wall_locked", {
-- default metal sign, if defined -- default metal sign, if defined
if minetest.registered_nodes["default:sign_wall_steel"] then
minetest.register_node(":"..default_sign_metal, { minetest.register_node(":"..default_sign_metal, {
description = S("Sign"), description = S("Sign"),
inventory_image = default_sign_metal_image, inventory_image = default_sign_metal_image,
@ -944,14 +943,29 @@ if minetest.registered_nodes["default:sign_wall_steel"] then
signs_lib.destruct_sign(pos) signs_lib.destruct_sign(pos)
end, end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
signs_lib.receive_fields(pos, formname, fields, sender) local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local pname = sender:get_player_name() or ""
if pname ~= owner and pname ~= minetest.settings:get("name")
and not minetest.check_player_privs(pname, {sign_editor=true}) then
return
end
signs_lib.receive_fields(pos, formname, fields, sender, true)
end, end,
on_punch = function(pos, node, puncher) on_punch = function(pos, node, puncher)
signs_lib.update_sign(pos,nil,nil,node) signs_lib.update_sign(pos,nil,nil,node)
end, end,
on_rotate = signs_lib.wallmounted_rotate on_rotate = function(pos, node, user, mode)
}) local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner == user:get_player_name() then
signs_lib.wallmounted_rotate(pos, node, user, mode)
else
return false
end end
end
})
-- metal, colored signs -- metal, colored signs
if enable_colored_metal_signs then if enable_colored_metal_signs then