I just slapped my nephew's leg because he threw a toy at me
How did it make you feel to slap your nephew?
I didn't like to hit him but I'm too protective of my toys.
You shouldn't hit children or family members. Maybe you can reprimand him verbally if he's engaging in behavior that you don't like. It's safer for him and probably more effective.
He's a boy but I know that I cant can't hit him like in the old days.
I would not make a habit of hitting him.  Apologize for your mistake and work on a non violent way to keep him from getting into trouble in the future