I want to make it so that when BOTH players hit each other, then the action below occurs, but, for some reason, when 1 player hits, then the action is performed for both of them (2 player did not even hit). How to make sure that when BOTH players hit each other then the action below occurs? I will be grateful.
Make a $last_player_hit variable for each player and save the name of the player which the player hits on EntityDamageEvent, then just check if both players have hit each other during the last 0,2 seconds or similar.
No one will be willing to spoonfeed you. He has already described how it's done. Do your own research on how you could write that in your own code.
Or if time is not important, you could get the damager's last damage cause and perform checks to see if the entity getting damaged now, was the entity who damaged him previously.
I just reread this again, and you're entirely right, the last damage cause damager is already saved so there's no need to create new variables
Can you please tell me in more detail what I need to do? The code is not needed, you can only throw off the principle of operation. Thank.