Skip to content

Commit 9973d74

Browse files
committed
better handling of /kill
apparently minecraft:kill runs in multiple entity damage events?
1 parent a89b9d6 commit 9973d74

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/lol/hyper/toolstats/events/EntityDamage.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void onDamage(EntityDamageByEntityEvent event) {
4949
if (event.isCancelled()) {
5050
return;
5151
}
52+
5253
if (!(event.getEntity() instanceof LivingEntity)) {
5354
return;
5455
}
@@ -148,6 +149,13 @@ public void onDamage(EntityDamageEvent event) {
148149
if (!(event.getEntity() instanceof LivingEntity)) {
149150
return;
150151
}
152+
153+
// ignore void and /kill damage
154+
EntityDamageEvent.DamageCause cause = event.getCause();
155+
if (cause == EntityDamageEvent.DamageCause.SUICIDE || cause == EntityDamageEvent.DamageCause.VOID) {
156+
return;
157+
}
158+
151159
LivingEntity livingEntity = (LivingEntity) event.getEntity();
152160
// player is taken damage but not being killed
153161
if (livingEntity instanceof Player) {
@@ -171,6 +179,13 @@ public void onDamage(EntityDamageByBlockEvent event) {
171179
if (!(event.getEntity() instanceof LivingEntity)) {
172180
return;
173181
}
182+
183+
// ignore void and /kill damage
184+
EntityDamageEvent.DamageCause cause = event.getCause();
185+
if (cause == EntityDamageEvent.DamageCause.SUICIDE || cause == EntityDamageEvent.DamageCause.VOID) {
186+
return;
187+
}
188+
174189
LivingEntity livingEntity = (LivingEntity) event.getEntity();
175190
// player is taken damage but not being killed
176191
if (livingEntity instanceof Player) {

0 commit comments

Comments
 (0)