player.setHealth(20) Not Working Help Please!

Discussion in 'Plugin Development' started by semajjames1399, Sep 25, 2013.

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

    semajjames1399

    I felt like making a private heal plugin for my sever but the code doesnt work. I am aware in 1.6 they changed everything around and ive read EvilSteph's forum post but i got confused. This is the code i have, here it is:

    Code:java
    1. package com.semajjames1399.minecraft.plugin.iCMD;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8.  
    9. public class heal implements CommandExecutor {
    10.  
    11. @Override
    12. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    13. Player player = (Player) sender;
    14. if (cmd.getName().equalsIgnoreCase("heal")) {
    15. if (player.hasPermission("icmd.command.heal")) {
    16. if(args.length == 0) { // '/heal' = 0 args, '/heal semajjames1399' = 1 args
    17. player.setHealth(20); //Right here it isnt working. There is a yellow line with a strike through it in eclipse********
    18. player.sendMessage(ChatColor.AQUA + "You have been fed!");
    19. }
    20. else if(args.length == 1){
    21. Player targetPlayer = player.getServer().getPlayer(args [0]);
    22. targetPlayer.setSaturation(20);
    23. targetPlayer.sendMessage(ChatColor.AQUA + "You have been fed!");
    24. player.sendMessage(ChatColor.AQUA + "Player Fed!");
    25. }
    26. return true;
    27. }
    28. else {
    29. sender.sendMessage(ChatColor.RED + "Error: No Permission!");
    30. return false;
    31. }
    32. }
    33. return false;
    34.  
    35. }
    36.  
    37. }


    It would be nice if someone could either fix the line or just fix the entire class. Thanks!
     
  2. Offline

    chasechocolate

    It's a double: player.setHealth(20.0D). Also, it's "EvilSeph" ;)
     
  3. Offline

    semajjames1399

    what is the .oD for?
     
  4. Offline

    TheEyeMonster

    Do you have a plugin.yml with the command registered?
     
  5. Offline

    semajjames1399

    yes. i do.
     
  6. semajjames1399 That is for converting it from an int into a double which is what is used for health now.
     
  7. Offline

    TheEyeMonster

    Because its a Double said that guy.
     
  8. Offline

    semajjames1399

    Alright thanks guys!
     
Thread Status:
Not open for further replies.

Share This Page