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

Duplicated FloatingTextParticle

Comments in 'Plugin Development' started by deot, Nov 28, 2015.

  1. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Hi, when i used FloatingTextParticle in PlayerJoinEvent, it will be duplicated... Idk if anybody realized... but heres an example:

    1st player joined, one TextParticle spawned
    2nd player joined, another one TextParticle spawned
    3rd player joined, one more TextParticle spawned

    And this make that:
    1st player see 1 TextParticle (not duplicated)
    2nd player see 2 same TextParticle(duplicated)
    and 3rd player see 3....

    Then... how can I spawn only one TextParticle to every player? In which Event should i put?? Or any other way to do this?

    Thanks ;)
    Last edited: Nov 28, 2015
    Skullex likes this.
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Same thing happens to me. It doesnt bother me though.
  3. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Well, if you're the last player joined the server... u can see many identical FloatingTextParticle at the same coordinate... And... it will be very LAGGED!

    This is how it bothers me..
    Skullex likes this.
  4. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    and if you add púarticle only once so it doesn't work? else use $particle->setInvisible() and then add new particle
  5. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Pretty sure you can set who the particle will show to.
  6. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    I do like this:
    PHP:
                $this->pt1->setInvisible();
                
    $this->level->addParticle($this->pt1);
    Yes, it make the particle become invisible, but after that I do addParticle I cant spawn it back :(

    How?? Idk how, I searched trough the forum... doesnt see anything related.. zzz :p
    Skullex likes this.
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    I think you should replace pt1 with new instance
  8. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    did you try add particle only once? it works for me and all players see it
  9. Timmpann
    Offline

    Timmpann New Member

    Joined:
    Feb 5, 2015
    Posts:
    24
    Minecraft User:
    Timmpann
    Instead of creating a new particle every time someone joins, create all your particles when the server starts and then send it to the players when they join.

    PHP:
     private $particles = [];

    public function 
    onEnable(){
      
    $this->getServer()->getPluginManager()->registerEvents($this$this);

      
    $this->particles[] = new FloatingTextParticle(new Vector3(138.543.5157.5), """§l§c>>§aSurvival§c<<");
      
    $this->particles[] = new FloatingTextParticle(new Vector3(132.543.5157.5), """§l§c>>§aCreative§c<<");
      
    $this->particles[] = new FloatingTextParticle(new Vector3(126.543.5157.5), """§l§c>>§aSpleef§c<<");
      
    $this->particles[] = new FloatingTextParticle(new Vector3(120.543.5157.5), """§l§c>>§aInget/Nothing§c<<");
    }

    public function 
    onPlayerJoin(PlayerJoinEvent $event){
      foreach(
    $this->particles as $particle){
       
    $event->getPlayer()->getLevel()->addParticle($particle, [$event->getPlayer()]);
      }
    }
  10. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Looks great, i will test that now :)
    Skullex likes this.
  11. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    test it without sending before because i don't have to do that and all players see them
  12. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    How do we make it center like Hypixel do ?
  13. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Simple. Use alot of spaces.
  14. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    That would be hard? is there any kind of tag like $center or whatever
  15. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Nope, u can do it again and again... it wont be too hard... xD
    Skullex likes this.
  16. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    perfectly centered...

Share This Page

Advertisement