Solved Issue with getting health

Discussion in 'Plugin Development' started by Pikachu8091, Nov 29, 2014.

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

    Pikachu8091

    Hey, so I'm learning Bukkit and Java at the the same time, and sometimes I may get ahead of myself with Bukkit. I'm working on some mechanics for a sword, and when I try to get someone who has taken damage from a specific sword's health, I get a weird error message. (The method getHealth() is ambiguous for the type Player) What am I doing wrong? How could I fix this?
    Code:java
    1. @EventHandler
    2. public void pyroHit(EntityDamageByEntityEvent e){
    3. Player a = (Player) e.getEntity();
    4. Player b = (Player) e.getDamager();
    5. if(b.getInventory().getItemInHand().hasItemMeta()){
    6. if(b.getInventory().getItemInHand().getItemMeta().hasDisplayName()){
    7. if(b.getInventory().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.RED + "Fire Sword")){
    8. int victimHealth = b.getHealth();
    9. if(victimHealth >= 20){
    10. b.setFireTicks(300);
    11. }
    12. }
    13. }
    14. }
    15. }

    Thanks.
     
  2. Offline

    Skionz

  3. Offline

    Pikachu8091

    Alright, fixed. Thanks a ton!
     
  4. Offline

    teej107

    One more thread to add to AdamQpzm's list.
     
    AdamQpzm and Skionz like this.
Thread Status:
Not open for further replies.

Share This Page