A judge has issued a restraining order against a 20-year-old man, requiring him to turn his guns into police within 48 hours.