EntityDamageByEntityEvent help

Discussion in 'Plugin Development' started by BlazingBroGamer, Apr 22, 2014.

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

    BlazingBroGamer

    So I have been looking around for a while, and I couldn't seem to find a way to get the damager of the entity. So far, I have done this code:
    Code:
        @EventHandler
        public void onPlayerDamage(EntityDamageByEntityEvent e){
            if(e.getEntity() instanceof Player)
            if(firstKill == false){
                Player p = (Player) e.getEntity();
                if(p.getHealthScale() <= 0){
                    p.setHealth(20.0);
                    p.setFlying(true);
                    
                    p.sendMessage(ChatColor.AQUA + "[GSG]");
                }
    }
    And I cant seem to fix the problem. I want the player to not die in this game, so I used EntityDamageByEntityEvent, instead of PlayerDeathEvent. Any help will be appriciated :D

    Nevermind.. I think I found the solution... It is p.getLastDamageCause().getEntity();

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    itzrobotix

    e.getDamager();
    e = event/event variable
     
Thread Status:
Not open for further replies.

Share This Page