.getHealth() Help

Discussion in 'Plugin Development' started by Leviticalpixel10, Apr 18, 2014.

Thread Status:
Not open for further replies.
  1. I'm trying to make a regen command and here is my code:

    Code:java
    1. Player p = (Player) sender
    2. boolean isRegen = false;
    3. if(commandLabel.equalsIgnoreCase("regen")){
    4. if(isRegen == false){
    5. isRegen = true;
    6. player.sendMessage(ChatColor.BOLD + "Regeneration Mode is Now On.")
    7. }else{
    8. if(isRegen == true){
    9. isRegen = false
    10. player.sendMessage(ChatColor.BOLD + "Regeneration Mode is Now Off")
    11. }
    12. Health h = p.getHealth()
    13. if(!(h == 20)){
    14. p.setHealth(20)
    15. }
    16. }


    It sayd that the setHealth and getHealth are only for a player. Any help? oh, and it says that Health isn't correct on the variable claiming.
     
  2. Offline

    2MBKindiegames

    Hi,
    getHealth returns a double, not a health (if that even exists).
    You need to do something like this:
    Code:java
    1. Double h = p.getHealth()
    2. if(!(h == 20)){
    3. p.setHealth(20)
    4. }
     
Thread Status:
Not open for further replies.

Share This Page