Ensure entity is always dying before Death Event

Prior to this it was possible for plugins to put the server into a never
ending recursive loop until it eventually killed itself.

Fixes GH-1432
This commit is contained in:
Zach Brown 2018-09-11 17:38:57 -04:00
parent 6793fee387
commit b380338244
No known key found for this signature in database
GPG key ID: CC9DA35FC5450B76
2 changed files with 9 additions and 7 deletions

1
.gitignore vendored
View file

@ -34,6 +34,7 @@ work/Spigot-Server
work/Spigot-API
work/*.jar
work/test-server
work/ForgeFlower
# Mac filesystem dust
.DS_Store/

View file

@ -1,4 +1,4 @@
From b8c6e5d80cd3b21db5b3d9a031439d37143eb467 Mon Sep 17 00:00:00 2001
From 61dddacb42c358d24f53ae3a28e5a49eca53d271 Mon Sep 17 00:00:00 2001
From: Phoenix616 <mail@moep.tv>
Date: Tue, 21 Aug 2018 01:39:35 +0100
Subject: [PATCH] Improve death events
@ -69,7 +69,7 @@ index dca497072..454c1e7d0 100644
}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 14637be49..dec4b442c 100644
index 14637be49..5ccd3ea6f 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -75,14 +75,14 @@ public abstract class EntityLiving extends Entity {
@ -140,7 +140,7 @@ index 14637be49..dec4b442c 100644
- this.aU = true;
- this.getCombatTracker().g();
+ //this.aU = true;
+ this.aU = true; // Paper - Always set at start, unset later if cancelled - GH-1432
+ //this.getCombatTracker().g();
+
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = null;
@ -148,7 +148,7 @@ index 14637be49..dec4b442c 100644
if (!this.world.isClientSide) {
int i = 0;
@@ -1136,15 +1145,32 @@ public abstract class EntityLiving extends Entity {
@@ -1136,15 +1145,33 @@ public abstract class EntityLiving extends Entity {
this.a(flag, i, damagesource);
// CraftBukkit start - Call death event
@ -178,13 +178,14 @@ index 14637be49..dec4b442c 100644
+ this.setDying(true);
+ this.world.broadcastEntityEffect(this, (byte) 3);
+ } else {
+ this.setDying(false); // Paper - reset if cancelled
+ this.setHealth((float) deathEvent.getReviveHealth());
+ }
+ // Paper end
}
}
@@ -1198,6 +1224,7 @@ public abstract class EntityLiving extends Entity {
@@ -1198,6 +1225,7 @@ public abstract class EntityLiving extends Entity {
return SoundEffects.bX;
}
@ -192,7 +193,7 @@ index 14637be49..dec4b442c 100644
@Nullable
protected SoundEffect cf() {
return SoundEffects.bS;
@@ -1583,10 +1610,12 @@ public abstract class EntityLiving extends Entity {
@@ -1583,10 +1611,12 @@ public abstract class EntityLiving extends Entity {
}
@ -412,5 +413,5 @@ index cce4acc0b..f1a3ca950 100644
* Server methods
*/
--
2.18.0.windows.1
2.19.0