The word "he" refers to the man Joshua saw.
"I am neither for you nor for your enemies"
This was an act of worship.