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

Need Help

Comments in 'Plugin Development' started by Flabe, Jan 16, 2016.

Thread Status:
Not open for further replies.
  1. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Hello guys , i need code to remove all FloatingTextParticles from the level. Please help if you know how to do this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Save them in a class property. If you don't hold them, server would lose control of them.
    AndrewBit likes this.
  3. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    As @PEMapModder said, the best way is saving the particles.
    I recommend you use a array instead of a class (It's easier).
    PHP:
    private $particles = [];
    If you're initializing your particles OnEnable, you only need to save their object.
    PHP:
    $this->particle[] = new WhateverParticle();
    But, if you want save particles on a class, it will be easy too.
    PHP:
    class Particles{
    private 
    $owner;
    private 
    $particles = [];

    public function 
    __construct(MainClass $owner){
    $this->owner $owner;
    }

    public function 
    addParticle($particle){
    $this->particles[] = $particle;
    }

    public function 
    removeAll(Level $level){
    foreach(
    $this->particles as $particle){
    $particle->setInvisible();
    $level->addParticle($particle,$this->owner->getServer()->getOnlinePlayers());
    }

    }
    Last edited: Jan 16, 2016
  4. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    PEMapModder likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Instead of a class?

    Also, it is not "the best way", but "the only way" :p (unless you do the crazy floccinaucinihilipilification way of saving the entity ID only, but then why use particles instead of the packets directly?) (just being paranoid)
Thread Status:
Not open for further replies.

Share This Page

Advertisement