Benedikt05 / BetterAltay

A server software for Minecraft: Bedrock Edition in PHP
GNU Lesser General Public License v3.0
81 stars 41 forks source link

Events #266

Closed AfterKing closed 6 months ago

AfterKing commented 6 months ago

Issue description

Steps to reproduce the issue

  1. ...
  2. ...

OS and versions

Plugins

<------ 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()));
            }
        }
    }
}

---->

Crashdump, backtrace or other files

When I hit the slapper he takes damage