Adding a wither bar to a player?

Discussion in 'Plugin Development' started by Slideroller, Jan 4, 2014.

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

    Slideroller

    Is it possible to add a wither bar to a player and the health? I'm curious about this because I'm making a plugin and I don't know if this is possible it'd be cool though but although the wither health would have to collide to a player?
    If so may I please have an example of the code?
     
  2. Offline

    Timbals

  3. Offline

    Slideroller

  4. Offline

    Timbals

    What do you mean?

    Do you mean that the health of the Wither is the health of the Player?
     
  5. Offline

    Slideroller

    Yeah, and any damage the player takes it'll take it as a wither health
     
  6. Offline

    GaaTavares

    Listen to EntityDamage and Regain, then keep updating your Boss API method.
    Also use a scheduler (repeating) .-.
     
  7. Offline

    Slideroller

    May I please have an example if possible?
     
  8. Offline

    GaaTavares

    Code:java
    1.  
    2.  
    3. pubic void onRegain(EntityRegainEvent e){
    4. if (!(e.getEntity() instanceof Player))
    5. return;
    6. Player p = (Player)e.getEntity();
    7. YourBossAPI.displayBar(....);
    8. }
    9.  

    and
    Code:java
    1.  
    2.  
    3. pubic void onDamage(EntityDamageEvent e){
    4. if (!(e.getEntity() instanceof Player))
    5. return;
    6. Player p = (Player)e.getEntity();
    7. YourBossAPI.displayBar(....);
    8. }
    9.  

    then use int on your onEnable()
    Code:java
    1.  
    2. Bukkit.getScheduler().scheduledSyncRepeatingTask(this, new Runnable()){
    3.  
    4. public void run(){
    5. for (Player on: Bukkit.getOnlinePlayers()){
    6. YourBossAPI.displayBar())...
    7. },0,40);
    8.  
     
Thread Status:
Not open for further replies.

Share This Page