I have some errors when I use this plugin. He must kill the player if they attacked with bone. PHP: public function onEnable(){$this->getServer()->getPluginManager()->registerEvents($this, $this);}public function onHurt(EntityDamageEvent $e){$entity = $e->getEntity();if($entity instanceof Player){if($e instanceof EntityDamageByEntityEvent){$killer = $e->getDamager()->getPlayer()->getName();$cause = $e->getEntity()->getPlayer()->getName();if($e->getDamager()->getInventory()->getItemInHand()->getId() == 352){ $e->getEntity()->getPlayer()->setHealth($e->getEntity()->getPlayer()->getHealth() - 20); $e->getDamager()->getInventory()->removeItem(Item::get(352, 0, 1)); } } } } Crash: Code: Error: Call to undefined method pocketmine\entity\PrimedTNT::getPlayer() File: /Bone_v2.phar/src/eddir/Bone Line: 39 Type: E_ERROR How to fix it?
PHP: if($e->getDamager()->getInventory()->getItemInHand()->getId() == 352){$e->getEntity()->getPlayer()->kill(); // use kill()$e->getDamager()->getInventory()->removeItem(Item::get(352, 0, 1));} Umm there's more wrong in it
I don't know where you got the getPlayer. It is simply useless, unnecessary and wrong. And $killer anas $entity are unussed. Please, we are not nannies. We are not here to hold your finger and teach you to type button by button. Please understand what you are doing when you do it.