public class EntityListen implements Listener {
@EventHandler(ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
CreatureTask.onDamage(event.getEntity(), event);
HumanNPC npc = NPCManager.get(event.getEntity());
if (npc != null) {
npc.callDamageEvent(event);
}
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if (npc != null) {
if (e.getDamager() instanceof Player) {
Player player = (Player) e.getDamager();
npc.callLeftClick(player, npc);
}
} else if (e.getDamager() instanceof Player) {
CreatureTask.onDamage(e.getEntity(), event);
}
}