@@ -38,11 +38,11 @@ default.get_translator = S
38
38
-- sound ideas: furnace, eating
39
39
-- falling sand/gravel
40
40
-- investigate long vertical shafts (mgv6 fail?)
41
+ -- some particle effects
41
42
42
43
-- long-term TODOs?:
43
44
-- consider adding unfinished features like firefly spawn & standing signs
44
45
-- texture animations for some
45
- -- protection support
46
46
-- 3d model signs and torches
47
47
-- maybe 3d model mobs
48
48
@@ -895,6 +895,10 @@ minetest.register_node("default:sign_wall", {
895
895
end ,
896
896
on_receive_fields = function (pos , formname , fields , sender )
897
897
local player_name = sender :get_player_name ()
898
+ if minetest .is_protected (pos , player_name ) then
899
+ minetest .record_protection_violation (pos , player_name )
900
+ return
901
+ end
898
902
local meta = minetest .get_meta (pos )
899
903
local text = fields .text
900
904
if not text then
@@ -911,6 +915,20 @@ minetest.register_node("default:sign_wall", {
911
915
end ,
912
916
})
913
917
918
+ local function can_dig_chest (pos , player )
919
+ local meta = minetest .get_meta (pos )
920
+ local inv = meta :get_inventory ()
921
+ if not inv :is_empty (" main" ) then
922
+ return false
923
+ end
924
+ local player_name = player :get_player_name ()
925
+ if minetest .is_protected (pos , player_name ) then
926
+ minetest .record_protection_violation (pos , player_name )
927
+ return false
928
+ end
929
+ return true
930
+ end
931
+
914
932
minetest .register_node (" default:chest" , {
915
933
description = S (" Chest" ),
916
934
tiles = { " chest_top.png" , " chest_top.png" , " chest_side.png" , " chest_side.png" , " chest_side.png" , " chest_front.png" },
@@ -929,22 +947,22 @@ minetest.register_node("default:chest", {
929
947
local inv = meta :get_inventory ()
930
948
inv :set_size (" main" , 8 * 4 )
931
949
end ,
932
- can_dig = function (pos , player )
933
- local meta = minetest .get_meta (pos )
934
- local inv = meta :get_inventory ()
935
- return inv :is_empty (" main" )
936
- end ,
950
+ can_dig = can_dig_chest ,
937
951
})
938
952
939
953
local function can_use_locked_chest (meta , player )
940
- if meta :get_string (" owner" ) == player :get_player_name () then
941
- return true
954
+ local player_name = player :get_player_name ()
955
+ if meta :get_string (" owner" ) ~= player_name then
956
+ -- 0.3 uses the 'server' priv for this
957
+ if not minetest .check_player_privs (player , " protection_bypass" ) then
958
+ return false
959
+ end
942
960
end
943
- -- 0.3 uses the 'server' priv for this
944
- if minetest .check_player_privs ( player , " protection_bypass " ) then
945
- return true
961
+ if minetest . is_protected ( pos , player_name ) then
962
+ minetest .record_protection_violation ( pos , player_name )
963
+ return false
946
964
end
947
- return false
965
+ return true
948
966
end
949
967
950
968
minetest .register_node (" default:chest_locked" , {
@@ -970,11 +988,8 @@ minetest.register_node("default:chest_locked", {
970
988
local inv = meta :get_inventory ()
971
989
inv :set_size (" main" , 8 * 4 )
972
990
end ,
973
- can_dig = function (pos , player )
974
- local meta = minetest .get_meta (pos )
975
- local inv = meta :get_inventory ()
976
- return inv :is_empty (" main" )
977
- end ,
991
+ -- note: can_dig_chest() does not check the owner, this is intentional.
992
+ can_dig = can_dig_chest ,
978
993
allow_metadata_inventory_move = function (pos , from_list , from_index , to_list , to_index , count , player )
979
994
local meta = minetest .get_meta (pos )
980
995
if not can_use_locked_chest (meta , player ) then
0 commit comments