How do I stop dreaming about him?

Everyday for the last week I keep on having dreams about my ex. We broke up 7 months ago but we still had feelings for each other so we were on and off for a while. About 3 weeks ago he texted me saying he had been thinking about me but that didn’t go so great because I made it seem like I wasn’t interested even though I still have feelings for him. I feel like I just pushed him away completely and ruined the chance of us ever getting back together. So maybe I’ve been having dreams about him because of that? I don’t know what to do. Should I contact him? Please help.