mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-08-16 16:37:07 +00:00
Merge pull request #464 from Simplicitee/master
Move armor effects to PassiveHandler
This commit is contained in:
commit
6d515fdf17
|
@ -3,7 +3,6 @@ package com.projectkorra.projectkorra.earthbending;
|
|||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.EarthAbility;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
import com.projectkorra.projectkorra.util.TempPotionEffect;
|
||||
import com.projectkorra.projectkorra.waterbending.PlantArmor;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
@ -12,8 +11,6 @@ import org.bukkit.block.Block;
|
|||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EarthArmor extends EarthAbility {
|
||||
|
@ -98,8 +95,6 @@ public class EarthArmor extends EarthAbility {
|
|||
new ItemStack(Material.LEATHER_CHESTPLATE, 1),
|
||||
new ItemStack(Material.LEATHER_HELMET, 1) };
|
||||
player.getInventory().setArmorContents(armors);
|
||||
PotionEffect resistance = new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, (int) duration / 50, strength - 1);
|
||||
new TempPotionEffect(player, resistance);
|
||||
formed = true;
|
||||
}
|
||||
|
||||
|
@ -208,7 +203,6 @@ public class EarthArmor extends EarthAbility {
|
|||
if (oldArmor != null) {
|
||||
player.getInventory().setArmorContents(oldArmor);
|
||||
}
|
||||
player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,9 @@ import com.projectkorra.projectkorra.airbending.AirPassive;
|
|||
import com.projectkorra.projectkorra.chiblocking.AcrobatStance;
|
||||
import com.projectkorra.projectkorra.chiblocking.ChiPassive;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthArmor;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthPassive;
|
||||
import com.projectkorra.projectkorra.waterbending.PlantArmor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -39,6 +41,52 @@ public class PassiveHandler implements Runnable{
|
|||
}
|
||||
}
|
||||
|
||||
public static void handleArmorPassives() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (ConfigManager.defaultConfig.get().getStringList("Properties.DisabledWorlds").contains(player.getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
|
||||
if (bPlayer == null) continue;
|
||||
if (CoreAbility.hasAbility(player, EarthArmor.class)) {
|
||||
EarthArmor abil = CoreAbility.getAbility(player, EarthArmor.class);
|
||||
int strength = abil.getStrength();
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 3, strength - 1), false);
|
||||
}
|
||||
if (CoreAbility.hasAbility(player, PlantArmor.class)) {
|
||||
PlantArmor abil = CoreAbility.getAbility(player, PlantArmor.class);
|
||||
int strength = abil.getResistance();
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 3, strength - 1), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleExhaustionPassives() {
|
||||
double air = AirPassive.getExhaustionFactor();
|
||||
double chi = ChiPassive.getExhaustionFactor();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (ConfigManager.defaultConfig.get().getStringList("Properties.DisabledWorlds").contains(player.getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
|
||||
if (bPlayer == null) continue;
|
||||
|
||||
if (!bPlayer.hasElement(Element.AIR)) air = 0;
|
||||
if (!bPlayer.hasElement(Element.CHI)) chi = 0;
|
||||
|
||||
double max = Math.max(air, chi);
|
||||
if (max == 0) continue;
|
||||
else {
|
||||
player.setExhaustion(getExhaustion(player, player.getExhaustion(), max));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleSpeedPassives() {
|
||||
int air = AirPassive.getSpeedPower();
|
||||
int chi = ChiPassive.getSpeedPower();
|
||||
|
@ -121,34 +169,11 @@ public class PassiveHandler implements Runnable{
|
|||
}
|
||||
}
|
||||
|
||||
public static void handleExhaustionPassives() {
|
||||
double air = AirPassive.getExhaustionFactor();
|
||||
double chi = ChiPassive.getExhaustionFactor();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (ConfigManager.defaultConfig.get().getStringList("Properties.DisabledWorlds").contains(player.getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
|
||||
if (bPlayer == null) continue;
|
||||
|
||||
if (!bPlayer.hasElement(Element.AIR)) air = 0;
|
||||
if (!bPlayer.hasElement(Element.CHI)) chi = 0;
|
||||
|
||||
double max = Math.max(air, chi);
|
||||
if (max == 0) continue;
|
||||
else {
|
||||
player.setExhaustion(getExhaustion(player, player.getExhaustion(), max));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
handleArmorPassives();
|
||||
handleExhaustionPassives();
|
||||
handleSpeedPassives();
|
||||
handleJumpPassives();
|
||||
handleExhaustionPassives();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ import org.bukkit.block.Block;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -20,7 +18,6 @@ import java.util.Random;
|
|||
public class PlantArmor extends PlantAbility {
|
||||
|
||||
private boolean formed;
|
||||
private boolean hadEffect;
|
||||
private int resistance;
|
||||
private long duration;
|
||||
private long cooldown;
|
||||
|
@ -59,7 +56,6 @@ public class PlantArmor extends PlantAbility {
|
|||
}
|
||||
|
||||
location = block.getLocation();
|
||||
hadEffect = player.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
|
||||
if (!canUse()) {
|
||||
return;
|
||||
}
|
||||
|
@ -102,10 +98,7 @@ public class PlantArmor extends PlantAbility {
|
|||
player.getInventory().setChestplate(chestplate);
|
||||
player.getInventory().setLeggings(leggings);
|
||||
player.getInventory().setBoots(boots);
|
||||
|
||||
if (!hadEffect) {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 1000000, resistance - 1));
|
||||
}
|
||||
|
||||
formed = true;
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -155,9 +148,6 @@ public class PlantArmor extends PlantAbility {
|
|||
|
||||
if (oldArmor != null) {
|
||||
player.getInventory().setArmorContents(oldArmor);
|
||||
if (!hadEffect) {
|
||||
player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
if (plantbending != null) {
|
||||
|
@ -187,10 +177,6 @@ public class PlantArmor extends PlantAbility {
|
|||
|
||||
public void setResistance(int resistance) {
|
||||
this.resistance = resistance;
|
||||
if (!hadEffect) {
|
||||
player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 1000000, resistance - 1));
|
||||
}
|
||||
}
|
||||
|
||||
public int getResistance() {
|
||||
|
@ -225,14 +211,6 @@ public class PlantArmor extends PlantAbility {
|
|||
this.formed = formed;
|
||||
}
|
||||
|
||||
public boolean isHadEffect() {
|
||||
return hadEffect;
|
||||
}
|
||||
|
||||
public void setHadEffect(boolean hadEffect) {
|
||||
this.hadEffect = hadEffect;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue