[Tutorial] Utilizing the Boss Health Bar

Discussion in 'Resources' started by chasechocolate, Jul 5, 2013.

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


    It appears I'm invisible, even though the dragon may not be.
  2. Offline


    If anyone wants, I have updated Comphenix's ProtocolLib version to 1.7, you will need ProtocolLib (ofc) and PacketWrapper. Here: https://gist.github.com/thesbros/8446511
    Keep in mind this is not tested.
  3. Offline


    How can i make for show total players health in the bar?
  4. Offline


    How come the Bar Looks odd, it just works when i am one a specific area (when the bar first appears) when it lowers a Wither spawns and the Bar Health ends faster than the cooldown itself. Here is my code:

    1. public Pyro() {
    2. super("Pyro", "Trained by the masters of the Fire the pyro is a crazy archer who sets everything and everyone on fire."+ "<NL>" + ChatColor.YELLOW.toString() + ChatColor.BOLD + "Purchase from the Shop!", null, new ItemStack(Material.FIRE));
    3. this.listener = new Listener() {
    4. @EventHandler
    5. public void onAbility(PlayerInteractEvent event) {
    6. if (event.getItem() == null || !event.getPlayer().getItemInHand().equals(KitManager.getInstance().getAbilityItem()) || !(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) || (!KitManager.getInstance().getSelectedKits().containsKey(event.getPlayer().getName()) || !KitManager.getInstance().getSelectedKits().get(event.getPlayer().getName()).equals("Pyro"))) {
    7. return;
    8. }
    9. if (KitManager.getInstance().getSelectedKits().containsKey(event.getPlayer().getName()) && KitManager.getInstance().getSelectedKits().get(event.getPlayer().getName()).equals("Pyro") && event.getPlayer().getItemInHand().equals(KitManager.getInstance().getAbilityItem()) && !KitPVP.getInstance().getCooldownUtils().playersInCooldown.containsKey(event.getPlayer().getName())) {
    10. KitPVP.getInstance().getCooldownUtils().setCooldownLength(event.getPlayer(), 300,KitPVP.getInstance().getCooldownUtils().playersInCooldown);
    11. KitPVP.getInstance().getCooldownUtils().startCooldown(event.getPlayer(), KitPVP.getInstance().getCooldownUtils().playersInCooldown);
    12. BarAPI.displayLoadingBar(ChatColor.YELLOW.toString() + ChatColor.BOLD + "Reloading Ability...", ChatColor.GREEN.toString() + ChatColor.BLUE + "You can use the Ability", event.getPlayer(),20,300,false);
    13. for (Entity e : event.getPlayer().getNearbyEntities(20,20,20)) {
    14. if (e instanceof Player) {
    15. Player p = (Player) e;
    16. p.setFireTicks(20*10);
    17. }
    18. }
    19. ChatUtils.sendMessage(event.getPlayer(), ChatColor.GRAY + "Used ability" + ChatColor.RED.toString() + ChatColor.BOLD + "Firescape!");
    20. } else if (KitPVP.getInstance().getCooldownUtils().playersInCooldown.containsKey(event.getPlayer().getName()) && event.getPlayer().getItemInHand().equals(KitManager.getInstance().getAbilityItem())) {
    21. ChatUtils.sendMessage(event.getPlayer(), ChatColor.GRAY + "You still need to wait " + TimeUtil.formatIntoMMSS(KitPVP.getInstance().getCooldownUtils().getTimeLeft(event.getPlayer(), KitPVP.getInstance().getCooldownUtils().playersInCooldown)) + " to use Firescape ability again!");
    22. event.setCancelled(true);
    23. }
    24. }
    25. };
    26. }
  5. Offline


    Hm, question about Chase's 1.6.4 reflection. This is probably a nooby one, that I have completely overlooked, but when the player relogs before the bar updates, it no longer shows. Would setting the display to 0 on a login event prevent this?, if not any suggestions?
  6. Offline


    For the 1.7 version, what would I put for the yourMainClass? I tried this and it says "Cannot use this in a static context" and when I use my main class name it says it can't be resolved to a variable. How would I do this?
  7. Offline


    Use the instance of your main class, not the actual class itself.
  8. Offline


    Got it to work but I get this error:http://hastebin.com/daxuveyusi.coffee

    This is the HeadsUpDisplay and I tried

    HeadsUpDisplay.displayLoadingBar("Hallo", "Finished", player, 10, true);
    HeadsUpDisplay.displayTextBar("Hallo", player);
    Both throw the error from up above.
  9. Offline


    97waterpolo the hastebin doesn't seem to be working.
  10. Offline


  11. Offline


  12. Offline


    97waterpolo in your onEnable(), put HeadsUpDisplay.plugin = this.
  13. Offline



    Thank you ._. amazed it was that simple...

    Is this per player? Or does it show for everyone? I got no alts and no friends to log on right now, if its for the whole server, are you able to have a custom one per player?
  14. Offline


    You can set it for one player, or loop online players.
  15. Offline


    DrJava chasechocolate
    Well I am trying to make a instance per player, but player Tom's will be different than player Alex.

    And I am using "HeadsUpDisplay.displayLoadingBar("Regenerating", "Full Stamina", player, 20, true);"

    Throwing error on "displayLoadingBar" saying "The method displayLoadingBar(String, String, Player, int, boolean) is undefined for the type HeadsUpDisplay". How am I messing up?

    EDIT: No idea. went away as I continued coding, so thanks for the help!
  16. chasechocolate I am getting smoke effects around the player, but I have no idea why (and it most definetely isn't my code) :/
  17. Offline


  18. Offline


    Why not just use BarAPI?
  19. Offline


    e1kfws7 this is for those who don't want to depend on a plugin :)
  20. Offline


  21. Offline


    chasechocolate - I took SoThatsIt 's messy-as-hell and slightly broken (despawning the dragons didn't work) reflection code for MC 1.7.x and patched/cleaned it up. It works like a charm for me.

    I present to you, a reflection-based 1.7.x-compatible dragon-enabled single-class API for manipulating the boss health bar:

  22. Offline



    Awesome! Great work!

    It would be cool if you could add the methods from chasechocolate 's gist version two. I mean (for example) the override parameter (because this seems to be pretty useful) and the displayloadingbar method (because this is probably one of the most important/awesome things you can do with the boss bar).
  23. Offline


    darkness1999 I'll put it on my to-do list. Have you checked to see that it actually works for you?
  24. Offline


    AmoebaMan Had no time so far :(

    EDIT: Seems to be working for me :)
  25. this method works for me:
    public static void create(Location location, String text) {
    LivingEntity enderdragon = (LivingEntity) location.getWorld().spawnEntity(location, EntityType.ENDER_DRAGON);

    enderdragon.setCustomNameVisible(true); isn't necessary.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 3, 2016
  26. Offline


    If it helps, you can use
    1. me.confuser.barapi.BarAPI.setMessage(player, "Something", 10);

    That should last 10 seconds.
    So for my plugin, I'm using:
    1. if(commandLabel.equalsIgnoreCase("reloading")){
    2. Bukkit.broadcastMessage(ChatColor.RED+""+ChatColor.BOLD+"RELOADING");
    3. me.confuser.barapi.BarAPI.setMessage(player, ChatColor.RED+""+ChatColor.BOLD+"RELOADING", 10);
    4. }

    All seems to work well on 1.7, though, I have not tested in on 1.6 nor am I willing to.
  27. Offline


    I am using the Version 3 an changed it to use a EnderDragon which will be spawned under Bedrock
    d.set(mobPacket, (int) Math.floor(loc.getBlockY() -200D));
    But the Players will hear the Enderdragon Flying. Is it possible to disable the sound? or is it possible to block the sound in anyway?

    Thanks for the Nice API!

  28. It says:
    1. //Remember to change "yourMainClass" to your plugin's main class

    my main class is BossHealth
    So what should I change 'yourMainClass' to?
  29. Offline


    Is there any way to get rid of the smoke particles spawning around the player?
  30. Offline


    Can you make me a version for 1.5.2 or can you tell me how i spawn the dragon with packets
Thread Status:
Not open for further replies.

Share This Page