A life that once glittered had turned dark and murky. Jayson Williams, the former NBA All-Star, had served time in prison for the accidental shooting death of his driver. He had one legal mess after another. And now he was sequestered at a cabin in the Catskills, drinking himself into oblivion.

Then two people who cared arrived at that cabin. One was former Jets great and NFL Hall of Famer Curtis Martin, who brought kindly spiritual advice and hope. The other was ex-Knicks great Charles Oakley, who brought a baseball bat.

“Curtis showed up with, ‘What would Jesus do?’ and Charles showed up with an aluminum baseball bat,” Williams told The Post in a hour-long phone interview. “I asked Oak, ‘What were you going to do with that bat?’ He said, ‘I was going to do whatever I had to do to get you in that truck to get you down to Florida to go to treatment.’ ”

The date of that life-changing encounter was Dec. 26, 2015. On Dec. 27, 2015, Williams, who had ballooned to 316 pounds, checked into rehab in Lake Worth, Fla., and he says now he has been sober for three years and seven months.

These days, the 51-year-old Williams — who made an estimated $63 million in his nine NBA seasons, according to Basketball Reference — works at his Rebound treatment program at Futures recovery center in Jupiter, Fla., enduring a schedule seemingly designed for someone who lost a big bet.

Or, in this case, for a man still desperate to escape the nightmare realities of his life.

“I’m robotic. I try to do the exact same thing every day. I caused a lot of pain — to my family, to Mr. Christofi’s family, to people that love me,” said Williams, an All-Star in 1998, 21 years — or, another lifetime — ago. “And I can’t shake it. I cannot shake it. So I just work it all day long trying to help others.”

In 2002, Williams accidentally shot and killed Costas “Gus” Christofi, a 55-year-old limo driver, and then tried to cover up the incident. In 2010, after a protracted set of criminal proceedings on a charge of manslaughter, he pleaded guilty to aggravated assault. He was sentenced to five years in prison and served 15 months (he served an additional 12 months on a drunk-driving rap). The worst prison resided in his mind. So he endures a robust, rigorous schedule now.

“I don’t know if it helps me deal with it,” Williams said, “but it helps me not to remember it.”

Williams tries to cram 15 hours of recovery work — mainly for others, but for himself, too — into every day. His quest to be a better person is virtually all-consuming.

It’s rise and yawn daily at 3:30 a.m., drive to the gym for a workout that starts at 4:04 (not 4:00 or 4:05). The workout, alongside Futures CEO Sean Nasiff, continues until 6 a.m. Then comes the one-hour drive to the facility.

Along the way, Williams checks in with past “teammates” (they are not called patients or clients) on his cellphone. Several months ago, Rebound merged with the expansive Futures Recovery Healthcare System — which, among other things, means more people seeking help. The facility, which is accredited by the state through Futures, provides help for substance abuse and mental health issues.

“I’ve always enjoyed giving back,” said Nasiff, 30, a former MMA fighter who comes from a family afflicted by alcohol and drug abuse. “Giving someone the tools to feel better about themselves … and also learning together how to be better as people. It’s not just drug abuse or mental health. It’s being a better person.”

Use time productively, Williams tells himself. Help others and be remembered for something other than the shooting and the cover-up. Williams tries to guide others around the mistakes that altered his life.

“To most of the people that come, I’m a warning or an example,” Williams said.

He definitely is both.

His “teammates” get a chance to know him daily. There’s breakfast with a goal-setting session, plus a daily check-in for past members through a video-messaging app.

“At 7, I teach a goal-setting class [and] pretty much see how everybody slept, how you’re doing, how you’re feeling,” Williams said. “I’m the guy looking at everyone’s eyes — seeing who’s hurting, who’s humble, who has gratitude. If I see you with sunglasses on and it’s raining, ‘Oh, there’s a problem there.’ ”

At 9, there is “adventure therapy.” The “teammates” engage in 19 different activities, from scuba diving to snorkeling to skydiving, designed to promote confidence, self-esteem and to help them overcome anxieties.

“I hadn’t heard much about it outside a traditional place like in Utah where they do wilderness therapy,” said Cody Smith, LMHC (Licensed Mental Health Counselor), who has 15 years of experience in the field and is the clinician director at the facility, overseeing therapeutic services. “As I got to see it and experience it, it really took off in my mind. I truly believe it’s the most critical component of what we do.

“Skydiving, we’re talking about overcoming fears. Once you can overcome that one, you can usually face about anything.”

Williams and Nasiff don’t just talk the talk and walk the walk, they jump the jump out of planes.

“It’s to build trust between us and the teammate because Jay and I do it with them,” Nasiff said. “It shocks the system. We had a guy suffering from agoraphobia. He was a wreck. He didn’t leave his couch for two years. … But then it was, ‘I jumped out of a plane.’ It’s a good way to remind yourself, if you can jump out of a plane, you can do most anything.”

Even get sober.

