Merge pull request #452 from grasshopperMatt/master

Fixed passives
This commit is contained in:
OmniCypher 2016-03-19 19:44:57 -07:00
commit 33c291236c
2 changed files with 68 additions and 29 deletions

View file

@ -1,16 +1,16 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import com.projectkorra.projectkorra.BendingPlayer; import java.util.concurrent.ConcurrentHashMap;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; 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 { public class AirPassive {
@ -25,7 +25,7 @@ public class AirPassive {
if (level < oldlevel) { if (level < oldlevel) {
level = 0; level = 0;
} else { } else {
double factor = getFactor(); double factor = getFactor();
level = (float) ((level - oldlevel) * factor + oldlevel); level = (float) ((level - oldlevel) * factor + oldlevel);
} }
FOOD.replace(player, level); FOOD.replace(player, level);
@ -34,31 +34,52 @@ public class AirPassive {
} }
public static void handlePassive() { public static void handlePassive() {
for (World world : Bukkit.getServer().getWorlds()) { int speedPower = 0;
for (Player player : world.getPlayers()) { int jumpPower = 0;
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (!player.isOnline() || bPlayer == null) { for (Player player : Bukkit.getOnlinePlayers()) {
return; 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)) { if (player.isSprinting()) {
player.setExhaustion(getExhaustion(player, player.getExhaustion())); if (!player.hasPotionEffect(PotionEffectType.SPEED)) {
if (player.isSprinting()) { player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speedPower));
if (!player.hasPotionEffect(PotionEffectType.SPEED)) { }
int speedPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.Speed"); if (!player.hasPotionEffect(PotionEffectType.JUMP)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speedPower - 1)); player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jumpPower));
}
if (!player.hasPotionEffect(PotionEffectType.JUMP)) {
int jumpPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.Jump");
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jumpPower - 1));
}
} }
} }
} }
} }
} }
public static double getFactor() { public static double getFactor() {
return ConfigManager.getConfig().getDouble("Abilities.Air.Passive.Factor"); 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");
}
} }

View file

@ -5,6 +5,7 @@ import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.airbending.AirPassive;
import com.projectkorra.projectkorra.airbending.Suffocate; import com.projectkorra.projectkorra.airbending.Suffocate;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
@ -64,20 +65,37 @@ public class ChiPassive {
} }
public static void handlePassive() { public static void handlePassive() {
int speedPower = 0;
int jumpPower = 0;
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) { if (bPlayer == null) {
continue; 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. if (bPlayer.canBendPassive(Element.CHI)) {
ChiAbility stance = bPlayer.getStance(); if (bPlayer.canBendPassive(Element.AIR)) {
if (player.isSprinting() && !(stance instanceof AcrobatStance)) { if (AirPassive.getJumpPower() > getJumpPower()) {
if (!player.hasPotionEffect(PotionEffectType.JUMP)) { jumpPower = AirPassive.getJumpPower();
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, 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)) { 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));
} }
} }
} }