Robert F. Kennedy Jr. hopefully won't have to worry about a guy he claims tried to break into his house -- 'cause the guy agreed to stay away, and the judge just signed off on an order to make it official.
Lawyers for the presidential candidate worked out a stipulation with lawyers for Jonathan Macht, requiring him to steer clear of RFK Jr., as well as his family, home, workplace, and vehicle. Earlier this month, RFK ran to court to get a TRO after Macht was arrested at the guy's house in October for trespassing.
You'll recall ... Macht was hauled away by cops twice in a short window -- this after Kennedy claimed he'd climbed the fence to his Brentwood property in an attempt to talk to RFK, although he never actually made it into the house.
Now court records show the judge signed off on extending the restraining order for the next 5 years.
The terms require Macht to stay at least 100 yards away from Kennedy and his family members -- not to mention his home, his workplace, etc. Macht also cannot contact RFK Jr. ... nor can he harass, intimidate, threaten or otherwise bother him.
Per the terms of the order, Macht can't own, possess or attempt to purchase firearms or ammo during this period.
Remember, this whole saga left Kennedy and his wife, Cheryl Hines, pretty rattled. She talked to us about it ... and said it's just evidence why they've needed Secret Service protection throughout the campaign -- which they've been denied up until this point.