Plugin Help Trying To Fix a Plugin That Deals With Boss Mob Health Bars Need Help

Discussion in 'Plugin Help/Development/Requests' started by abctmtom, Feb 9, 2016.

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

    abctmtom

    The plugin is meant to make it so your health is given to you by armor so if your chest says say hp: +100 then it adds to your wither bar or boss mob bar 100/100 and if say i hit you with my fist it become 99/100 but i run into a problem because i think its not just changing the text but instead also hurting the wither and the wither dies before the play hits 0/100 so at one point the player cant see the boss mob bar and so they dont know home much health they have. because the player is suppose to die when it his 0/100. if this does not make sense i am sorry [edit]

    below is the code i think that deals with this if it is not tell me again i cant code so i very well could be wrong.



    public void barHealth(Player player) {
    BarAPI.setMessage(player, "§d§lHP §d" + (int)player.getHealth() + " §d§l/§d " + (int)player.getMaxHealth());
    BarAPI.setHealth(player, (float)((float)player.getHealth() / player.getMaxHealth() * 100.0D));
    }
    public String getNameHealth(double Health, double MaxHealth, String Name) {
    Name = Name.replaceAll("§0", "");
    Name = Name.replaceAll("§1", "");
    Name = Name.replaceAll("§2", "");
    Name = Name.replaceAll("§3", "");
    Name = Name.replaceAll("§4", "");
    Name = Name.replaceAll("§5", "");
    Name = Name.replaceAll("§6", "");
    Name = Name.replaceAll("§7", "");
    Name = Name.replaceAll("§8", "");
    Name = Name.replaceAll("§9", "");
    Name = Name.replaceAll("§a", "");
    Name = Name.replaceAll("§b", "");
    Name = Name.replaceAll("§c", "");
    Name = Name.replaceAll("§d", "");
    Name = Name.replaceAll("§e", "");
    Name = Name.replaceAll("§f", "");
    Name = Name.replaceAll("§l", "");
    Name = Name.replaceAll("§k", "");
    Name = Name.replaceAll("§o", "");
    Name = Name.replaceAll("§m", "");
    Name = Name.replaceAll("§n", "");
    double percent = Health / MaxHealth;
    double length = Name.length();
    double scolor = length * percent;
    int color = (int)Math.ceil(scolor);
    String n = Name;
    if (color < length / 3.0D)
    {
    String g = n.substring(color);
    String h = n.substring(0, color);
    n = "§c" + h + "§7" + g;
    } else if (color < length / 1.5D)
    {
    String g = n.substring(color);
    String h = n.substring(0, color);
    n = "§e" + h + "§7" + g;
    }
    else {
    String g = n.substring(color);
    String h = n.substring(0, color);
    n = "§a" + h + "§7" + g;


    [edit by moderator: removed disallowed section - please read forum rules]
     
    Last edited by a moderator: Feb 9, 2016
  2. Offline

    pie_flavor

    @abctmtom lol that's a lot of replaceAlls
    ChatColor.stripColor(String)
     
  3. Offline

    teej107

    for loop says hi.

    @abctmtom Please put your code in code tags so it's not a hassle to read.
     
Thread Status:
Not open for further replies.

Share This Page