Merge remote-tracking branch 'refs/remotes/ProjectKorra/master'

This commit is contained in:
Benford 2016-03-23 20:27:47 -04:00
commit dd461e54d1
5 changed files with 78 additions and 29 deletions

View file

@ -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");
}
}

View file

@ -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));
}
}
}

View file

@ -98,6 +98,13 @@ public class AddCommand extends PKCommand {
return;
}
bPlayer.addElement(e);
for (SubElement sub : Element.getAllSubElements()) {
if (sub.getParentElement() == e && bPlayer.hasSubElementPermission(sub)) {
bPlayer.addSubElement(sub);
}
}
ChatColor color = e.getColor();
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
@ -106,6 +113,7 @@ public class AddCommand extends PKCommand {
target.sendMessage(color + added.replace("{element}", e.getName() + e.getType().getBender()));
}
GeneralMethods.saveElements(bPlayer);
GeneralMethods.saveSubElements(bPlayer);
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, e, Result.ADD));
return;
} else if (Arrays.asList(Element.getAllSubElements()).contains(e)) {

View file

@ -138,6 +138,7 @@ public class ChooseCommand extends PKCommand {
target.sendMessage(color + chosen.replace("{element}", element.getName() + element.getType().getBender()));
}
GeneralMethods.saveElements(bPlayer);
GeneralMethods.saveSubElements(bPlayer);
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE));
}

View file

@ -18,6 +18,7 @@ public class EarthbendingManager implements Runnable {
EarthPassive.handleMetalPassives();
EarthPassive.sandSpeed();
RevertChecker.revertEarthBlocks();
Shockwave.progressAll();
Tremorsense.manage(Bukkit.getServer());
}
}