diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/HealthRegenTimerTask.java b/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/HealthRegenTimerTask.java index 065f2f8b1d..198b41a54a 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/HealthRegenTimerTask.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/HealthRegenTimerTask.java @@ -6,8 +6,8 @@ import com.palmergames.bukkit.towny.object.TownBlock; import org.bukkit.NamespacedKey; +import org.bukkit.Registry; import org.bukkit.Server; -import org.bukkit.attribute.Attribute; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; @@ -16,7 +16,6 @@ import com.palmergames.bukkit.towny.TownyAPI; import com.palmergames.bukkit.towny.object.TownBlockType; import com.palmergames.bukkit.towny.utils.CombatUtil; -import com.palmergames.bukkit.towny.utils.MinecraftVersion; import com.palmergames.bukkit.util.BukkitTools; public class HealthRegenTimerTask extends TownyTimerTask { @@ -78,7 +77,7 @@ private void evaluateHealth(Player player) { // Heal 1 HP while in town. final double currentHP = player.getHealth(); final double futureHP = currentHP + 1; - final double maxHP = player.getAttribute(getMaxHealthAttribute()).getValue(); + final double maxHP = player.getAttribute(Registry.ATTRIBUTE.getOrThrow(NamespacedKey.minecraft("max_health"))).getValue(); // Shrink gained to fit below the maxHP. final double gained = futureHP > maxHP ? 1.0 - (futureHP - maxHP) : 1.0; @@ -96,12 +95,4 @@ private void tryIncreaseHealth(Player player, double currentHealth, double maxHe player.setHealth(Math.min(maxHealth, event.getAmount() + currentHealth)); } - - @SuppressWarnings("deprecation") - private Attribute getMaxHealthAttribute() { - if (MinecraftVersion.CURRENT_VERSION.isNewerThanOrEquals(MinecraftVersion.MINECRAFT_1_21_3)) - return Attribute.MAX_HEALTH; - else - return Attribute.valueOf("GENERIC_MAX_HEALTH"); - } }