PHP: public function onDamageDeath(EntityDamgeEvent $event){ if(($player = $event->getEntity()) instanceof Player && $event->getFinalDamage() - $player->getHealth() <= 0){ $player->teleport($this->getServer()->getDefaultLevel()->getSpawnLocation()); }}
oh and dont forget to remove items and experience EDIT: PHP: public function onDamageDeath(EntityDamgeEvent $event){ if(($player = $event->getEntity()) instanceof Player && $event->getFinalDamage() - $player->getHealth() <= 0){ $player->teleport($this->getServer()->getDefaultLevel()->getSpawnLocation()); $player->getInventory()->setContents([]); // i belive there is no exp system with api in pocketmine }}
My bad, my idea won't work, as PlayerQuitEvent isn't cancellable (neither is EntityDeathEvent). It's still quite a bad idea to make the EntityDeathEvent never appear, but it actually seems like that's the only way. (?) This'll be annoying for other plugins that use EntityDeathEvent though.