playEffect() on player not showing up

Discussion in 'Plugin Development' started by JaguarBolt, Sep 2, 2013.

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

    JaguarBolt

    I'm making a plugin that will create mob spawner flames around every player online with this code:
    Code:java
    1. public void onEnabled(){
    2. getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    3.  
    4. @Override
    5. public void run() {
    6. for (Player p : getServer().getOnlinePlayers()){
    7. p.getWorld().playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 30);
    8. }
    9. }
    10.  
    11. }, 0, 20);
    12. }

    However, when I put the plugin on my private server for testing, I don't see any flames.
     
  2. Offline

    newboyhun

    JaguarBolt
    Do you see it in third person view?

    getLocation() doesn't give you the center of the player, you need to position on to player's body or so.
     
  3. Offline

    Gater12

    Try:
    Code:java
    1. getServer().getScheduler().scheduleAsyncRepeatingTask(this,
    2. new Runnable(){
    3. @Override
    4. public void run(){
    5. for(Player p : Bukkit.getServer().getOnlinePlayers()){
    6. p.getWorld().playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 10);
    7. }
    8. }
    9. }, 20, 20);
     
  4. Offline

    tommycake50

    Yeah getLocation gives you the leg position.
    What's the 30 for?
     
  5. Offline

    JaguarBolt

    tommycake50 - It's a data value. To be honest, I'm really not sure what it does, I saw it in example code on one of my other threads.

    newboyhun - I double checked to make sure that particles are on, and I can't see it in third person view.
     
  6. Offline

    macguy8

    Gater12
    All you did that I saw was make it async, which would just add more possible errors...
     
  7. Offline

    Morrango

    the data value changes the direction of the smoke particle. I believe there are only 9 directions starting at 0. So try a data value <= 8
     
  8. Offline

    JaguarBolt

    Changing the data value didn't change that fact that I couldn't see any particles on the player at all.
     
  9. Offline

    Retherz_

    I think it is the amount
     
  10. Offline

    JaguarBolt

    But, that wouldn't make sense, because regardless of the data value given, I can't see any particles from playEffect().
     
  11. Offline

    Waffletastic

  12. Offline

    JaguarBolt

    Wow! Player.playEffect() works! My only concern is that p.playEffect() only plays the effect for that specific player, and for the purposes of my plugin, that won't work.

    Edit: Doing Effect.MOBSPAWNER_FIRE doesn't work. I'm think that it's maybe an issue with the loop I'm using, because the playEffect() method works outside of it. Another Edit: I started the loop in the onEnabled() method. onEnabled() should've been onEnable(). onEnabled() never was run because it was meant to be onEnable().
     
  13. Offline

    fromgate

    JaguarBolt mobspawner fire is an "oldest" effect and it works fine. I used this effect in some of my plugins including the NoSmoking! and PlayEffect. Here is example: https://github.com/fromgate/PlayEff...e/fromgate/playeffect/effect/EffectFlame.java

    May be you trying to use wrong name? Right name is Effect.MOBSPAWNER_FLAMES
    The data value for this effect does not mean anything. So you can type world.playEffect(loc,Effect.MOBSPAWNER_FLAMES, 0) and it will work. Data is required for SMOKE effect (Example: https://github.com/fromgate/PlayEff...e/fromgate/playeffect/effect/EffectSmoke.java) and for some other effects.

    I think you need to do additional check before play effect in by loop. You must be sure that there's a player can see this effect and play this effect. If no one can see this effect - you don't need to play it. If you play a lot of effects you can overload a network bandwidth (every playEffect sends a packet to players).

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
Thread Status:
Not open for further replies.

Share This Page