A teenage boy from Cannock has been jailed for over three years after police found a handgun in Stoke on Trent.