how i can fix this? Code: [Server thread/CRITICAL]: ErrorException: "Non-static method pocketmine\entity\EffectInstance::getId() should not be called statically" (EXCEPTION) in "BlackEffect/src/BlackEffect/sets/BuffEffectSet" at line 41 Spoiler: BufferEffectSet Code: <?php namespace BlackEffect\sets; use pocketmine\entity\Effect; use pocketmine\entity\EffectInstance; use pocketmine\Player; class BuffEffectSet extends EffectSet { /** * Apply the buffs to a player * * @param Player $player */ public function applyBuffs(Player $player) { foreach($this->effects as $e) { $effect = clone $e; $player->addEffect(20 * 30); } } /** * Remove all buffs from a player * * @param Player $player */ public function removeBuffs(Player $player) { foreach($this->effects as $e) { $player->removeEffect($e->getId()); } } /** * Read buff data from config and parse effects into an array * * @param array $data */ protected function parseEffects(array $data) { for($i = 0; $i < count($data); $i++) { $this->effects[] = EffectInstance::getId($data[$i]["id"]($data[$i]["amplifier"](20 * 30))); } } }
You need to create a new instance of EffectInstance, what do you expect EffectInstance::getId() to return? PHP: $effect = Effect::getEffect($data[$i]["id"]);$duration = 20 * 30;$amplifier = $data[$i]["amplifier"];$effectInstance = new EffectInstance($effect, $duration, $amplifier); Anyway, this should be helpful for you: http://php.net/manual/en/functions.arguments.php
I managed to fix my now I have this error PHP: [Server thread/CRITICAL]: Error: "Call to undefined function night_vision()" (EXCEPTION) in "BlackEffect/src/BlackEffect/sets/BuffEffectSet" at line 41 Spoiler: BuffEffectSet PHP: <?phpnamespace BlackEffect\sets;use pocketmine\entity\Effect;use pocketmine\entity\EffectInstance;use pocketmine\Player;class BuffEffectSet extends EffectSet { public function applyBuffs(Player $player) { foreach($this->effects as $e) { $effect = clone $e; $player->addEffect(20 * 30); } } public function removeBuffs(Player $player) { foreach($this->effects as $e) { $player->removeEffect($e->getId()); } } protected function parseEffects(array $data) { for($i = 0; $i < count($data); $i++) { $this->effects[] = Effect::getEffectByName($data[$i]["id"]($data[$i]["amplifier"](20 * 30))); } }}
I think you have a code who you dont understand. You are getting an effect by his name so why are you using amplifier?? In you array PHP: //getEffect in PMMPpublic static function getEffectByName(string $name) : ?Effect{ $const = self::class . "::" . strtoupper($name); if(\defined($const)){ return self::getEffect(\constant($const)); } return null; } You have to insert a name not anything else.. And the error go with that, use correctly the function and it will work. Or just use a code who you understand