What is wrong? Error: "Call to undefined method pocketmine\entity\effect\Effect::getEffect()" (EXCEPTION) in "plugins/Borrow_plugin/src/Borrow/MainBorrow" at line 34 <?php namespace Borrow; use pocketmine\plugin\PluginBase; use pocketmine\event\Listener; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageByChildEntityEvent; use pocketmine\entity\effect\Effect; use pocketmine\entity\Entity; use pocketmine\utils\Config; use pocketmine\inventory\Inventory; use pocketmine\entity\EffectInstance; use pocketmine\player\Player; class MainBorrow extends PluginBase implements Listener { function onEnable() : void { $this->config = new Config($this->getDataFolder()."config.yml", Config::YAML); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info("lol"); } function onDisable() : void { $this->getLogger()->info("lol"); } public function onDamage(EntityDamageEvent $event){ if($event instanceof EntityDamageByEntityEvent && $event->getDamager() instanceof Player) { $player = $event->getEntity(); $damager = $event->getDamager(); if($damager->getInventory()->getItemInHand()->getId() == 261){ $effect = Effect::getEffect(9); $effect = new EffectInstance($effect, 20 * 5, 1); $entity->addEffect($effect); } } } }
PHP: use pocketmine\entity\Living;use pocketmine\entity\effect\{Effect, EffectInstance, VanillaEffects};use pocketmine\event\entity\{EntityDamageByEntityEvent, EntityDamageEvent};use pocketmine\item\VanillaItems;use pocketmine\player\Player; PHP: public function onDamage(EntityDamageEvent $event): void { if ($event instanceof EntityDamageByEntityEvent && ($damager = $event->getDamager()) instanceof Player) { $entity = $event->getEntity(); if ($entity instanceof Living && $damager->getInventory()->getItemInHand()->equals(VanillaItems::BOW(), false, false)) { $entity->getEffects()->add(new EffectInstance(VanillaEffects::NAUSEA(), 20 * 5, 1)); } }}