From 742b6a2e2799aaed7886607e9f1c725f74d62a10 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 26 Jun 2011 16:39:41 -0700 Subject: [PATCH] Made negative healing possible. --- .../sk89q/worldguard/bukkit/FlagStateManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java index b0bbb505..94cac2d0 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java @@ -98,7 +98,7 @@ public void run() { private void processHeal(ApplicableRegionSet applicable, Player player, PlayerFlagState state) { - if (player.getHealth() >= 20 || player.getHealth() <= 0) { + if (player.getHealth() <= 0) { return; } @@ -107,15 +107,19 @@ private void processHeal(ApplicableRegionSet applicable, Player player, Integer healAmount = applicable.getFlag(DefaultFlag.HEAL_AMOUNT); Integer healDelay = applicable.getFlag(DefaultFlag.HEAL_DELAY); - if (healAmount == null || healDelay == null || healAmount < 1 || healDelay < 0) { + if (healAmount == null || healDelay == null || healAmount == 0 || healDelay < 0) { + return; + } + + if (player.getHealth() >= 20 && healAmount > 0) { return; } - if (healDelay <= 0) { + if (healDelay <= 0 && healAmount > 0) { player.setHealth(20); state.lastHeal = now; } else if (now - state.lastHeal > healDelay * 1000) { - player.setHealth(Math.min(20, player.getHealth() + healAmount)); + player.setHealth(Math.min(20, Math.max(0, player.getHealth() + healAmount))); state.lastHeal = now; } }