CHARLOTTESVILLE, Va. (WVIR) - A judge is sentencing a Charlottesville man to 20 years behind bars stemming from a shooting involving police.

Twenty-seven-year-old Joshua Lamar Carter entered a plea deal in Charlottesville Circuit Court Monday, March 12.

Carter had been charged with attempted capital murder of a law enforcement officer, malicious shooting into an occupied building, use of a firearm in a felony, injury as a result of shooting in a public place, and possession of a firearm by a nonviolent felon.

As a result of Monday’s plea deal, Carter was sentenced on the reduced charge of attempted second-degree murder, shooting in a public place, and possession of a firearm by a nonviolent felon.

Investigators say Carter fired a gun at a woman, grazing her legs, in the 500 block of 11th Street NW back in November 2016.

According to authorities, Carter was still holding a handgun when he encountered two police officers. Shots were exchanged, and Carter was hit by a gunshot. He was transported to the hospital, and recovered from the injury. Neither of the officers were injured.