Shea Britton, 20, of Atkinson Close, Preston, admitted possessing cocaine and heroin with intent to supply them during a hearing at Preston Crown Court.
Martin Callery, prosecuting, said on February 14 last year police officers witnessed what appeared to be a street drug deal and detained the man responsible.
He added: " During the course of that arrest that male attempted to alert the defendant and one other in a flat nearby and it led the police to that flat.
Video shows man in van wielding weapon in Preston city centre fight
Dramatic reduction in speed limit on major route into Preston through South Ribble
Lancashire Police investigate after man found critically injured outside Preston’s Harris Museum
Ribbleton man Karl Bruney arrested by Lancashire Police after firearms incident in Preston
Real Housewives of Cheshire: former star of hit TV show set to visit Chorley boutique
"When they searched the flat they found cocaine and diamorphine.
They found a number of class A and B controlled drugs and paraphernalia normally associated with the preparation and supply of drugs.
"Present were Shea Britton and another man called Charlie Blakey, both of whom were arrested.
"The flat is not the home address of either two men. Found at the flat was drugs packaging."
Defending, Beverley Hackett said he had never been in trouble before, had indicated he would plead guilty at an early stage and had demonstrated he can be "industrious".
She added: " He has nothing in his history to aggravate his position. He seeks not to blame others but clearly in that period fell into acquaintances that weren't good for him."
The court heard the offences happened after his aspiration to be a sportsman failed.
Recorder Paul Atherton said "It's agreed by the prosecution and defence that you played a significant role. Drug dealing was clearly going on from this flat.
"You were responsible for putting onto the street, to any sort of purchasers - sophisticated, students, unsophisticated, vulnerable people, people who would be committing criminal offences to pay for these drugs, people who would be involving themselves in violence to pay for these drugs - you didn't care so long as you got the money in.
"That's how serious it is."
"This is a depressing exercise for the court to undertake, we want to keep people out of prison if we can. But perhaps it's what you need to develop your maturity and move forward."
The Lancashire Post is more reliant than ever on you taking out a digital subscription to support our journalism. For unlimited access to Lancashire news and information online, you can subscribe here.