Melvin Gambanga tried to get rid of his stash as police broke down the door of his Gravesend flat, but officers found the plastic bag of drugs in the toilet.
Police also discovered a loaded pistol and ammunition hidden in a holdall with more bullets in a suit in the wardrobe, while heroin and crack cocaine - which had been assembled into ready-to-sell wraps - were discovered in his bedroom.
The 23-year-old unemployed warehouse worker was jailed for a total of eight years.
At Maidstone Crown Court on Wednesday, Gambanga admitted possessing class A drugs with intent, possessing a prohibited firearm and ammunition and having £1,000 ($1,256) in cash - the proceeds of drug deals.
Mark Gadsden, prosecuting, said: "He was responsible for a significant amount of drugs being brought into Gravesend and other parts of the south east."
Mr Gadsden added that the self-loading 9mm pistol that was found in the flat contained four rounds with four more found in his suit, which was hanging in a wardrobe.
The dealer - who has a previous drugs conviction from 2016 - had been peddling drugs in the Kent town from October 2019 until his arrest in May this year.
Max Reeves, defending, said Gambanga claimed the weapon had been given to him by someone 'further up the chain of command' and he had never inspected or fired it.
Jailing Gambanga for five years on the weapon charges and another three years for the drugs offence, Judge Stephen Thomas told him: "You were heavily involved in the marketing of class A drugs."
Detective Constable Mark Donovan of Kent Police said Gambanga - who lived in Abbey Wood, south east London - was 'a threat to public safety'.
He said: "Gambanga has demonstrated he is an individual who presents a clear threat to public safety.
"Not only does he see people suffering from drug abuse as a means to make money, his willingness to possess a loaded gun demonstrates he was willing to commit acts of serious violence.
"Despite being based outside of Kent, he was not able to escape capture after our enquiries revealed he had been actively involved in coordinating the supply of drugs to Gravesend.
"Each day we are gathering new information on the supply of class A drugs in our town and, as this case shows, we will not hesitate to come after drug dealers at their own homes to ensure they are brought to justice."Featured Image Credit: SWNS