After undergoing an apparent attitude adjustment, a former mixed-martial arts championship fighter who pleaded guilty to assault charges was placed on three years’ probation Tuesday and ordered to continue serving a year in county jail.

Jon Koppenhaver, who legally changed his name to War Machine, was sentenced in accordance with a plea agreement reached in his case, which stems from two bar fights earlier this year. While on probation, he is not allowed to possess or consume any alcohol and he will have to undergo counseling if directed to do so by the Probation Department.

If he violates probation, he could be sent to prison for up to four years.

War Machine had agreed to this deal before his last hearing on Aug. 12, but the agreement appeared to be in jeopardy after a tense exchange with the sentencing judge.

At that hearing, San Diego Superior Court Judge David Danielsen said War Machine’s behavior inside and outside the courtroom warranted prison, not probation. The judge made reference to statements War Machine had made to a probation officer and his somewhat flippant attitude in the courtroom.

Deputy District Attorney Michael Runyon filed a document in court that day that contained several expletive-laden tweets War Machine had posted on his Twitter page before he was booked into jail last month.

On Tuesday, Danielsen said he had received a three-page letter from War Machine, the tone of which he described as just short of “contrite.” The question now, the judge said, is whether the defendant was capable of learning from his actions.

“I made some stupid mistakes in my life a few times,” War Machine said in court, noting that he tends to get into trouble when he goes to bars. “I’m not a bad person.”

He said he recently married and has plans to open a gym with two business partners. “I just want to do my time, pay my debt and get on with my life,” he said.

Danielsen said he’s willing to give War Machine “one shot” at probation. He said time will show whether the defendant’s true attitude was demonstrated at his last court appearance or at the Tuesday hearing when he was “saying all the right things.”

“I think we’ll find out who the real guy is,” the judge said.

War Machine pleaded guilty last month to two counts of assault with force likely to cause great bodily injury, stemming from altercations at a bar in Point Loma in February and a Pacific Beach bar in March. He also admitted he violated probation on a previous misdemeanor case.

Under the terms of the plea deal, he will have to serve the entire year in jail. He is not eligible for so-called “good-time credits” that would allow an early release.