<?php namespace Stick; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\entity\Effect; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\Listener; use pocketmine\item\Armor; use pocketmine\item\Axe; use pocketmine\item\Item; use pocketmine\item\Pickaxe; use pocketmine\item\Shovel; use pocketmine\item\Sword; use pocketmine\math\Vector3; use pocketmine\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\Config; use pocketmine\utils\TextFormat as TF; class Stick extends PluginBase implements Listener { private $config; public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onEntityDamage(EntityDamageEvent $event) { if ($event instanceof EntityDamageByEntityEvent) { $player = $event->getEntity(); $effect = $event->getEffect(); if($effect instanceof Player){ $item = $effect->getInventory()->getItemInHand(); if($item->getId(376)){ $player->addEffect(Effect::getEffect(Effect:OISON)); } } } } }
Tip: you no longer need to check $event instanceof EntityDamageByEntityEvent. You could directly put EntityDamageByEntityEvent in the parameter type.