Made negative healing possible.

This commit is contained in:
sk89q 2011-06-26 16:39:41 -07:00
parent 258fbc8870
commit 742b6a2e27

View File

@ -98,7 +98,7 @@ public void run() {
private void processHeal(ApplicableRegionSet applicable, Player player, private void processHeal(ApplicableRegionSet applicable, Player player,
PlayerFlagState state) { PlayerFlagState state) {
if (player.getHealth() >= 20 || player.getHealth() <= 0) { if (player.getHealth() <= 0) {
return; return;
} }
@ -107,15 +107,19 @@ private void processHeal(ApplicableRegionSet applicable, Player player,
Integer healAmount = applicable.getFlag(DefaultFlag.HEAL_AMOUNT); Integer healAmount = applicable.getFlag(DefaultFlag.HEAL_AMOUNT);
Integer healDelay = applicable.getFlag(DefaultFlag.HEAL_DELAY); 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; return;
} }
if (healDelay <= 0) { if (player.getHealth() >= 20 && healAmount > 0) {
return;
}
if (healDelay <= 0 && healAmount > 0) {
player.setHealth(20); player.setHealth(20);
state.lastHeal = now; state.lastHeal = now;
} else if (now - state.lastHeal > healDelay * 1000) { } 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; state.lastHeal = now;
} }
} }