FLATBUSH, Brooklyn — A 22-year-old man was sentenced to 25 years in prison on Monday, years after he killed a dad at a Brooklyn elementary school.

Adonis Barnett was 16 when he shot Gerald Cummings, 38, in the back and in the back of the head, District Attorney Eric Gonzalez said. Before the shooting, Cummings had confronted the teen.

Barnett and another teen had stolen a hat belonging to Cummings’ son. The distinctive, leather and snakeskin Oakland Raiders cap was valued at several hundred dollars.

“This was a senseless, cold-blooded shooting of a family man walking away after retrieving his son’s stolen cap,” Gonzalez said. “Now he has lost his life, and his family lost their loved one. With today’s sentence, the defendant will spend many years behind bars as a consequence of his actions.”

Barnett was convicted of first-degree manslaughter last April. He was also convicted of second-degree criminal possession of a weapon at an earlier trial and is awaiting sentencing on that charge.