How to get a killer with custom snowball?

Discussion in 'Plugin Development' started by AdityaTD, Jul 30, 2015.

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

    AdityaTD

    So I made so the snowball damages the players but how can I get a killer via the snowball??

    Here's my code for damage, Idk how to get killer via the custom snowball hit.

    Code:
        @EventHandler(priority=EventPriority.HIGH)
        public void onSnowBall(EntityDamageByEntityEvent event) {
            if(event.getDamager() instanceof Snowball && event.getEntity() instanceof Player){
                Player player = (Player) event.getEntity();
                player.damage(2);
            }
        }
     
  2. Check if damager is a Snowball, then cast the damager to Snowball (or Projectile) and check if .getShooter() is an instance of Player then cast .getShooter() to player and you have the killer.

    Ps: use EntityDeathEvent
     
  3. Offline

    AdityaTD

    ok thanks man! :D
     
Thread Status:
Not open for further replies.

Share This Page