Ambiguous Method Call? help?

Discussion in 'Plugin Development' started by Nachoman44, Apr 20, 2014.

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

    Nachoman44

    I'm confused on what i'm doing wrong, if I am doing something wrong.. It seems as though i'm unable to use .getDamage() or .getHealth() in EntityDamageByEntityEvent event. No idea what the problem is D= here's the code:

    Code:java
    1. @EventHandler
    2. public void entityDamagebyEntity(EntityDamageByEntityEvent event){
    3. if (!(event.getDamager() instanceof Player && event.getEntity() instanceof Player)) return;
    4. if (ArenaManager.getManager().isInGame((Player) event.getDamager()) &&
    5. ArenaManager.getManager().isInGame((Player) event.getEntity())){
    6. Player damager = (Player) event.getDamager();
    7. Player victim = (Player) event.getEntity();
    8. double Damage = event.getDamage();
    9. event.setCancelled(true);
    10. victim.damage(Damage);
    11. victim.getWorld().playEffect(victim.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
    12. if ((victim.getHealth()-Damage) <= 0){
    13. // Killed.
    14. }
    15.  
    16. }
    17. }


    Here's the error I get when I hover over it:
    Code:
    Ambiguous method call. Both
    getHealth    ()    in Damageable and
    getHealth    ()    in Damageable match.
     
    Exactly the same for getDamage.
     
  2. Offline

    GeorgeeeHD

    Its a bit weird. Use:

    Code:java
    1. Damageable victim = (Damageable) event.getEntity();
     
  3. Offline

    Nachoman44

    GeorgeeeHD
    Still exactly the same problem, :confused:
     
  4. Offline

    YoshiGenius

    If using Maven, you need to have the bukkit dependency higher up than the craftbukkit one.

    If using Eclipse, you need to (in build path), go to Order/Export, and move the bukkit dependency to higher than the craftbukkit one.

    If you do not have the bukkit dependency, add the correct version.

    i.e. if using craftbukkit-1.7.9-R0.1, use the corresponding bukkit-1.7.9-R0.1
     
  5. Offline

    Garris0n

    Use Bukkit instead of CraftBukkit.

    Edit: I had this page loaded for a while, somebody else answered it. Not even really ninja'd, just stupid :p
     
  6. Offline

    ZeusAllMighty11 Retired Staff

  7. Offline

    Garris0n

    I generally assume people using NMS code are also capable of doing a google search and finding the countless other threads with the same question :p
     
Thread Status:
Not open for further replies.

Share This Page