2017-01-07 06:28:21 +00:00
|
|
|
package com.projectkorra.projectkorra.chiblocking.passive;
|
2015-08-02 06:58:35 +00:00
|
|
|
|
2017-08-06 07:18:12 +00:00
|
|
|
import org.bukkit.Sound;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
|
2015-08-02 06:58:35 +00:00
|
|
|
import com.projectkorra.projectkorra.BendingPlayer;
|
2017-08-06 07:18:12 +00:00
|
|
|
import com.projectkorra.projectkorra.Element;
|
2015-08-02 06:58:35 +00:00
|
|
|
import com.projectkorra.projectkorra.ProjectKorra;
|
2016-01-13 21:14:34 +00:00
|
|
|
import com.projectkorra.projectkorra.ability.ChiAbility;
|
|
|
|
import com.projectkorra.projectkorra.ability.CoreAbility;
|
2015-08-02 06:58:35 +00:00
|
|
|
import com.projectkorra.projectkorra.airbending.Suffocate;
|
2017-01-07 06:28:21 +00:00
|
|
|
import com.projectkorra.projectkorra.chiblocking.AcrobatStance;
|
|
|
|
import com.projectkorra.projectkorra.chiblocking.QuickStrike;
|
|
|
|
import com.projectkorra.projectkorra.chiblocking.SwiftKick;
|
2016-01-13 21:14:34 +00:00
|
|
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
2017-08-06 07:18:12 +00:00
|
|
|
import com.projectkorra.projectkorra.util.ActionBar;
|
2015-08-02 06:58:35 +00:00
|
|
|
|
|
|
|
public class ChiPassive {
|
|
|
|
|
|
|
|
public static boolean willChiBlock(Player attacker, Player player) {
|
2016-01-13 21:14:34 +00:00
|
|
|
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
|
|
|
if (bPlayer == null) {
|
|
|
|
return false;
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
2017-01-16 06:48:20 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
ChiAbility stance = bPlayer.getStance();
|
|
|
|
QuickStrike quickStrike = CoreAbility.getAbility(player, QuickStrike.class);
|
|
|
|
SwiftKick swiftKick = CoreAbility.getAbility(player, SwiftKick.class);
|
2017-08-06 07:18:12 +00:00
|
|
|
double newChance = getChance();
|
2017-01-16 06:48:20 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
if (stance != null && stance instanceof AcrobatStance) {
|
2017-08-06 07:18:12 +00:00
|
|
|
newChance += ((AcrobatStance) stance).getChiBlockBoost();
|
2015-11-15 22:52:45 +00:00
|
|
|
}
|
2017-01-16 06:48:20 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
if (quickStrike != null) {
|
2017-08-06 07:18:12 +00:00
|
|
|
newChance += quickStrike.getBlockChance();
|
2016-01-13 21:14:34 +00:00
|
|
|
} else if (swiftKick != null) {
|
2017-08-06 07:18:12 +00:00
|
|
|
newChance += swiftKick.getBlockChance();
|
2015-11-15 22:52:45 +00:00
|
|
|
}
|
2017-01-16 06:48:20 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
if (Math.random() > newChance / 100.0) {
|
2015-08-02 06:58:35 +00:00
|
|
|
return false;
|
2016-01-13 21:14:34 +00:00
|
|
|
} else if (bPlayer.isChiBlocked()) {
|
2015-08-02 06:58:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void blockChi(final Player player) {
|
|
|
|
if (Suffocate.isChannelingSphere(player)) {
|
|
|
|
Suffocate.remove(player);
|
|
|
|
}
|
2017-01-16 06:48:20 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
|
|
|
if (bPlayer == null) {
|
2015-08-02 06:58:35 +00:00
|
|
|
return;
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
2015-08-02 06:58:35 +00:00
|
|
|
bPlayer.blockChi();
|
2017-08-06 07:18:12 +00:00
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_HURT, 2, 0);
|
|
|
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
new BukkitRunnable() {
|
2016-01-13 21:14:34 +00:00
|
|
|
@Override
|
2015-08-02 06:58:35 +00:00
|
|
|
public void run() {
|
2017-08-06 07:18:12 +00:00
|
|
|
ActionBar.sendActionBar(Element.CHI.getColor() + "* Chiblocked *", player);
|
|
|
|
if (System.currentTimeMillis() >= start + getDuration()) {
|
|
|
|
bPlayer.unblockChi();
|
|
|
|
cancel();
|
|
|
|
}
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
2017-08-06 07:18:12 +00:00
|
|
|
}.runTaskTimer(ProjectKorra.plugin, 0, 1);
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
2016-03-29 05:46:39 +00:00
|
|
|
public static double getExhaustionFactor() {
|
2017-01-06 04:02:32 +00:00
|
|
|
return ConfigManager.getConfig().getDouble("Abilities.Chi.Passive.ChiSaturation.ExhaustionFactor");
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
2017-01-16 06:48:20 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
public static double getFallReductionFactor() {
|
2017-01-06 04:02:32 +00:00
|
|
|
return ConfigManager.getConfig().getDouble("Abilities.Chi.Passive.Acrobatics.FallReductionFactor");
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static int getJumpPower() {
|
2017-01-06 04:02:32 +00:00
|
|
|
return ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.JumpPower");
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static int getSpeedPower() {
|
2017-01-06 04:02:32 +00:00
|
|
|
return ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.SpeedPower");
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static double getChance() {
|
|
|
|
return ConfigManager.getConfig().getDouble("Abilities.Chi.Passive.BlockChi.Chance");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getDuration() {
|
|
|
|
return ConfigManager.getConfig().getInt("Abilities.Chi.Passive.BlockChi.Duration");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static long getTicks() {
|
|
|
|
return (getDuration() / 1000) * 20;
|
|
|
|
}
|
|
|
|
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|