Is there a way to prevent the PlayerDeathEvent from being called so that the 'You Died' thingy doesn't come up and I can replace it with my custom code? Example: PHP: /*** @param EntityDamageEvent $damageEvent*/public function catchDamage(EntityDamageEvent $damageEvent){ $entity = $damageEvent->getEntity(); if ($entity instanceof Player && $damageEvent instanceof EntityDamageByEntityEvent) { $player = $entity; if (($player->getHealth() - $damageEvent->getFinalDamage()) < 1) { // BOIIII $this->kill($player); } }}/*** @param Player $player*/private function kill(Player $player){ $player->getInventory()->clearAll(); $player->setHealth($player->getMaxHealth()); $player->setFood($player->getMaxFood()); if ($player->hasEffects()) { $player->removeAllEffects(); } $player->addTitle("u died lol", "watanub kys", 20, 20 * 3, 20);}
PHP: public function catchDamage(EntityDamageEvent $damageEvent){ $entity = $damageEvent->getEntity(); if ($entity instanceof Player && $damageEvent instanceof EntityDamageByEntityEvent) { $player = $entity; if (($player->getHealth() - $damageEvent->getFinalDamage()) < 1) { // BOIIII $damageEvent->setCancelled(); $this->kill($player); } }}
I mean, my internet lags. The method is okay. This happened to me twice yesterday. Posting something when someone else already replied.