Fixed ClassCastException caused by wrong entity logics

This commit is contained in:
t3hk0d3 2011-08-02 17:41:38 +04:00
parent 1a056e7fc6
commit 22a4ef1827

View File

@ -73,24 +73,26 @@ public class EntityListener extends ModifyworldListener {
}
}
player = (Player) edbe.getEntity();
if (edbe.getEntity() instanceof Player && edbe.getDamager() != null) { // Prevent from taking damage by player
if (!canMessWithEntity(player, "modifyworld.damage.take.", edbe.getDamager())) {
cancelDamageEvent(player, event);
return;
if (edbe.getEntity() instanceof Player) {
player = (Player) edbe.getEntity();
if (edbe.getDamager() != null) { // Prevent from taking damage by entity
if (!canMessWithEntity(player, "modifyworld.damage.take.", edbe.getDamager())) {
cancelDamageEvent(player, event);
return;
}
}
if (edbe instanceof EntityDamageByProjectileEvent && edbe.getDamager() == null) { // Prevent damage taken from dipenser projectile
EntityDamageByProjectileEvent edpe = (EntityDamageByProjectileEvent) edbe;
if (!canMessWithEntity(player, "modifyworld.damage.take.", edpe.getProjectile())) {
cancelDamageEvent(player, event);
return;
}
}
}
if (edbe instanceof EntityDamageByProjectileEvent && edbe.getDamager() == null){
EntityDamageByProjectileEvent edpe = (EntityDamageByProjectileEvent)edbe;
if (!canMessWithEntity(player, "modifyworld.damage.take.", edpe.getProjectile())) {
cancelDamageEvent(player, event);
return;
}
}
} else if (event.getEntity() instanceof Player) { // player are been damaged by enviroment
Player player = (Player) event.getEntity();