public function onDamage(EntityDamageEvent $event) { $damaged = $event->getEntity(); if (!$damaged instanceof Player or !($session = $this->getMain()->getSessions()->getSession($damaged)) instanceof Session or !$session->inSession($this)) { return; } if ($event instanceof EntityDamageByChildEntityEvent) { $entity = $event->getDamager(); if ($entity instanceof Player) { $ses = $this->main->getSessions()->getSession($entity); if ($ses instanceof Session and $ses->inSession($this)) { $data = $this->getPlayerData($ses); if ($data->isPlaying() and $data->getArena()->isPlaying()) { $projectile = $event->getChild(); if ($projectile instanceof Snowball) { $event->setCancelled(false); $event->setKnockBack($event->getKnockBack() * 2); } } } } } }
/** * @param Player|string $player * @return Session|null */ protected function getSession($player) { $ses = $this->main->getSessions()->getSession($player); return $ses instanceof Session ? $ses : null; }