From a6d981de32a11967e9073a6f8530a05c3c5d5dde Mon Sep 17 00:00:00 2001 From: Jedediah Smith 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 2e17397..f0f8cb2 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -208,4 +208,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 16da1c9..b1e63f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -98,11 +98,21 @@ 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); + } + // Paper end + if (entity instanceof EntityPlayer && health == 0) { ((EntityPlayer) entity).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.9.0