aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0081-Set-health-before-death-event.patch
blob: a13a53007b9286c9c6195ea0b508f2f3a4f82206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From 62f9ecf769955dd17317af05db2280aa386940e0 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Sun, 19 Jul 2015 16:51:38 -0400
Subject: [PATCH] Set health before death event


diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 078e0d989..a48f5cb51 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -214,4 +214,9 @@ public class PaperConfig {
     private static void loadPermsBeforePlugins() {
         loadPermsBeforePlugins = getBoolean("settings.load-permissions-yml-before-plugins", true);
     }
+
+    public static boolean setHealthBeforeDeathEvent = false;
+    private static void healthDeath() {
+        setHealthBeforeDeathEvent = getBoolean("settings.set-health-before-death-event", false);
+    }
 }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 348a8c758..c0103cb39 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -102,11 +102,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
                     + (this instanceof CraftPlayer ? ", player: " + this.getName() + ')' : ')'));
         }
 
+        // Paper start
+        if (com.destroystokyo.paper.PaperConfig.setHealthBeforeDeathEvent) {
+            this.getHandle().setHealth((float) health);
+        }
+        
         if (health == 0) {
             getHandle().die(DamageSource.GENERIC);
         }
 
-        getHandle().setHealth((float) health);
+        // Paper start - wrap, see above
+        if (!com.destroystokyo.paper.PaperConfig.setHealthBeforeDeathEvent) {
+            getHandle().setHealth((float) health);
+        }
+        // Paper end
     }
 
     public double getMaxHealth() {
-- 
2.12.0.windows.1