So I'm not really sure what to do about this one. I have a boss that counts the damage of each player on EntityDamageByEntityEvent and adds it up in an array like this (method inside my boss entity): PHP: /** * @param Player $player * @param int $damage */ public function setDamage(Player $player, int $damage){ if(!isset($this->damagers[spl_object_hash($player)])){ if(($this->getHealth() - $damage) <= 0){ $this->damagers[spl_object_hash($player)] = [$player, $this->getHealth()]; }else{ $this->damagers[spl_object_hash($player)] = [$player, $damage]; } }else{ if(($this->getHealth() - $damage) <= 0){ $this->damagers[spl_object_hash($player)][1] += $this->getHealth(); }else{ $this->damagers[spl_object_hash($player)][1] += $damage; } } } And this is how I set the damage: PHP: /** * @param EntityDamageByEntityEvent $event */ public function entityDamage(EntityDamageByEntityEvent $event){ $entity = $event->getEntity(); $killer = $event->getDamager(); if($entity instanceof BossEntity && $killer instanceof Player){ $entity->setDamage($killer, $event->getFinalDamage()); } } Yeah I know why so many ifs, but I figured this is the only way to fix the issue but even then I still run into it. You can see in the screenshot I dealt 274% damage when the max should be 100%. I can't work my head around this, any suggested solutions?
Damage and health aren't always equal. There are effects, armor protection etc which can decrease the damage taken. Another thing to note is that the damage can very well be more than the health of the victim. The event could be cancelled by other plugins as well (set the priority to MONITOR). One way to deal with this would be overriding attack method of the BossEntity. PHP: $health = $this->getHealth();parent::attack($source);if(!$source->isCancelled()){ $healthLost = $health - $this->getHealth(); // $event->getDamager()...}