2018-09-19 13:49:01 +02:00
|
|
|
local has_areas_mod = minetest.get_modpath("areas")
|
|
|
|
local has_protector_mod = minetest.get_modpath("protector")
|
2018-09-19 11:14:41 +02:00
|
|
|
|
2019-08-07 17:29:28 +00:00
|
|
|
local protector_radius = (tonumber(minetest.settings:get("protector_radius")) or 5)
|
2018-11-13 10:25:32 +01:00
|
|
|
|
2018-09-19 13:49:01 +02:00
|
|
|
jumpdrive.is_area_protected = function(pos1, pos2, playername)
|
|
|
|
|
2019-12-16 10:05:42 +01:00
|
|
|
local radius_vector = {x=protector_radius, y=protector_radius, z=protector_radius}
|
|
|
|
local check_pos1 = vector.subtract(pos1, radius_vector)
|
|
|
|
local check_pos2 = vector.add(pos2, radius_vector)
|
|
|
|
|
|
|
|
-- preload area with voxel manip
|
|
|
|
minetest.get_voxel_manip(check_pos1, check_pos2)
|
2019-07-16 14:00:38 +02:00
|
|
|
|
|
|
|
if minetest.is_area_protected then
|
|
|
|
-- use area protection check
|
2019-07-20 15:37:56 +02:00
|
|
|
if minetest.is_area_protected(pos1, pos2, playername, 8) then
|
2019-07-16 14:00:38 +02:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
elseif has_protector_mod then
|
|
|
|
-- use improvised find_nodes check
|
2018-09-19 13:49:01 +02:00
|
|
|
local protectors = minetest.find_nodes_in_area(
|
2019-12-16 10:05:42 +01:00
|
|
|
check_pos1, check_pos2, {
|
|
|
|
"protector:protect",
|
|
|
|
"protector:protect2",
|
|
|
|
"priv_protector:protector",
|
|
|
|
"xp_redo:protector"
|
|
|
|
}
|
2018-09-19 13:49:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if protectors then
|
2018-09-19 17:10:57 +02:00
|
|
|
for _,pos in pairs(protectors) do
|
2018-09-19 13:49:01 +02:00
|
|
|
if minetest.is_protected(pos, playername) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if has_areas_mod then
|
|
|
|
if not areas:canInteractInArea(pos1, pos2, playername, true) then
|
|
|
|
-- player can't interact
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- no protection
|
|
|
|
return false
|
2018-09-19 17:10:57 +02:00
|
|
|
end
|