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 e0c865681c
commit 463e6dac06
2 changed files with 4 additions and 2 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

@ -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
@@ -0,0 +0,0 @@ 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;
@ -178,6 +178,7 @@ 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