Man sentenced to 18 years for attempted murder