I find ageing has REALLY helped with this. I don't care so much what people think or if I fit in, I'm me and I'm ok with that. I also find nice people always like me cos I'm also nice, so people that dislike me or mistreat me often just aren't nice people at all.
I'm waaaayyy better at spotting bullies and good people nowadays. I stay away from the bad, don't tell them anything and join the good for safety. That really helps.
I've got better techniques for dealing with things, for example "can you explain that joke?" when someone is being nasty.
It's not easy but I'm better at dealing with it!