Solved Adding Extra Health

Discussion in 'Plugin Development' started by jonasxdx, Mar 24, 2015.

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

    jonasxdx

    I am trying to create mini game using a Bukkit plugin. I am trying to give the player 4 rows of hearts, so 40 hearts or 80 hit points. I can't figure out the code to do this, and was wondering if some one could help. Anyone know the code for adding health. It doesn't need to meet my requests, just editable so I can edit it to meet my request. I have some code below, and if someone could tell me how to change that to work, that would be great. I am not sure the code can be edited to do this though. I am new to coding Bukkit plugins, and still learning. Thanks so much to anyone who helps!!
    Code:
    public boolean realSoup(Player player, Player tplayer, double damage){
           
            if (player.hasPermission("myrace.wraith.reap")){
                player.sendMessage(ChatColor.DARK_GRAY + "You have reaped " + tplayer.getName() + "'s soul.");
                damage = player.getLevel()/10;
                double heal = damage/2;
                tplayer.damage(damage);
                player.setHealth(new Double(player.getHealth()) + heal);
            }
            return true;
        }
     
  2. I belive what your looking for is something like player.setMaxHealth(80); However, that just sets their max health. Im not sure if thats all you needed though xD
     
  3. Offline

    jonasxdx

    Will this make it so the player has 80 HP?
    Code:
    public boolean realSoup(Player player, Player tplayer, double damage){
              
            if (player.hasPermission("myrace.wraith.reap")){
                damage = player.getLevel()/10;
                tplayer.damage(damage);
                player.setMaxHealth(80);
            }
            return true;
        }
     
    Tyler Christensen likes this.
  4. Offline

    teej107

    @jonasxdx Have you tried looking in the Bukkit documentation? @Tyler Christensen Already mentioned the method, but the Bukkit documentation is a great place to go for questions like this.
     
    Tyler Christensen likes this.
  5. Offline

    jonasxdx

    No I didn't. I didn't even think of that. Thanks for the suggestion!!
     
  6. Offline

    nverdier

    @jonasxdx Is this solved? If so, please mark your thread as solved. See this for more info.
     
Thread Status:
Not open for further replies.

Share This Page