'Make it clear to him that you completely understand that he can’t make plans until last minute because of x y and z, but that that might mean you aren’t available
I fear that the relationship would end if I did that.'
This is where you (and I) go wrong. You can't put up with everything for fear of losing here. You've admitted here (I can be the same) that it's not always just about being 'nice,' it's that you're afraid to not give someone everything they want for fear of losing them.
This devalues you in their eyes, because they know you'll put up with anything, sometimes for fear of losing them.
You have to insist on something if someone's behaviour is making you unhappy (depending how unhappy it's making you.) If it's making you sufficiently unhappy, you don't actually have anything to lose by telling them you don't like it.
It is said, as you say, that if you say what you like and don't like, people respect you more for it. I had a disagreement with a friend recently, and he later said that my sticking up for myself made him respect me more.
Another friend- we were not getting anywhere communicating online about an issue we were having. Trying to say the right thing on messenger was really stressing me out, and my therapist etc were saying that text is just not the best method of communication for anything in depth or a disagreement, because you don't know people's intonation or expression so you don't know quite what they mean.
So I msged to her, ending ' It just feels like a minefield I have to navigate, and I think we'd make more progress in the flesh.' She has not got back to me, which is disappointing, but soon after I said it I was at peace. I no longer had to worry about what I was going to say via messenger etc to put things right. It was done and there was no more stress.
Forgive the long message lol- basically you need to no longer do everything you can so as not to lose the person. This is probably part of what makes people, you feel, treat you inconsiderately, rather than the fact that you're nice. If a situation is bad enough to really annoy you, you have nothing to lose by letting them know.