I try to make a pvp server that players are able to attack each other by using a crossbow loaded with firework rocket.The problem is if the player fires his crossbow too close to themself, they will be damaged by the rocket due to explosion damage.
I tried to solve this issue by adding the players into a team that I have created and turn off friendly fire. It works nicely but it also prevents the players from attacking their enemies since they are in the same team.
Besides, another idea is to give the player resistance 255 for 1 second after they have fired the crossbow so even if the rocket explodes near them they will not be hurt. This is by far the best solution I can come out with. However, if the player spams this, they will always be immune to all kind of damage. As a result of that, their enemies totally cannot defeat him.
So, I wonder is there another way to protect the players from being damaged by the firework rocket that is fired by themself BUT they will still be able to hurt their enemies with the same rocket.
*the version that I am using is java edition 1.16.3