Skip to content

Commit

Permalink
EntityDeathListener: Added handling for pushing into void, improved u…
Browse files Browse the repository at this point in the history
…nknown message for EntityDamageByBlockEvent
  • Loading branch information
mindsolve committed May 13, 2021
1 parent 13d2238 commit 3bb0f86
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ public void onEntityDeath(EntityDeathEvent event) {
deathMessage.append(getPetTextComponent((Tameable) deadEntity).create());
}

deathMessage.append(" was killed by player ").color(DARK_GRAY).append(killerPlayer.getDisplayName()).color(DARK_PURPLE);
deathMessage
.append(" was killed by player ")
.color(DARK_GRAY)
.append(killerPlayer.getDisplayName())
.color(DARK_PURPLE)
.append("")
.color(DARK_GRAY);

if (deadEntity.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
Entity damager = ((EntityDamageByEntityEvent) deadEntity.getLastDamageCause()).getDamager();
Expand Down Expand Up @@ -283,7 +289,16 @@ public void onEntityDeath(EntityDeathEvent event) {
}

} else if (deadEntity.getLastDamageCause() instanceof EntityDamageByBlockEvent) {
deathMessage.append(" (How the heck did you do this? Event (block): " + ((EntityDamageByBlockEvent) deadEntity.getLastDamageCause()).getDamager().getType() + ")").color(DARK_RED);
EntityDamageByBlockEvent cause = ((EntityDamageByBlockEvent) deadEntity.getLastDamageCause());
if (cause.getCause() == EntityDamageEvent.DamageCause.VOID) {
deathMessage
.append(" by pushing it into")
.append(" the VOID").color(BLACK).bold(true)
.append("").reset().color(DARK_GRAY);
} else {
deathMessage.append(" (How the heck did you do this? Event (block): " +
"Cause:" + cause + "; Damager:" + cause.getDamager() + ")").color(DARK_RED);
}

} else if (deadEntity.getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.MAGIC) {
// Might be an Arrow of Harming (I / II). Either we assume that here, or we ignore it
Expand Down

0 comments on commit 3bb0f86

Please sign in to comment.