Closed AfterKing closed 6 months ago
public function onEntityDamage(EntityDamageEvent $event): void { $entity = $event->getEntity(); if (!($entity instanceof Player)) { return; } if ($entity instanceof SlapperEntity || $entity instanceof SlapperHuman) { $event->setCancelled(true); if (!$event instanceof EntityDamageByEntityEvent) { return; } $damager = $event->getDamager(); if (!$damager instanceof Player) { return; } $this->getServer()->getPluginManager()->callEvent($event = new SlapperHitEvent($entity, $damager)); if ($event->isCancelled()) { return; } $damagerName = $damager->getName(); if (isset($this->hitSessions[$damagerName])) { if ($entity instanceof SlapperHuman) { $entity->getInventory()->clearAll(); } $entity->close(); unset($this->hitSessions[$damagerName]); $damager->sendMessage($this->prefix . "Entity removed."); return; } if (isset($this->idSessions[$damagerName])) { $damager->sendMessage($this->prefix . "Entity ID: " . $entity->getId()); unset($this->idSessions[$damagerName]); return; } if (($commands = $entity->namedtag->getCompoundTag("Commands")) !== null) { $server = $this->getServer(); /** @var StringTag $stringTag */ foreach ($commands as $stringTag) { $server->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", '"' . $damagerName . '"', $stringTag->getValue())); } } }
I also experienced issues with this. I think it is an issue with $event->isCancelled();
isCancelled and the other event
is my plugin, sorry!
Issue description
Steps to reproduce the issue
OS and versions
Plugins
Crashdump, backtrace or other files