What should I do if I can't stop thinking about someone who hates me.
Do you know this person well?
I used to be really good friends with him before he decided that he hated me.
I'm sorry your friend has decided he doesn't like you. It's sad when that happens, but it's not good for your mental health to spend so much time thinking about it. Instead you can focus on making new friends.
I know but I can't help but think of him.
It's understandable that you are still thinking about your friend, likely trying to piece together what happened. It's okay to be sad about it but you should grieve the loss of the friendship and begin healing. That way you can let it go and move forward.