Skip to content

Commit

Permalink
Fixed zombies killed by wither roses not being logged when skip-gener…
Browse files Browse the repository at this point in the history
…ic-data is enabled (fixes #309)
  • Loading branch information
Intelli committed Jan 5, 2024
1 parent c91f460 commit 15e8cd5
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.coreprotect.listener.entity;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -121,8 +122,11 @@ protected static void logEntityDeath(LivingEntity entity, String e) {
e = isCommand ? "#command" : "";
}

List<DamageCause> validDamageCauses = Arrays.asList(DamageCause.KILL, DamageCause.POISON, DamageCause.THORNS, DamageCause.MAGIC, DamageCause.WITHER);

boolean skip = true;
if (!Config.getConfig(entity.getWorld()).SKIP_GENERIC_DATA || (!(entity instanceof Zombie) && !(entity instanceof Skeleton))) {
EntityDamageEvent.DamageCause cause = damage.getCause();
if (!Config.getConfig(entity.getWorld()).SKIP_GENERIC_DATA || (!(entity instanceof Zombie) && !(entity instanceof Skeleton)) || validDamageCauses.contains(cause)) {
skip = false;
}

Expand Down Expand Up @@ -171,7 +175,6 @@ else if (attacker.getType().name() != null) {
}
}
else {
EntityDamageEvent.DamageCause cause = damage.getCause();
if (cause.equals(EntityDamageEvent.DamageCause.FIRE)) {
e = "#fire";
}
Expand All @@ -189,6 +192,9 @@ else if (cause.equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) {
else if (cause.equals(EntityDamageEvent.DamageCause.MAGIC)) {
e = "#magic";
}
else if (cause.equals(EntityDamageEvent.DamageCause.WITHER)) {
e = "#wither_effect";
}
}

if (entity instanceof ArmorStand) {
Expand Down Expand Up @@ -224,7 +230,7 @@ else if (entity instanceof Player) {
}
}

if (e.startsWith("#wither")) {
if (e.startsWith("#wither") && !e.equals("#wither_effect")) {
e = "#wither";
}

Expand Down

0 comments on commit 15e8cd5

Please sign in to comment.