better handling of /kill

apparently minecraft:kill runs in multiple entity damage events?
This commit is contained in:
hyperdefined
2022-08-19 18:27:34 -04:00
parent a89b9d6f6a
commit 9973d743a5

View File

@@ -49,6 +49,7 @@ public class EntityDamage implements Listener {
if (event.isCancelled()) {
return;
}
if (!(event.getEntity() instanceof LivingEntity)) {
return;
}
@@ -148,6 +149,13 @@ public class EntityDamage implements Listener {
if (!(event.getEntity() instanceof LivingEntity)) {
return;
}
// ignore void and /kill damage
EntityDamageEvent.DamageCause cause = event.getCause();
if (cause == EntityDamageEvent.DamageCause.SUICIDE || cause == EntityDamageEvent.DamageCause.VOID) {
return;
}
LivingEntity livingEntity = (LivingEntity) event.getEntity();
// player is taken damage but not being killed
if (livingEntity instanceof Player) {
@@ -171,6 +179,13 @@ public class EntityDamage implements Listener {
if (!(event.getEntity() instanceof LivingEntity)) {
return;
}
// ignore void and /kill damage
EntityDamageEvent.DamageCause cause = event.getCause();
if (cause == EntityDamageEvent.DamageCause.SUICIDE || cause == EntityDamageEvent.DamageCause.VOID) {
return;
}
LivingEntity livingEntity = (LivingEntity) event.getEntity();
// player is taken damage but not being killed
if (livingEntity instanceof Player) {