Passive fixes (#708)

* Passive fixes

* Fixed Air & Chi Saturation not being toggled with /b t

* Renamed Hodor to FerroControl
This commit is contained in:
Sobki 2017-01-24 17:11:01 +10:00 committed by Christopher Martin
parent 14bdf056e4
commit 011a047559
11 changed files with 167 additions and 22 deletions

View file

@ -256,7 +256,7 @@ public class BendingPlayer {
}
return true;
}
public boolean canUsePassive(Element element) {
if (!isToggled() || !isElementToggled(element)) {
return false;

View file

@ -3,6 +3,7 @@ package com.projectkorra.projectkorra;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -13,6 +14,7 @@ import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.Statistic;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -128,6 +130,7 @@ import com.projectkorra.projectkorra.earthbending.metal.Extraction;
import com.projectkorra.projectkorra.earthbending.metal.MetalClips;
import com.projectkorra.projectkorra.earthbending.passive.DensityShift;
import com.projectkorra.projectkorra.earthbending.passive.EarthPassive;
import com.projectkorra.projectkorra.earthbending.passive.FerroControl;
import com.projectkorra.projectkorra.earthbending.sand.SandSpout;
import com.projectkorra.projectkorra.event.EntityBendingDeathEvent;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
@ -764,27 +767,27 @@ public class PKListener implements Listener {
if (!event.isCancelled() && bPlayer.hasElement(Element.AIR) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.AIR)) {
new AirBurst(player, true);
if (CoreAbility.getAbility(GracefulDescent.class).isEnabled()) {
if (CoreAbility.getAbility(GracefulDescent.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(GracefulDescent.class))) {
event.setDamage(0D);
event.setCancelled(true);
}
}
if (!event.isCancelled() && bPlayer.hasElement(Element.WATER) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.WATER) && CoreAbility.getAbility(Hydrosink.class).isEnabled()) {
if (!event.isCancelled() && bPlayer.hasElement(Element.WATER) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.WATER) && CoreAbility.getAbility(Hydrosink.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Hydrosink.class))) {
if (WaterPassive.applyNoFall(player)) {
event.setDamage(0D);
event.setCancelled(true);
}
}
if (!event.isCancelled() && bPlayer.hasElement(Element.EARTH) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.EARTH) && CoreAbility.getAbility(DensityShift.class).isEnabled()) {
if (!event.isCancelled() && bPlayer.hasElement(Element.EARTH) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.EARTH) && CoreAbility.getAbility(DensityShift.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(DensityShift.class))) {
if (EarthPassive.softenLanding(player)) {
event.setDamage(0D);
event.setCancelled(true);
}
}
if (!event.isCancelled() && bPlayer.hasElement(Element.CHI) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.CHI) && CoreAbility.getAbility(Acrobatics.class).isEnabled()) {
if (!event.isCancelled() && bPlayer.hasElement(Element.CHI) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.CHI) && CoreAbility.getAbility(Acrobatics.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Acrobatics.class))) {
double initdamage = event.getDamage();
double newdamage = event.getDamage() * ChiPassive.getFallReductionFactor();
double finaldamage = initdamage - newdamage;
@ -1181,6 +1184,7 @@ public class PKListener implements Listener {
JUMPS.remove(player);
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerSneak(PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
@ -1221,6 +1225,28 @@ public class PKListener implements Listener {
BlockSource.update(player, ClickType.SHIFT_DOWN);
}
if (CoreAbility.getAbility(FerroControl.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(FerroControl.class)) && !bPlayer.isOnCooldown("Hodor")) {
if (event.isSneaking()) {
Block block = player.getTargetBlock((HashSet<Material>) null, 5);
if (block != null) {
if (block.getType() == Material.IRON_DOOR_BLOCK && !GeneralMethods.isRegionProtectedFromBuild(player, block.getLocation())) {
if (block.getData() >= 8) {
block = block.getRelative(BlockFace.DOWN);
}
if (block.getData() < 4) {
block.setData((byte) (block.getData() + 4));
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 10, 1);
} else {
block.setData((byte) (block.getData() - 4));
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 10, 1);
}
bPlayer.addCooldown("Hodor", 200);
}
}
}
}
AirScooter.check(player);
CoreAbility coreAbil = bPlayer.getBoundAbility();

View file

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility;
@ -26,9 +27,7 @@ public class PassiveManager {
}
for (CoreAbility ability : CoreAbility.getAbilities()) {
if (ability instanceof PassiveAbility) {
if (!ability.isEnabled()) {
continue;
} else if (!bPlayer.canBendPassive(ability.getElement())) {
if (!hasPassive(player, ability)) {
continue;
} else if (CoreAbility.hasAbility(player, ability.getClass())) {
continue;
@ -67,6 +66,28 @@ public class PassiveManager {
}
}
public static boolean hasPassive(Player player, CoreAbility passive) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
Element element = passive.getElement();
if (passive.getElement() instanceof SubElement) {
element = ((SubElement) passive.getElement()).getParentElement();
}
if (bPlayer == null) {
return false;
} else if (!(passive instanceof PassiveAbility)) {
return false;
} else if (!passive.isEnabled()) {
return false;
} else if (!bPlayer.canBendPassive(passive.getElement())) {
return false;
} else if (!bPlayer.isToggled()) {
return false;
} else if (!bPlayer.isElementToggled(element)) {
return false;
}
return true;
}
public static Set<String> getPassivesForElement(Element element) {
if (PASSIVES_BY_ELEMENT.get(element) == null) {
return new HashSet<>();

View file

@ -6,10 +6,12 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility;
import com.projectkorra.projectkorra.chiblocking.passive.ChiAgility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
public class AirAgilityPassive extends AirAbility implements PassiveAbility {
public class AirAgility extends AirAbility implements PassiveAbility {
// Configurable variables
private int jumpPower;
@ -19,7 +21,7 @@ public class AirAgilityPassive extends AirAbility implements PassiveAbility {
private boolean jumpActivate;
private boolean speedActivate;
public AirAgilityPassive(Player player) {
public AirAgility(Player player) {
super(player);
setFields();
}
@ -35,6 +37,16 @@ public class AirAgilityPassive extends AirAbility implements PassiveAbility {
return;
}
if (CoreAbility.hasAbility(player, ChiAgility.class)) {
ChiAgility chiAgility = CoreAbility.getAbility(player, ChiAgility.class);
if (chiAgility.getJumpPower() > jumpPower) {
jumpPower = chiAgility.getJumpPower();
}
if (chiAgility.getSpeedPower() > speedPower) {
speedPower = chiAgility.getSpeedPower();
}
}
// Jump Buff
jumpActivate = true;
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
@ -96,4 +108,12 @@ public class AirAgilityPassive extends AirAbility implements PassiveAbility {
return true;
}
public int getJumpPower() {
return jumpPower;
}
public int getSpeedPower() {
return speedPower;
}
}

View file

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.airbending.Suffocate;
import com.projectkorra.projectkorra.command.Commands;
@ -72,6 +73,9 @@ public class Paralyze extends ChiAbility {
return true;
}
ENTITIES.remove(entity);
if (entity instanceof Player) {
PassiveManager.registerPassives((Player) entity);
}
}
return false;

View file

@ -6,11 +6,13 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility;
import com.projectkorra.projectkorra.airbending.passive.AirAgility;
import com.projectkorra.projectkorra.chiblocking.AcrobatStance;
import com.projectkorra.projectkorra.configuration.ConfigManager;
public class ChiAgilityPassive extends ChiAbility implements PassiveAbility {
public class ChiAgility extends ChiAbility implements PassiveAbility {
// Configurable variables
private int jumpPower;
@ -20,7 +22,7 @@ public class ChiAgilityPassive extends ChiAbility implements PassiveAbility {
private boolean jumpActivate;
private boolean speedActivate;
public ChiAgilityPassive(Player player) {
public ChiAgility(Player player) {
super(player);
setFields();
}
@ -36,6 +38,16 @@ public class ChiAgilityPassive extends ChiAbility implements PassiveAbility {
return;
}
if (CoreAbility.hasAbility(player, AirAgility.class)) {
AirAgility airAgility = CoreAbility.getAbility(player, AirAgility.class);
if (airAgility.getJumpPower() > jumpPower) {
jumpPower = airAgility.getJumpPower();
}
if (airAgility.getSpeedPower() > speedPower) {
speedPower = airAgility.getSpeedPower();
}
}
// Jump Buff
int jMax = jumpPower;
if (hasAbility(player, AcrobatStance.class)) {
@ -107,4 +119,12 @@ public class ChiAgilityPassive extends ChiAbility implements PassiveAbility {
return true;
}
public int getJumpPower() {
return jumpPower;
}
public int getSpeedPower() {
return speedPower;
}
}

View file

@ -341,6 +341,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.Tremorsense.Description", "This is a pure utility ability for earthbenders. If you are in an area of low-light and are standing on top of an earthbendable block, this ability will automatically turn that block into glowstone, visible *only by you*. If you lose contact with a bendable block, the light will go out as you have lost contact with the earth and cannot 'see' until you can touch earth again. Additionally, if you click with this ability selected, smoke will appear above nearby earth with pockets of air beneath them.");
config.addDefault("Abilities.Earth.Tremorsense.Instructions", "Simply left click while on an earthbendable block.");
config.addDefault("Abilities.Earth.Passive.DensityShift.Description", "DensityShift is a passive ability which allows earthbenders to make a firm landing negating all fall damage on any earthbendable surface.");
config.addDefault("Abilities.Earth.Passive.FerroControl.Description", "FerroControl is a passive ability which allows metalbenders to simply open and close iron doors by sneaking.");
config.addDefault("Commands.Help.Elements.Fire", "Fire is the element of power. Firebenders focus on destruction and incineration. Their abilities are pretty straight forward: set things on fire. They do have a bit of utility however, being able to make themselves un-ignitable, extinguish large areas, cook food in their hands, extinguish large areas, small bursts of flight, and then comes the abilities to shoot fire from your hands.\nFirebenders can chain their abilities into combos, type /b help FireCombos for more information.");
config.addDefault("Abilities.Fire.Blaze.Description", "Blaze is a basic firebending technique that can be extremely deadly if used right. It's useful to stop people from chasing you or to create space between you and other players..");
@ -946,6 +947,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.Passive.Duration", 2500);
config.addDefault("Abilities.Earth.Passive.DensityShift.Enabled", true);
config.addDefault("Abilities.Earth.Passive.FerroControl.Enabled", true);
config.addDefault("Abilities.Earth.Catapult.Enabled", true);
config.addDefault("Abilities.Earth.Catapult.Length", 6);

View file

@ -1,7 +1,6 @@
package com.projectkorra.projectkorra.earthbending.passive;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.EarthAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility;
@ -11,15 +10,12 @@ import com.projectkorra.projectkorra.earthbending.lava.LavaSurgeWall;
import com.projectkorra.projectkorra.earthbending.lava.LavaSurgeWave;
import com.projectkorra.projectkorra.util.TempBlock;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.material.MaterialData;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -100,7 +96,7 @@ public class EarthPassive {
}
}
@SuppressWarnings("deprecation")
/*@SuppressWarnings("deprecation")
public static void handleMetalPassives() {
for (Player player : Bukkit.getOnlinePlayers()) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
@ -130,7 +126,7 @@ public class EarthPassive {
}
}
}
}
}*/
public static void revertSands() {
for (Block block : SAND_BLOCKS.keySet()) {

View file

@ -0,0 +1,50 @@
package com.projectkorra.projectkorra.earthbending.passive;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.ability.MetalAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility;
public class FerroControl extends MetalAbility implements PassiveAbility {
public FerroControl(Player player) {
super(player);
}
@Override
public void progress() {
}
@Override
public boolean isSneakAbility() {
return true;
}
@Override
public boolean isHarmlessAbility() {
return true;
}
@Override
public long getCooldown() {
return 0;
}
@Override
public String getName() {
return "FerroControl";
}
@Override
public Location getLocation() {
return null;
}
@Override
public boolean isInstantiable() {
return false;
}
}

View file

@ -19,7 +19,7 @@ public class EarthbendingManager implements Runnable {
public void run() {
EarthPassive.revertSands();
EarthPassive.handleMetalPassives();
//EarthPassive.handleMetalPassives();
RevertChecker.revertEarthBlocks();
Shockwave.progressAll();
Tremorsense.manage(Bukkit.getServer());

View file

@ -6,9 +6,12 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.airbending.passive.AirPassive;
import com.projectkorra.projectkorra.airbending.passive.AirSaturation;
import com.projectkorra.projectkorra.chiblocking.passive.ChiPassive;
import com.projectkorra.projectkorra.chiblocking.passive.ChiSaturation;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
@ -33,6 +36,9 @@ public class PassiveHandler {
}
public static void checkExhaustionPassives(Player player) {
if (!CoreAbility.getAbility(AirSaturation.class).isEnabled() && !CoreAbility.getAbility(ChiSaturation.class).isEnabled()) {
return;
}
double air = AirPassive.getExhaustionFactor();
double chi = ChiPassive.getExhaustionFactor();
@ -49,9 +55,9 @@ public class PassiveHandler {
if (bPlayer == null)
return;
if (!bPlayer.hasElement(Element.AIR))
if (!PassiveManager.hasPassive(player, CoreAbility.getAbility(AirSaturation.class)))
air = 0;
if (!bPlayer.hasElement(Element.CHI))
if (!PassiveManager.hasPassive(player, CoreAbility.getAbility(ChiSaturation.class)))
chi = 0;
double max = Math.max(air, chi);