1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Hey, how can I add a effect to a Player ?

Discussion in 'Plugin Help' started by TheWalkingDrift, Jul 6, 2019.

  1. TheWalkingDrift

    TheWalkingDrift Silverfish

    Messages:
    23
    This is my Code:

    <?php

    namespace blue;

    use pocketmine\plugin\PluginBase;
    use pocketmine\Player;
    use pocketmine\Server;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerJoinEvent;
    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    use pocketmine\item\Item;
    use pocketmine\event\block\BlockPlaceEvent;
    use pocketmine\item\enchantment\Enchantment;
    use pocketmine\item\enchantment\EnchantmentInstance;
    use pocketmine\entity\Effect;
    use pocketmine\event\entity\EntityDamageEvent;
    use pocketmine\block\Block;
    use pocketmine\math\Vector3;
    use pocketmine\level\particle\DestroyBlockParticle;
    use pocketmine\level\particle\{DustParticle, FlameParticle, FloatingTextParticle, EntityFlameParticle, CriticalParticle, ExplodeParticle, HeartParticle, LavaParticle, MobSpawnParticle, SplashParticle};
    use pocketmine\event\player\PlayerMoveEvent;

    class Main extends PluginBase implements Listener {

    public $plugin;

    public function onEnable(){
    $this->getLogger()->info("Enable");
    $this->getServer()->getPluginManager()->registerEvents($this, $this);
    $this->eco = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI");
    }

    public function onCommand(CommandSender $sender, Command $command, String $label, array $args) : bool {
    switch($command->getName()){
    case "blue":
    $sender->removeAllEffects();
    $sender->addEffect(Effect::getEffect(10)->setAmplifier(50)->setDuration(20*2)->setVisible(false));
    return true;
    }
    return true;
    }
    }

    And this is my Problem:

    [16:53:50] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\entity\Effect::setAmplifier()" (EXCEPTION) in "plugins/blue/src/blue/Main" at line 38
     
  2. TheWalkingDrift

    TheWalkingDrift Silverfish

    Messages:
    23
    I think, I did allthing right, but It don't works
     
  3. TheWalkingDrift

    TheWalkingDrift Silverfish

    Messages:
    23
    I use pmmp Ver. 3.8.3
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    old code, please check the new api
     
    jasonwynn10 likes this.
  5. StevenS

    StevenS Spider

    Messages:
    8
    I couldn't get it to work either, so I just ran the effect command through the console.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.