A third man was arrested after driving away from the scene and remains under investigation.
Swansea Crown Court heard police officers were called to Mountain Dew public house in Mount Pleasant on May 6 after reports of suspicious activity. They found 190 plants in various forms, alongside numerous items of growing equipment.
Both men admitted producing cannabis, with Kryemadhi having no previous convictions.
Giving the defendants a one-third discount for their guilty pleas, Judge Paul Thomas QC sentenced Kryemadh to 12 months in prison and Matrapaei to two years. Each man will serve up to half of those sentences in custody before being released on licence.
The judge said what would happen to the defendants upon their release was a matter for the immigration authorities.