Sometimes I don't think my boyfriend is a very good boyfriend.
Why do you think that way about him?
He takes advantage of me all the time
If your boyfriend is taking advantage of you, you should break up with him. There is no reason to put up with that at all.
But sometimes he acts really nice. I don't  know what to do.
It sounds like you believe that he is a bad person, which means that you should reconsider being in a relationship with him. You're going to continue feeling hurt if you don't leave him or at least talk about it.