diff --git a/src/com/projectkorra/projectkorra/airbending/AirPassive.java b/src/com/projectkorra/projectkorra/airbending/AirPassive.java index 36a106d2..eca629af 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirPassive.java +++ b/src/com/projectkorra/projectkorra/airbending/AirPassive.java @@ -1,16 +1,16 @@ package com.projectkorra.projectkorra.airbending; -import com.projectkorra.projectkorra.BendingPlayer; -import com.projectkorra.projectkorra.Element; -import com.projectkorra.projectkorra.configuration.ConfigManager; +import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; -import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.util.concurrent.ConcurrentHashMap; +import com.projectkorra.projectkorra.BendingPlayer; +import com.projectkorra.projectkorra.Element; +import com.projectkorra.projectkorra.chiblocking.ChiPassive; +import com.projectkorra.projectkorra.configuration.ConfigManager; public class AirPassive { @@ -25,7 +25,7 @@ public class AirPassive { if (level < oldlevel) { level = 0; } else { - double factor = getFactor(); + double factor = getFactor(); level = (float) ((level - oldlevel) * factor + oldlevel); } FOOD.replace(player, level); @@ -34,31 +34,52 @@ public class AirPassive { } public static void handlePassive() { - for (World world : Bukkit.getServer().getWorlds()) { - for (Player player : world.getPlayers()) { - BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - if (!player.isOnline() || bPlayer == null) { - return; + int speedPower = 0; + int jumpPower = 0; + + for (Player player : Bukkit.getOnlinePlayers()) { + BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); + if (bPlayer == null) { + continue; + } + + if (bPlayer.canBendPassive(Element.AIR)) { + if (bPlayer.canBendPassive(Element.CHI)) { + if (ChiPassive.getJumpPower() > getJumpPower()) { + jumpPower = ChiPassive.getJumpPower(); + } else { + jumpPower = getJumpPower(); + } + + if (ChiPassive.getSpeedPower() > getSpeedPower()) { + speedPower = ChiPassive.getSpeedPower(); + } else { + speedPower = getSpeedPower(); + } } + player.setExhaustion(getExhaustion(player, player.getExhaustion())); - if (bPlayer.canBendPassive(Element.AIR)) { - player.setExhaustion(getExhaustion(player, player.getExhaustion())); - if (player.isSprinting()) { - if (!player.hasPotionEffect(PotionEffectType.SPEED)) { - int speedPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.Speed"); - player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speedPower - 1)); - } - if (!player.hasPotionEffect(PotionEffectType.JUMP)) { - int jumpPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.Jump"); - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jumpPower - 1)); - } + if (player.isSprinting()) { + if (!player.hasPotionEffect(PotionEffectType.SPEED)) { + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speedPower)); + } + if (!player.hasPotionEffect(PotionEffectType.JUMP)) { + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jumpPower)); } } } } } - + public static double getFactor() { return ConfigManager.getConfig().getDouble("Abilities.Air.Passive.Factor"); } + + public static int getJumpPower() { + return ConfigManager.getConfig().getInt("Abilities.Air.Passive.Jump"); + } + + public static int getSpeedPower() { + return ConfigManager.getConfig().getInt("Abilities.Air.Passive.Speed"); + } } diff --git a/src/com/projectkorra/projectkorra/chiblocking/ChiPassive.java b/src/com/projectkorra/projectkorra/chiblocking/ChiPassive.java index 5ce33b04..8a49bce0 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/ChiPassive.java +++ b/src/com/projectkorra/projectkorra/chiblocking/ChiPassive.java @@ -5,6 +5,7 @@ import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.CoreAbility; +import com.projectkorra.projectkorra.airbending.AirPassive; import com.projectkorra.projectkorra.airbending.Suffocate; import com.projectkorra.projectkorra.configuration.ConfigManager; @@ -64,20 +65,37 @@ public class ChiPassive { } public static void handlePassive() { + int speedPower = 0; + int jumpPower = 0; + for (Player player : Bukkit.getOnlinePlayers()) { BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); if (bPlayer == null) { continue; } - if (bPlayer.canBendPassive(Element.CHI) && !bPlayer.canBendPassive(Element.AIR)) { // If they're an airbender and gets the boosts we want to give them that instead of the Chi. - ChiAbility stance = bPlayer.getStance(); - if (player.isSprinting() && !(stance instanceof AcrobatStance)) { - if (!player.hasPotionEffect(PotionEffectType.JUMP)) { - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, getJumpPower())); + if (bPlayer.canBendPassive(Element.CHI)) { + if (bPlayer.canBendPassive(Element.AIR)) { + if (AirPassive.getJumpPower() > getJumpPower()) { + jumpPower = AirPassive.getJumpPower(); + } else { + jumpPower = getJumpPower(); } + + if (AirPassive.getSpeedPower() > getSpeedPower()) { + speedPower = AirPassive.getSpeedPower(); + } else { + speedPower = getSpeedPower(); + } + } + ChiAbility stance = bPlayer.getStance(); + + if (player.isSprinting() && !(stance instanceof AcrobatStance)) { if (!player.hasPotionEffect(PotionEffectType.SPEED)) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, getSpeedPower())); + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speedPower)); + } + if (!player.hasPotionEffect(PotionEffectType.JUMP)) { + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jumpPower)); } } }