From a5f7b37face918c0b813f91b2d837818f7afe6de Mon Sep 17 00:00:00 2001 From: William Date: Tue, 7 Jun 2022 20:59:59 +0100 Subject: [PATCH] Fix incompatibility with custom health scalars, close #25 --- .../net/william278/husksync/bukkit/util/PlayerSetter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bukkit/src/main/java/net/william278/husksync/bukkit/util/PlayerSetter.java b/bukkit/src/main/java/net/william278/husksync/bukkit/util/PlayerSetter.java index ec819ed6..d0dbe3f2 100644 --- a/bukkit/src/main/java/net/william278/husksync/bukkit/util/PlayerSetter.java +++ b/bukkit/src/main/java/net/william278/husksync/bukkit/util/PlayerSetter.java @@ -464,12 +464,13 @@ public class PlayerSetter { */ private static void setPlayerHealth(Player player, double health, double maxHealth, double healthScale) { // Set max health - if (maxHealth != 0.0D) { + if (maxHealth != 0D) { Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).setBaseValue(maxHealth); } // Set health - player.setHealth(player.getHealth() > maxHealth ? maxHealth : health); + double currentHealth = player.getHealth(); + if (health != currentHealth) player.setHealth(currentHealth > maxHealth ? maxHealth : health); // Set health scaling if needed if (healthScale != 0D) {