} else {
// unknown
e.setDeathMessage(replacements(config.getString("deathUnknown"), victim));
return;
}
Entity killer = null;
// put this in a try catch incase we get an NPE here
try {
killer = (((EntityDamageByEntityEvent) damev).getDamager());
} catch (Exception ex){
// no killer
}
String message = null;
// check if player died via pvp
if (killer instanceof Player){
message = replacements(config.getString("deathPvP"), victim).replaceAll("%killer%", Nicknames.getNick(((Player) killer).getName()));
}
// check if drowned
if (cause == DamageCause.DROWNING){
message = replacements(config.getString("deathDrown"), victim);
}
// check if they fell
if (cause == DamageCause.FALL){
message = replacements(config.getString("deathFall"), victim);
}
// check if fire
if (cause == DamageCause.FIRE || cause == DamageCause.FIRE_TICK){
message = replacements(config.getString("deathFire"), victim);
}
// check if lava
if (cause == DamageCause.LAVA){
message = replacements(config.getString("deathLava"), victim);
}
// check if magic
if (cause == DamageCause.MAGIC){
message = replacements(config.getString("deathMagic"), victim);
}
// check if starved
if (cause == DamageCause.STARVATION){
message = replacements(config.getString("deathStarvation"), victim);
}
// check if struck by lightning
if (cause == DamageCause.LIGHTNING){
message = replacements(config.getString("deathLightning"), victim);
}
// check if poisoned
if (cause == DamageCause.POISON){
message = replacements(config.getString("deathPoison"), victim);
}
// check if suffocated
if (cause == DamageCause.SUFFOCATION){
message = replacements(config.getString("deathSuffocate"), victim);
}
// check if suicide
if (cause == DamageCause.SUICIDE){
message = replacements(config.getString("deathSuicide"), victim);
}
// check if void
if (cause == DamageCause.VOID){
message = replacements(config.getString("deathVoid"), victim);
}
if ((cause == DamageCause.CONTACT || cause == DamageCause.ENTITY_ATTACK) && !(killer instanceof Player)){
//System.out.println(killer.getType().getName());
message = replacements(config.getString("death" + killer.getType().getName()), victim);
}
// check if explosion
if (cause == DamageCause.BLOCK_EXPLOSION || cause == DamageCause.ENTITY_EXPLOSION){
if (killer != null){
// check if tnt
if (killer.getType() == EntityType.PRIMED_TNT){
message = replacements(config.getString("deathTNT"), victim);
} else if (killer.getType() == EntityType.CREEPER){
message = replacements(config.getString("deathCreeper"), victim);
}
} else {
message = replacements(config.getString("deathOtherExplosion"), victim);
}