Getting the Damager AND the player who got damaged

Discussion in 'Plugin Development' started by Monkey_Swag, Feb 11, 2014.

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

    Monkey_Swag

    Hey guys, so I am getting an EntityDamageByEntity event, and I can get the Damager, but I do not know how to get the Damaged player. Here is some of my code:
    Code:
    @EventHandler
      public void onDamageEvent(EntityDamageByEntityEvent e) {
        //Player p1 = (Player) e.getDamager();
        //Player p2 = (Player) I DONT KNOW HOW TO GET THE DAMAGED PLAYER!
     
        }
    thanks guys! I am making a really cool custom enchantment plugin, and if anyone could help me with this simple thing, my plugin will be 80% done!
     
  2. Offline

    Harmings

    Monkey_Swag
    If (e.getEntity() instanceof Player) {
    Player damaged = (Player) e.getEntity();
    }
     
  3. Offline

    Maurdekye

  4. Offline

    Monkey_Swag

    So....
    If(e.getEntity() instanceof Player) {
    Player damager = (Player) e.getDamager();
    Player damaged = (Player) e.getEntity();
    //Do something
    }
    And that's that? I am about 70% sure it's wrong, so someone please correct me :<
     
Thread Status:
Not open for further replies.

Share This Page