Williams starred at St. John’s before his NBA career, which comprised two seasons with the 76ers and seven seasons with the Nets. His career ended after he suffered a grotesque knee and leg injury in an on-court collision April 1, 1999.

He became a well-received NBA studio commentator for NBC, but that job evaporated after Christofi’s death. He paid the driver’s family $3.5 million to settle a civil suit, and as the criminal case worked its way through the legal system, Williams got into more trouble: bar fights, a hotel standoff with NYPD, DWI charges. His life was a mess.

“The incident, though it was a tragedy, forced Jayson to become more vulnerable and more transparent,” Martin said. “There’s one thing I always tell him: Life has a way of trying to deal with you privately, but if you don’t listen, life with deal with you publicly.”

Williams spent 27 months in prison in all. He says he stayed sober during that time, but upon his release from Rikers Island in April 2012, he was ill-equipped for life.

“I got out of jail and went, ‘[Bleep], I can’t get a job,’ ” said Williams, who admitted he held the unrealistic expectation that NBC would call, wanting him back.

He got a bottle. Actually, lots of bottles. That brought more problems in the legal system — a drunk-driving episode in upstate New York — and in Williams’ mind. He crawled into the Catskills cabin, apparently intent on destroying his liver.

St. John’s legend and Hall of Famer Chris Mullin, a recovering alcoholic, reached out to help. Then came the game-changers who continue to play huge roles in Williams’ recovery. Martin first met Williams at Bible study in 2002.

“Most people may never get to know the heart Jayson has … because most people know him as the NBA player who had that incident,” Martin said. “Those who have the opportunity to and are interested, I would like for them to get to know Jayson because he’s pretty dynamic.”

Oakley said he and Williams chat almost daily, and Oakley has cooked dinners at the Florida recovery center.

“When he was out, he did everything for everybody. Then some people closed the door in his face almost. But he’s still grinding, staying clean, and that’s the most important thing,” Oakley said. “Jayson’s got a big heart, so he’s going to be out to prove people wrong. He’d give you the shirt off his back and I’ve seen that – shirt, shoes.

“Yes, he made mistakes. A lot of people have. And a lot of people get second and third chances.”

During Williams’ own rehab, he saw areas for improvement and developed ideas for what would become his Rebound program. Daily 10-hour sessions too often devolved into boasts about former bouts of drinking or drug use. Williams said he asked to use an old volleyball net and basketball hoop, and soon physical activities entered the program. After his stay, he volunteered at a recovery center, Epiphany, in Delray Beach, Fla., where he put those ideas into practice.

At Rebound, after adventure therapy and lunch, clinicians take over. The doctors, techs, therapists, clinicians, nurses, plus “teammates” past and present, are Williams’ family now. He is estranged from his two daughters, ages 16 and 15, who live with their mother in New Jersey.

“When my kids tell me you have not put enough time in to be my dad, I understand I haven’t been in their lives,” Williams said. “I have not learned with my own family to make it work. Does that eat me up inside? Yes.

“I love helping people get better. … But I have not done a good job as a father. I’m a great brother. I’m a great friend. But I’m not a good father.”

Rather than dwell on the harsh realities, he dives deeper into his calling. Structure is key. The “teammates” go through clinical sessions, discussion groups, Bible study offerings, AA meetings. Williams takes part, does another gym session then goes to bed around 8:30. Keeping busy is of the utmost importance.

“We’re giving people the ability to find new skills, new activities they enjoy before they go home,” said Smith, the clinical director. “One of the biggest things … that causes people to relapse is boredom. They’re like, ‘I was bored. What the heck? I can get away with it this time.’ By doing these different activities, they are able to go home and find some sort of outlet.”

Williams frequently references his late father, E.J., and some of the folksy logic and advice (“If you wake up and think you know it all, you’ve got a problem”) he imparted. Helping others is often helping himself.

“I haven’t [fully] learned to forgive myself,” Williams said. “And that’s hypocritical. I’m learning, but it’s like molasses in the wintertime.”

Williams calls Martin “the most instrumental person in my life.” Williams said Martin provides solace through weekly Bible study groups, appearing through video conferencing as well as making periodic visits to Florida.

“His own sobriety is something,” Martin said. “Just for him to get there is a huge accomplishment, because I grew up in a family with a father who was severely addicted to alcohol and drugs, and I know how difficult that can be.

“There are people’s lives literally being saved, and I’ve spoken to some of them. The change and the growth I’ve seen in so many people has been amazing, and I don’t know where some people would be had they not been involved with Jayson. I have seen a part of Jayson that he would love for the world to get to know. … One thing I have learned is that people can change, and I would definitely say that Jayson has made a tremendous change.

“He’s had all the money in the world and everything: cash, fame, money, power. I think he’s realized that wasn’t the key to life. That wasn’t what made him feel fulfilled in life. And I think now what he’s doing, I don’t think he would trade for anything.”