MEDIA, Pa. (AP)  A Taiwanese exchange student accused of threatening a shooting at his high school near Philadelphia was sentenced to four to 23 months in prison but a judge ordered immediate parole to federal authorities for deportation.

The Delaware County Daily Times reported An-Tso Sun, 18, entered an open plea on Monday in Delaware County Court to terroristic threats.

School authorities were alerted in March that he talked about a May 1 shooting at Monsignor Bonner and Archbishop Prendergast High School, warning a friend not to come to school that day.

Sun called it a joke, but prosecutors said he had several parts of a 9mm handgun that a detective was able to assemble and fire along with two loaded 9mm magazines, a crossbow and a ballistic vest from his host family. Prosecutors also said he had researched how to buy weapons.

“Even a person in the defendant’s position, having been in the country since September, had to know that you cannot joke about school shootings,” Deputy District Attorney Daniel McDevitt said.

Sun apologized on Monday, saying he had brought shame on his family and supporters. Defense attorney Robert Keller said his client planned to enter Temple University and had hopes of joining law enforcement.

“During my time in prison, there was not one day where I was not regret what I did,” Sun said. “Now I cannot even graduate with my friends or go to the college I always wanted to, because of my own mistakes. I’m just really sorry. I’ll make sure this never happens again.”

Judge Barry Dozor said Sun had “the means and the tools” to act on his threats and “this was more than just mere words.” He urged the defendant to make amends by living a good life.

“You will return to a remarkable nation with a great deal of opportunity and promise,” the judge told Sun. “Make a contribution in the lives of others.”