BossBar on entity spawn...

Discussion in 'Spigot Plugin Development' started by Invaerne, May 20, 2017.

  1. Hi there,

    I'm currently experimenting with the Boss Bar for the first time.
    I want the bar to appear together with the zombie (I'm spawning a zombie by using a command).

    This is all I have so far:

    Code (Text):
            BossBar b = Bukkit.createBossBar("§cTEST", BarColor.BLUE, BarStyle.SOLID, BarFlag.PLAY_BOSS_MUSIC);
    ..and I'm stuck :D Any help would be greatly appreciated!
  2. Well, here are all the method you need
    Anyway, you need to assign the bossbar to the player/s, add all the flag you need, add a title and finally set it visible. Maybe you can change its progress with a BukkitRunnable that check the health of the mob
    • Agree Agree x 1
  3. How can I do it?
  4. Well, if you read the javafocs carefully, there stand #addPlayer
    Just do b.addPlayer(p) and it will show the bossbar to the player.
  5. Well, if you read carefully, or perhaps look more carefully, my post was precisly responding to the following sentence:
  6. just to avoid the use of a task altogether, you can update the bar when the entity's health is modified (damaged)
  7. Was i meant was using a BukkitRunnable to set not visibile the bossbar after X seconds
  8. Do you mean EntityDamageByEntityEvent?
  9. if you're sure the only way it'll be taking damage is by another entity, yes.
  10. But then how to update the progress since it is in seperate method?