David Crooks admitted throwing stones at police during orchestrated disorder in the Newtownabbey area, Belfast Magistrates' Court heard on Monday.
The 19-year-old claimed he had only gone along to watch, but got caught up in the trouble on 8 December. Crooks, of Rosslea Way, Newtownabbey, faced a single charge of riotous behaviour.
The court heard how police deployed water canon in an attempt to quell a large crowd firing rocks and other projectiles at them.
Violence flared in the Rathcoole area just days after the decision to restrict the flying of the Union flag at Belfast City Hall sparked street protests in some areas.
His solicitor argued that he had not intended to become involved.
She told the court: "He instructs me that he was in bed, he was on Facebook and saw things were happening.
"Initially he was going to spectate but got caught up in it. He accepts that was one of the most foolish things he's ever done."
District Judge Fiona Bagnall accepted Crooks has a clear record and pleaded guilty early on, but she ruled that the seriousness of the offence warranted an immediate jail sentence.
"It was a fairly extensive incident as I understand it, and largely orchestrated," the judge pointed out.
"Rocks and dangerous projectiles were thrown, causing major disruption and risk to the public.
"It's a matter with a significant crowd rioting, and it was a lengthy incident.
"I will therefore impose three months custody."