How to fix? Code: [09:46:55] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\event\entity\EntityDamageByEntityEvent::getDamage()" (EXCEPTION) in "plugins/TheBridge v1.2.0.phar/src/bridge/utils/arena/Arena" at line 232 CODE: PHP: public function onDamage(EntityDamageEvent $e){ $ent = $e->getEntity(); if($ent instanceof Player){ $name = strtolower($ent->getName()); $arena = $this->getPlugin()->getPlayerArena($ent); if(is_null($arena)){ return true; } if($arena->stat < 3 or $arena->stat > 3){ $e->setCancelled(); if($e->getCause() == 11){ if($arena->stat > 3){ $ent->getInventory()->clearAll(); $arena->respawnPlayer($ent, false); return true; } $level = $ent->getLevel(); $ent->teleport($level->getSafeSpawn()); return true; } } if($e->getCause() == 4){ $e->setCancelled(); return true; } if($e->getCause() == 10 or $e->getCause() == 9){ $e->setCancelled(); return true; } if($e->getCause() == 11){ $e->setCancelled(); $ent->getInventory()->clearAll(); $arena->respawnPlayer($ent); return true; } $cause = $ent->getLastDamageCause(); $damage = $e->getFinalDamage(); if($e instanceof EntityDamageByEntityEvent){ $p = $e->getDamager(); if($p instanceof Player){ if($arena->isTeamMode() && $arena->isTeam($p, $ent)){ $e->setCancelled(); return true; } } } if(($ent->getHealth() - round($damage)) <= 1){ $e->setCancelled(); $ent->getInventory()->clearAll(); $arena->respawnPlayer($ent); if($e instanceof EntityDamageByEntityEvent){ $p = $e->getDamager(); if($p instanceof Player){ $arena->broadcast("§c§l» §r§7 " . $p->getNameTag() . " §7killed " . $ent->getNameTag(), 3); if($arena->hasHab($p, "matador")){ $eff = Effect::getEffect(5); $eff->setDuration(20*20); $eff->setAmplifier(3); $p->addEffect($eff); } return true; } } $arena->broadcast("§c§l» §r§7 " . $ent->getNameTag() . " §7died alone", 3); return true; } switch($e->getCause()){ case 1: case 2: case 4: case 11: if($cause instanceof EntityDamageByEntityEvent){ $ev = new EntityDamageByEntityEvent($cause->getDamager(), $ent, 1, $e->getDamage()); //line 232 $ent->setLastDamageCause($ev); } break; } } }
Now it shows me this Code: [12:26:55] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\event\entity\EntityDamageByEntityEvent::__construct() must be an instance of pocketmine\entity\Entity, null given, called in phar:///home/minecraft/plugins/TheBridge v1.3.0.phar/src/bridge/utils/arena/Arena.php on line 232" (EXCEPTION) in "src/pocketmine/event/entity/EntityDamageByEntityEvent" at line 47
PHP: switch($e->getCause()){ case 1: case 2: case 4: case 11: if($cause instanceof EntityDamageByEntityEvent){ $ev = new EntityDamageByEntityEvent($cause->getDamager(), $ent, 1, $e->getBaseDamage()); $ent->setLastDamageCause($ev); } return true; break; } } }
You need to solve it by having a null check for $cause->getDamager(). It can return null in cases where a player shoots a bow, quits the server, and the arrow then hits an entity. EntityDamageEventg::getEntity() on the other hand will most likely never return null. https://github.com/pmmp/PocketMine-MP/pull/418
PHP: switch($e->getCause()){ case 1: case 2: case 4: case 11: if($cause instanceof EntityDamageByEntityEvent){ if($cause->getDamager() !== null){ $ev = new EntityDamageByEntityEvent($cause->getDamager(), $ent, 1, $e->getBaseDamage()); $ent->setLastDamageCause($ev); } } return true; break; } } }