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

Solved $particle->setInvisible(); doesnt work :/

Comments in 'Plugin Development' started by cake23, Mar 27, 2016.

  1. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Hey! I write a plugin, that spawns FloatingTextParticle with a command and remove them.
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
     switch(
    $command->getName()){
      case 
    "spawnparticle":
       
    $particle = new FloatingTextParticle(new Vector3(127.57108.8), Color::WHITE."Teeeeeeeeeeeeeest\n Test!"$this->anfang.Color::YELLOW."T".Color::GOLD."est".$this->anfang);
       
    $this->getServer()->getDefaultLevel()->addParticle($particle);
      break;
      case 
    "removeparticle":
       
    $particle->setInvisible();
      break;
     }
    }
    But if I do /removeparticle, nothing happens! Does anyone know why? Thanks!
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    $particle is created in the case "spawnparticle", you cannot access it from outside of that case.
    Skullex and cake23 like this.
  3. TheNewHEROBRINE
    Offline

    TheNewHEROBRINE New Member

    Joined:
    Mar 5, 2016
    Posts:
    10
    Minecraft User:
    TheNewHEROBRINE
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
    switch(
    $command->getName()){
    case 
    "spawnparticle":
    $this->particle = new FloatingTextParticle(new Vector3(127.57108.8), Color::WHITE."Teeeeeeeeeeeeeest\n Test!"$this->anfang.Color::YELLOW."T".Color::GOLD."est".$this->anfang);
    $this->getServer()->getDefaultLevel()->addParticle($particle);
    break;
    case 
    "removeparticle":
    $this->particle->setInvisible();
    break;
    }
    }
    PEMapModder and cake23 like this.
  4. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    I also tried this:
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
    switch(
    $command->getName()){
      case 
    "removeparticle":
    $particle = new FloatingTextParticle(new Vector3(127.57108.8), Color::WHITE."Teeeeeeeeeeeeeest\n Test!"$this->anfang.Color::YELLOW."T".Color::GOLD."est".$this->anfang);
       
    $this->getServer()->getDefaultLevel()->addParticle($particle);
       
    $particle->setInvisible();
      break;
    }
    }
  5. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
  6. TheNewHEROBRINE
    Offline

    TheNewHEROBRINE New Member

    Joined:
    Mar 5, 2016
    Posts:
    10
    Minecraft User:
    TheNewHEROBRINE
    you need to save the FloatingTextParticle object in a class property
  7. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
  8. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
  9. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    yep
    yep, but make sure you add all the arguments
    cake23 likes this.

Share This Page

Advertisement