Matt Barnes has just been granted sole legal and physical custody of his sons.

The win comes just weeks after his ex-wife, Gloria Govan was arrested for alleged child endangerment which led to Barnes filing a restraining order against the reality television star, which was also granted by the courts.

According to TMZ, "the judge ruled Gloria will get regular visitation -- including every other weekend from Friday until Monday morning. She is also allowed to have dinner with the kids every Wednesday evening. 

Barnes and Govan were officially divorced back in 2016. For a brief moment, it seemed that the split could have been amicable, with both parties agreeing on child and spousal support.

Barnes shelled out paid $5,000 per son per month in child support in 2016 which was doubled until their 10-year-old twin sons reached the age of 18. Barnes also paid Govan $20k per month in spousal support from Jan. 2016 to Dec. 2016 but she would receive no further child support.

As well as the custody ruling and restraining order, Govan has also been ordered to take anger management classes and 10 parenting classes. Govan has not exactly been behaving like the mother of the year, but the judgment is a crippling blow.

Barnes hopped onto Instagram to show off his stellar legal team.