Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to use addEffect()?

Comments in 'Plugin Development' started by Asidert, Apr 13, 2015.

  1. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    Who know how to use addEffect to player?
    I try and it not works...
  2. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    $p = xxx
    $effect = Effect::getEffect(Effect::SPEED); //kind of effect
    $effect->setVisible(true);
    $effect->setAmplifier(1);
    $effect->setDuration(20 * 60 * 3); //time
    $p->addEffect($effect);
  3. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    It no works, console wrote: "unexpected $effect at line 30"
    My code:
    PHP:
    [21]     }
    [
    22
    [
    23]   public function onBreak(BlockBreakEvent $event){
    [
    24
    [
    25]    if($event->getBlock()->getId() === Item::TNT){
    [
    26]         $p $event->getPlayer();
    [
    27]         $effect Effect::getEffect(Effect::SPEED);
    [
    28]         $effect->setVisible(true);
    [
    29]         $effect->setAmplifier(1); 
    [
    30]         $effect->setDuration(20 10 3);
    [
    31]         $p->addEffect($effect);
    [
    32
    [
    33]     }
    [
    34]    }
    [
    35
    [
    36]     public function onDisable() {
    [
    37]         $this->getLogger ()->info TextFormat::RED "Деактивация Лаки Блоков от Бориса" );
    [
    38]         $this->enabled false;
    [
    39]     }
    [
    40] }
  4. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Code:
     $effect = Effect::getEffect(1);
            $effect->setVisible(false);
            $effect->setDuration(800000000);
    
            $event->getPlayer()->addEffect($effect);
    I use this, and it work, but it should be the same as Effect::SPEED
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Delete the code and type them out yourself. It shouldn't have any syntax errors unless someone trolled you with an invisible character.
    iJoshuaHD likes this.
  6. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    PEMapModder likes this.
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Can this be used as special power?

Share This Page

Advertisement