Effect based on Health

Discussion in 'Plugin Development' started by zzienzz, Nov 26, 2013.

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

    zzienzz

    So I wanted it so that whenever someone on my server gets low health, a small effect plays.

    Code:java
    1. public static void updatePlayerFastish(Player curPlayer)
    2. {
    3. if (curPlayer.getHealth() <= 5)
    4. {curPlayer.getWorld().playEffect(curPlayer.getLocation(), Effect.POTION_BREAK, 9);}
    5. }


    It's working fine, if someone gets below 3 hearts, the effect plays. The effect being the breaking of a red potion.

    My problem is that I don't want it to spam it. I want it to do it like once every 0.5 seconds. Whereas at the moment, its like 20 times a second, far too fast for my liking (and may cause lag).

    But I'm not sure how to do this.... Any help?
     
  2. Offline

    GusGold

Thread Status:
Not open for further replies.

Share This Page