From 0009e6363a1de0bebc126d9a3e6d16add7ddb78b Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Sun, 21 Jul 2019 23:45:50 +0200 Subject: [PATCH] Use GENERIC_MAX_HEALTH in MASpawnThread. setMaxHealth() and getMaxHealth() are deprecated. Partial fix for #406 --- .../java/com/garbagemule/MobArena/MASpawnThread.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/garbagemule/MobArena/MASpawnThread.java b/src/main/java/com/garbagemule/MobArena/MASpawnThread.java index 34a4b69..2730933 100644 --- a/src/main/java/com/garbagemule/MobArena/MASpawnThread.java +++ b/src/main/java/com/garbagemule/MobArena/MASpawnThread.java @@ -19,6 +19,7 @@ import com.garbagemule.MobArena.waves.types.UpgradeWave; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.attribute.Attribute; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -227,10 +228,9 @@ public class MASpawnThread implements Runnable monsterManager.addMonster(e); // Set the health. - e.resetMaxHealth(); // Avoid conflicts/enormous multiplications from other plugins handling Mob health - int health = (int) Math.max(1D, e.getMaxHealth() * mul); + int health = (int) Math.max(1D, e.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() * mul); try { - e.setMaxHealth(health); + e.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(health); e.setHealth(health); } catch (IllegalArgumentException ex) { // Spigot... *facepalm* @@ -263,9 +263,9 @@ public class MASpawnThread implements Runnable } break; case SWARM: - health = (int) (mul < 1D ? e.getMaxHealth() * mul : 1); + health = (int) (mul < 1D ? e.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() * mul : 1); health = Math.max(1, health); - e.setHealth(Math.min(health, e.getMaxHealth())); + e.setHealth(Math.min(health, e.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())); break; case SUPPLY: SupplyWave sw = (SupplyWave) w;