DeathEvent check

Discussion in 'Spigot Plugin Development' started by Ayresy, May 23, 2015.

  1. Code (Text):
        @EventHandler
        public void onDeath(PlayerDeathEvent e)
        {
            if(e.getEntity() instanceof Player){
            Player p = e.getEntity();
            Player k = p.getKiller();
          for (ItemStack it : p.getKiller().getInventory().addItem(new ItemStack[] { item(e.getEntity().getName(), e.getEntity().getKiller().getName()) }).values()) {
            e.getDrops().add(it);
    it gives off an error when a play dies via fall mob, lava etc. how would i check if a player died by lava(mob etc) so it doesn't error
     
  2. It was a noob mistake all i had to do is check if the entity was a player and the killer was a player