A former high school star athlete shot by gun that accidentally discharged in his book bag during class pleaded guilty on Tuesday to weapons charges.

Damien Julius Singleton was struck in the leg after the small-caliber pistol accidentally fired at Myrtle Beach High in March. The senior was hospitalized for more than a week with a shattered leg, his attorney Tommy Brittain said.

Singleton brought the gun to school for protection against a man who threatened to kill him, his attorney said.

"We all know bringing a gun on school property is a stupid mistake," Brittain said. "He didn't plan any mischief, but it was very wrong."

Singleton, 18, pleaded guilty to carrying a weapon on school property and to possession of a firearm by a minor. He was sentenced to probation and 500 hours of community service. He had faced up to 10 years in prison.

He also is not allowed within 500 yards of the school where he once shined in both basketball and football.

Singleton was immediately expelled from school after the shooting. He now works for a lumber company and hopes to enroll in a high school to make up his senior year.