To check if a player has received damage, you need to use an event. These events are named differently in different versions of the game. To understand which creature attacked the player, you need to use "instanceof" operator. For example:
if(e.getLivingEntity() instanceof EnityMod) { //some code }
The above code is just an example of using an operator in an event. You will have to find the event you need yourself and get the entity that attacked the player