mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-28 05:25:20 +01:00
Made negative healing possible.
This commit is contained in:
parent
258fbc8870
commit
742b6a2e27
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user