At around 9.45pm on January 12, 2019 Alfie Larkin fired ten bullets at a house and motorhome in Greenway Road, Rumney, Cardiff.
His friend Rachel Crowthers then hid the weapon in a block of concrete at the bottom of a rhubarb plant pot.
When the plant pot was put through an x-ray machine at the University Hospital of Wales, it revealed a loaded semi-automatic pistol with five bullets in the magazine.
The pistol was forensically removed from the cement and ballistic tests showed it was the same one used during the night-time shooting on January 12, 2019.
Larkin, 24, from London, was found guilty of possessing a firearm with the intention to cause fear of violence, following a trial at Cardiff Crown Court.
The court heart the shooting was a revenge for an incident in 2018 when he had been stabbed in the hand.
He has was sentenced on June 2 at Cardiff Crown Court to 13 years in prison – 5 years for drug offences, 8 years for the firearm offences - with a further four-year extended licence.
Crowthers, 22, from Caerphilly, pleaded guilty to possession of a firearm and perverting the course of justice.
She was sentenced on June 7 at Cardiff Crown Court to 20 months in custody, suspended for 18 months, and required to undertake 240 hours of unpaid work.
Crothers must also remain on curfew for a further four months and undertake a rehabilitation activity requirement for up to 20 days
Detective Chief Inspector Lloyd Williams, from South Wales Police, said: “The use of firearms in South Wales is extremely rare and when it does happen, as Alfie Larkin has found out, we are determined to go after those involved. “It was very fortunate that nobody was seriously injured or worse as a result of this incident. “Larkin is a manipulative individual who instead of continuing his university education is now beginning a lengthy prison sentence. “We will not tolerate the use of firearms in Cardiff or any part of South Wales. Cardiff is a safe city and we are working hard to keep it that way. “I would like to thank the staff at the University Hospital of Wales, Cardiff for their invaluable assistance and expertise in helping to locate and preserve the firearm in this case.”