This commit is contained in:
MistPhizzle 2014-06-24 21:03:26 -04:00
parent 26237ce090
commit e1c8732d54
6 changed files with 159 additions and 0 deletions

View file

@ -18,6 +18,7 @@ import com.projectkorra.ProjectKorra.airbending.AirPassive;
import com.projectkorra.ProjectKorra.airbending.Tornado; import com.projectkorra.ProjectKorra.airbending.Tornado;
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive; import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
import com.projectkorra.ProjectKorra.earthbending.EarthPassive; import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
import com.projectkorra.ProjectKorra.firebending.FireJet;
import com.projectkorra.ProjectKorra.firebending.FirePassive; import com.projectkorra.ProjectKorra.firebending.FirePassive;
import com.projectkorra.ProjectKorra.firebending.FireStream; import com.projectkorra.ProjectKorra.firebending.FireStream;
import com.projectkorra.ProjectKorra.waterbending.Bloodbending; import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
@ -63,6 +64,7 @@ public class BendingManager implements Runnable {
AirBurst.progressAll(); AirBurst.progressAll();
handleDayNight(); handleDayNight();
Bloodbending.progressAll(); Bloodbending.progressAll();
FireJet.progressAll();
for (int ID: Tornado.instances.keySet()) { for (int ID: Tornado.instances.keySet()) {
Tornado.progress(ID); Tornado.progress(ID);

View file

@ -114,6 +114,17 @@ public class ConfigManager {
plugin.getConfig().addDefault("Abilities.Water.Plantbending.RegrowTime", 180000); plugin.getConfig().addDefault("Abilities.Water.Plantbending.RegrowTime", 180000);
plugin.getConfig().addDefault("Abilities.Earth.Passive.Duration", 2500); plugin.getConfig().addDefault("Abilities.Earth.Passive.Duration", 2500);
config.addDefault("Abilities.Fire.FireJet.Enabled", true);
config.addDefault("Abilities.Fire.FireJet.Description", "This ability is used for a limited burst of flight for firebenders. Clicking with this "
+ "ability selected will launch you in the direction you're looking, granting you "
+ "controlled flight for a short time. This ability can be used mid-air to prevent falling "
+ "to your death, but on the ground it can only be used if standing on a block that's "
+ "ignitable (e.g. not snow or water).");
config.addDefault("Abilities.Fire.FireJet.Speed", 0.7);
config.addDefault("Abilities.Fire.FireJet.Duration", 1500);
config.addDefault("Abilities.Fire.FireJet.Cooldown", 6000);
plugin.getConfig().addDefault("Abilities.Chi.Passive.FallReductionFactor", 0.5); plugin.getConfig().addDefault("Abilities.Chi.Passive.FallReductionFactor", 0.5);
plugin.getConfig().addDefault("Abilities.Chi.Passive.Speed", 1); plugin.getConfig().addDefault("Abilities.Chi.Passive.Speed", 1);
plugin.getConfig().addDefault("Abilities.Chi.Passive.Jump", 2); plugin.getConfig().addDefault("Abilities.Chi.Passive.Jump", 2);

View file

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Ability.AvatarState; import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.airbending.Tornado; import com.projectkorra.ProjectKorra.airbending.Tornado;
import com.projectkorra.ProjectKorra.firebending.FireJet;
import com.projectkorra.ProjectKorra.waterbending.Bloodbending; import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
public class Flight { public class Flight {

View file

@ -49,6 +49,7 @@ import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
import com.projectkorra.ProjectKorra.chiblocking.Paralyze; import com.projectkorra.ProjectKorra.chiblocking.Paralyze;
import com.projectkorra.ProjectKorra.earthbending.EarthPassive; import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
import com.projectkorra.ProjectKorra.firebending.Enflamed; import com.projectkorra.ProjectKorra.firebending.Enflamed;
import com.projectkorra.ProjectKorra.firebending.FireJet;
import com.projectkorra.ProjectKorra.firebending.FireStream; import com.projectkorra.ProjectKorra.firebending.FireStream;
import com.projectkorra.ProjectKorra.waterbending.Bloodbending; import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
import com.projectkorra.ProjectKorra.waterbending.WaterCore; import com.projectkorra.ProjectKorra.waterbending.WaterCore;
@ -281,6 +282,15 @@ public class PKListener implements Listener {
Bloodbending.launch(player); Bloodbending.launch(player);
} }
} }
if (Methods.isFireAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
return;
}
if (abil.equalsIgnoreCase("FireJet")) {
new FireJet(player);
}
}
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)

View file

@ -0,0 +1,128 @@
package com.projectkorra.ProjectKorra.firebending;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
public class FireJet {
public static ConcurrentHashMap<Player, FireJet> instances = new ConcurrentHashMap<Player, FireJet>();
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static final double defaultfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireJet.Speed");
private static final long defaultduration = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireJet.Duration");
// private static final long cooldown = ConfigManager.fireJetCooldown;
// private static ConcurrentHashMap<Player, Long> timers = new
// ConcurrentHashMap<Player, Long>();
private Player player;
// private boolean canfly;
private long time;
private long duration = defaultduration;
private double factor = defaultfactor;
public FireJet(Player player) {
if (instances.containsKey(player)) {
// player.setAllowFlight(canfly);
instances.remove(player);
return;
}
// if (timers.containsKey(player)) {
// if (System.currentTimeMillis() < timers.get(player)
// + (long) ((double) cooldown / Methods
// .getFirebendingDayAugment(player.getWorld()))) {
// return;
// }
// }
if (cooldowns.containsKey(player.getName())) {
if (cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireJet.Cooldown") >= System.currentTimeMillis()) {
return;
} else {
cooldowns.remove(player.getName());
}
}
factor = Methods.firebendingDayAugment(defaultfactor, player.getWorld());
Block block = player.getLocation().getBlock();
if (FireStream.isIgnitable(player, block)
|| block.getType() == Material.AIR
|| AvatarState.isAvatarState(player)) {
player.setVelocity(player.getEyeLocation().getDirection().clone()
.normalize().multiply(factor));
block.setType(Material.FIRE);
this.player = player;
// canfly = player.getAllowFlight();
new Flight(player);
player.setAllowFlight(true);
time = System.currentTimeMillis();
// timers.put(player, time);
instances.put(player, this);
cooldowns.put(player.getName(), System.currentTimeMillis());
}
}
public static boolean checkTemporaryImmunity(Player player) {
if (instances.containsKey(player)) {
return true;
}
return false;
}
public void progress() {
if (player.isDead() || !player.isOnline()) {
// player.setAllowFlight(canfly);
instances.remove(player);
return;
}
if ((Methods.isWater(player.getLocation().getBlock()) || System
.currentTimeMillis() > time + duration)
&& !AvatarState.isAvatarState(player)) {
// player.setAllowFlight(canfly);
instances.remove(player);
} else {
player.getWorld().playEffect(player.getLocation(),
Effect.MOBSPAWNER_FLAMES, 1);
double timefactor;
if (AvatarState.isAvatarState(player)) {
timefactor = 1;
} else {
timefactor = 1 - ((double) (System.currentTimeMillis() - time))
/ (2.0 * duration);
}
Vector velocity = player.getEyeLocation().getDirection().clone()
.normalize().multiply(factor * timefactor);
// Vector velocity = player.getVelocity().clone();
// velocity.add(player.getEyeLocation().getDirection().clone()
// .normalize().multiply(factor * timefactor));
player.setVelocity(velocity);
player.setFallDistance(0);
}
}
public static void progressAll() {
for (Player player : instances.keySet()) {
instances.get(player).progress();
}
}
public static ArrayList<Player> getPlayers() {
ArrayList<Player> players = new ArrayList<Player>();
for (Player player : instances.keySet()) {
players.add(player);
}
return players;
}
}

View file

@ -75,6 +75,13 @@ Abilities:
Earth: Earth:
Passive: Passive:
Duration: 2500 Duration: 2500
Fire:
FireJet:
Enabled: true
Description: "This ability is used for a limited burst of flight for firebenders. Clicking with this ability selected will launch you in the direction you're looking, granting you controlled flight for a short time. This ability can be used mid-air to prevent falling to your death, but on the ground it can only be used if standing on a block that's ignitable (e.g. not snow or water)."
Speed: 0.7
Duration: 1500
Cooldown: 6000
Chi: Chi:
Passive: Passive:
FallReductionFactor: 0.5 FallReductionFactor: 0.5