
local old_is_protected = minetest.is_protected
function minetest.is_protected(pos, name)
   if not areas:canInteract(pos, name) then
      return true
   end
   return old_is_protected(pos, name)
end

minetest.register_on_protection_violation(function(pos, name)
   if not areas:canInteract(pos, name) then
      local player = minetest.get_player_by_name(name)
      if player then
         local yaw = player:get_look_horizontal() + math.pi
            if yaw > 2 * math.pi then
               yaw = yaw - 2 * math.pi
            end
         player:set_look_horizontal(yaw)
         player:set_look_vertical(-player:get_look_vertical())
         local owners = areas:getNodeOwners(pos)
         minetest.chat_send_player(name,("%s is protected by %s."):format(
         minetest.pos_to_string(pos), table.concat(owners, ", ")))
      end
   end
end)
