David Medlam, aged 37, of no fixed abode, was sentenced after he appeared at Sheffield Crown Court on Thursday accused of possession of a firearm with intent to cause fear or violence.
The charges relate to incidents earlier this year on Yews Lane and Pontefract Road in Barnsley.
On Saturday, February 15 at 1pm, South Yorkshire Police received reports that a man had been threatened by Medlam with a gun.
The 35-year-old victim was outside with his son, in a garden on Yews Lane, when a car pulled up.
Medlam got out of the car and threatened the victim with the firearm.
As he left, it is believed he fired the gun.
Shortly afterwards at around 1.40pm, officers reports of possible drug dealing on Pontefract Road.
Officers attended and found Medlam at the scene.
Detective Emma Shipley, who led the investigation said: “Using a firearm to cause fear will not be tolerated in our communities.
“We want to ensure our communities are safe by taking as many firearms off the streets as possible and bringing those who think this type of behaviour is acceptable before the courts.”
No explanation has been provided by South Yorkshire Police as to the possible background to the firearm incident.
To report those who carry or have access guns in South Yorkshire call 101 or Crimestoppers, anonymously, on 0800 555111.