It is actually quite simple if you believe in the nature's/God's/karmic Law of cause and effect, where you reap only what you saw. Meaning, if you don't do/say/think bad/violent/criminal things you will not reap them or be victim of such.
It has worked for many of us and I'm sure it will work for you.
Try self-mastering yourself by choosing not to steal (from work, government, other people's time, from hotel bathrooms...), not to lie, not to abuse others (either physically or verbally or mentally), not to do any of the things you very well know they are bad and hurtful. As a result you'll see how magically you will no longer be drawn to situations where you get hurt or treated badly.
It is much easier than you think, the hard part is to decide to do it.