From 29873e139a097f40f39f21c9edd786cb1a94d5ad Mon Sep 17 00:00:00 2001 From: nathank33 Date: Wed, 11 Nov 2015 15:22:27 -0800 Subject: [PATCH] Decoreability cleanup --- .../projectkorra/airbending/AirBlast.java | 1 + .../projectkorra/airbending/AirBubble.java | 6 +- .../projectkorra/airbending/AirBurst.java | 23 +++--- .../projectkorra/airbending/AirCombo.java | 22 +++--- .../projectkorra/airbending/AirMethods.java | 14 ++-- .../projectkorra/airbending/AirPassive.java | 12 ++- .../projectkorra/airbending/AirScooter.java | 6 +- .../projectkorra/airbending/AirShield.java | 41 +++++----- .../projectkorra/airbending/AirSpout.java | 20 +++-- .../projectkorra/airbending/AirSuction.java | 3 +- .../projectkorra/airbending/AirSwipe.java | 24 +++--- .../airbending/FlightAbility.java | 4 +- .../projectkorra/airbending/Suffocate.java | 72 ++++++++++-------- .../projectkorra/airbending/Tornado.java | 15 ++-- .../projectkorra/earthbending/Catapult.java | 6 +- .../projectkorra/firebending/ArcOfFire.java | 6 +- .../projectkorra/firebending/Combustion.java | 30 +++++--- .../projectkorra/firebending/Cook.java | 4 +- .../projectkorra/firebending/Extinguish.java | 22 +++--- .../projectkorra/firebending/FireBlast.java | 5 +- .../projectkorra/firebending/FireBurst.java | 23 +++--- .../projectkorra/firebending/FireCombo.java | 21 +++--- .../projectkorra/firebending/FireJet.java | 22 +++--- .../projectkorra/firebending/FireMethods.java | 74 ++++++++++++------- .../projectkorra/firebending/FireShield.java | 33 ++++++--- .../projectkorra/firebending/FireStream.java | 39 +++++++--- .../projectkorra/firebending/Fireball.java | 36 ++++----- .../projectkorra/firebending/HeatControl.java | 6 +- .../projectkorra/firebending/HeatMelt.java | 8 +- .../firebending/Illumination.java | 63 +++++++++------- .../projectkorra/firebending/Lightning.java | 7 +- .../projectkorra/firebending/RingOfFire.java | 5 +- .../projectkorra/firebending/WallOfFire.java | 11 +-- 33 files changed, 400 insertions(+), 284 deletions(-) diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java index 4905d7d5..71098ab8 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java @@ -31,6 +31,7 @@ import com.projectkorra.projectkorra.util.Flight; public class AirBlast implements ConfigLoadable { public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static ConcurrentHashMap origins = new ConcurrentHashMap(); public static double speed = config.get().getDouble("Abilities.Air.AirBlast.Speed"); diff --git a/src/com/projectkorra/projectkorra/airbending/AirBubble.java b/src/com/projectkorra/projectkorra/airbending/AirBubble.java index 2e143105..86648f19 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBubble.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBubble.java @@ -16,7 +16,9 @@ import com.projectkorra.projectkorra.waterbending.WaterManipulation; import com.projectkorra.projectkorra.waterbending.WaterMethods; public class AirBubble implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static double DEFAULT_AIR_RADIUS = config.get().getDouble("Abilities.Air.AirBubble.Radius"); private static double DEFAULT_WATER_RADIUS = config.get().getDouble("Abilities.Water.WaterBubble.Radius"); @@ -53,7 +55,7 @@ public class AirBubble implements ConfigLoadable { if (GeneralMethods.getBoundAbility(player) != null) { if (GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirBubble") || GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterBubble")) { - if (instances.containsKey(player) && player.isSneaking()) { + if (!instances.containsKey(player) && player.isSneaking()) { new AirBubble(player); } } diff --git a/src/com/projectkorra/projectkorra/airbending/AirBurst.java b/src/com/projectkorra/projectkorra/airbending/AirBurst.java index d90de3c5..8fb74fa4 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBurst.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBurst.java @@ -16,8 +16,9 @@ import com.projectkorra.projectkorra.ability.AvatarState; import com.projectkorra.projectkorra.configuration.ConfigLoadable; public class AirBurst implements ConfigLoadable { - - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static double PARTICLES_PERCENTAGE = 50; private static double threshold = config.get().getDouble("Abilities.Air.AirBurst.FallThreshold"); @@ -34,7 +35,7 @@ public class AirBurst implements ConfigLoadable { private ArrayList affectedentities = new ArrayList(); public AirBurst() { - //reloadVariables(); + // reloadVariables(); } public AirBurst(Player player) { @@ -45,7 +46,7 @@ public class AirBurst implements ConfigLoadable { if (instances.containsKey(player)) return; /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); starttime = System.currentTimeMillis(); if (AvatarState.isAvatarState(player)) chargetime = 0; @@ -172,25 +173,25 @@ public class AirBurst implements ConfigLoadable { Location location = player.getEyeLocation(); // location = location.add(location.getDirection().normalize()); AirMethods.playAirbendingParticles(location, 10); - // location.getWorld().playEffect( - // location, - // Effect.SMOKE, - // Methods.getIntCardinalDirection(player.getEyeLocation() + // location.getWorld().playEffect( + // location, + // Effect.SMOKE, + // Methods.getIntCardinalDirection(player.getEyeLocation() // .getDirection()), 3); } return true; } - + public static void progressAll() { for (AirBurst ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(player); } - + public static void removeAll() { for (AirBurst ability : instances.values()) { ability.remove(); diff --git a/src/com/projectkorra/projectkorra/airbending/AirCombo.java b/src/com/projectkorra/projectkorra/airbending/AirCombo.java index 751fa3d4..709f42da 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirCombo.java +++ b/src/com/projectkorra/projectkorra/airbending/AirCombo.java @@ -25,6 +25,7 @@ import org.bukkit.util.Vector; import java.util.ArrayList; public class AirCombo implements ConfigLoadable { + public static enum AbilityState { TWISTER_MOVING, TWISTER_STATIONARY } @@ -79,7 +80,7 @@ public class AirCombo implements ConfigLoadable { public AirCombo(Player player, String ability) { /* Initial Checks */ - + if (!enabled) return; if (Commands.isToggledForAll) @@ -95,7 +96,7 @@ public class AirCombo implements ConfigLoadable { if (GeneralMethods.isRegionProtectedFromBuild(player, "AirBlast", player.getLocation())) return; /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); time = System.currentTimeMillis(); this.player = player; this.ability = ability; @@ -192,12 +193,12 @@ public class AirCombo implements ConfigLoadable { for (Entity entity : affectedEntities) { Vector forceDir = GeneralMethods.getDirection(entity.getLocation(), currentLoc.clone().add(0, height, 0)); - + if (entity instanceof Player) { if (Commands.invincible.contains(((Player) entity).getName())) break; } - + entity.setVelocity(forceDir.clone().normalize().multiply(0.3)); } } @@ -213,12 +214,12 @@ public class AirCombo implements ConfigLoadable { currentLoc = origin.clone(); } Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList()); - + if (target instanceof Player) { if (Commands.invincible.contains(((Player) target).getName())) return; } - + if (target != null && target.getLocation().distance(currentLoc) > 7) destination = target.getLocation(); else @@ -304,7 +305,8 @@ public class AirCombo implements ConfigLoadable { direction = player.getEyeLocation().getDirection(); for (double i = -5; i < 10; i += 1) { - FireComboStream fs = new FireComboStream(null, direction.clone().add(new Vector(0, 0.03 * i, 0)), player.getLocation(), range, speed, "AirSlice"); + FireComboStream fs = new FireComboStream(null, direction.clone().add(new Vector(0, 0.03 * i, 0)), + player.getLocation(), range, speed, "AirSlice"); fs.setDensity(1); fs.setSpread(0F); fs.setUseNewParticles(true); @@ -346,7 +348,8 @@ public class AirCombo implements ConfigLoadable { Vector origToDest = GeneralMethods.getDirection(origin, destination); for (double i = 0; i < 30; i++) { - Vector vec = GeneralMethods.getDirection(player.getLocation(), origin.clone().add(origToDest.clone().multiply(i / 30))); + Vector vec = GeneralMethods.getDirection(player.getLocation(), + origin.clone().add(origToDest.clone().multiply(i / 30))); FireComboStream fs = new FireComboStream(null, vec, player.getLocation(), range, speed, "AirSweep"); fs.setDensity(1); @@ -480,7 +483,8 @@ public class AirCombo implements ConfigLoadable { else if (ability.equalsIgnoreCase("AirSweep") && combo.ability.equalsIgnoreCase("AirSweep")) { for (int j = 0; j < combo.tasks.size(); j++) { FireComboStream fs = (FireComboStream) combo.tasks.get(j); - if (fs.getLocation() != null && fs.getLocation().getWorld().equals(loc.getWorld()) && Math.abs(fs.getLocation().distance(loc)) <= radius) { + if (fs.getLocation() != null && fs.getLocation().getWorld().equals(loc.getWorld()) + && Math.abs(fs.getLocation().distance(loc)) <= radius) { fs.remove(); removed = true; } diff --git a/src/com/projectkorra/projectkorra/airbending/AirMethods.java b/src/com/projectkorra/projectkorra/airbending/AirMethods.java index 6d9a2c90..44e177a7 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirMethods.java +++ b/src/com/projectkorra/projectkorra/airbending/AirMethods.java @@ -43,8 +43,7 @@ public class AirMethods { * Checks to see if a player can use SpiritualProjection. * * @param player The player to check - * @return true If player has permission node - * "bending.air.spiritualprojection" + * @return true If player has permission node "bending.air.spiritualprojection" */ public static boolean canUseSpiritualProjection(Player player) { if (player.hasPermission("bending.air.spiritualprojection")) @@ -60,7 +59,7 @@ public class AirMethods { public static ChatColor getAirColor() { return ChatColor.valueOf(config.getString("Properties.Chat.Colors.Air")); } - + /** * Gets the AirSubColor from the config. * @@ -132,8 +131,8 @@ public class AirMethods { } /** - * Plays an integer amount of air particles in a location with a given - * xOffset, yOffset, and zOffset. + * Plays an integer amount of air particles in a location with a given xOffset, yOffset, and + * zOffset. * * @param loc The location to use * @param amount The amount of particles @@ -142,7 +141,7 @@ public class AirMethods { * @param zOffset The zOffset to use */ public static void playAirbendingParticles(Location loc, int amount, float xOffset, float yOffset, float zOffset) { - getAirbendingParticles().display(loc, xOffset, yOffset, zOffset, 0, amount); + getAirbendingParticles().display(loc, xOffset, yOffset, zOffset, 0, amount); } /** @@ -185,8 +184,7 @@ public class AirMethods { } /** - * Breaks a breathbendng hold on an entity or one a player is inflicting on - * an entity. + * Breaks a breathbendng hold on an entity or one a player is inflicting on an entity. * * @param entity The entity to be acted upon */ diff --git a/src/com/projectkorra/projectkorra/airbending/AirPassive.java b/src/com/projectkorra/projectkorra/airbending/AirPassive.java index 979708a3..b2edef9b 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirPassive.java +++ b/src/com/projectkorra/projectkorra/airbending/AirPassive.java @@ -43,15 +43,21 @@ public class AirPassive implements ConfigLoadable { if (!player.isOnline()) return; if (GeneralMethods.canBendPassive(player.getName(), Element.Air)) { - player.setExhaustion(getExhaustion(player, player.getExhaustion())); // Handles Food Passive + player.setExhaustion(getExhaustion(player, player.getExhaustion())); // Handles + // Food + // Passive if (player.isSprinting()) { if (!player.hasPotionEffect(PotionEffectType.SPEED)) { speedPower = config.get().getInt("Abilities.Air.Passive.Speed"); - player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speedPower - 1)); // Handles Speed Passive + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speedPower - 1)); // Handles + // Speed + // Passive } if (!player.hasPotionEffect(PotionEffectType.JUMP)) { jumpPower = config.get().getInt("Abilities.Air.Passive.Jump"); - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jumpPower - 1)); // Handles jump passive. + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jumpPower - 1)); // Handles + // jump + // passive. } } } diff --git a/src/com/projectkorra/projectkorra/airbending/AirScooter.java b/src/com/projectkorra/projectkorra/airbending/AirScooter.java index b8ad3404..2764d9b2 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirScooter.java +++ b/src/com/projectkorra/projectkorra/airbending/AirScooter.java @@ -16,7 +16,7 @@ import com.projectkorra.projectkorra.util.Flight; public class AirScooter implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); private static double configSpeed = config.get().getDouble("Abilities.Air.AirScooter.Speed"); private static final long interval = 100; @@ -166,7 +166,7 @@ public class AirScooter implements ConfigLoadable { } return true; } - + public static void progressAll() { for (AirScooter ability : instances.values()) { ability.progress(); @@ -185,7 +185,7 @@ public class AirScooter implements ConfigLoadable { player.setAllowFlight(false); player.setSprinting(false); } - + public static void removeAll() { for (AirScooter ability : instances.values()) { ability.remove(); diff --git a/src/com/projectkorra/projectkorra/airbending/AirShield.java b/src/com/projectkorra/projectkorra/airbending/AirShield.java index 4f585ac5..dd8dc111 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirShield.java +++ b/src/com/projectkorra/projectkorra/airbending/AirShield.java @@ -22,8 +22,8 @@ import com.projectkorra.projectkorra.firebending.FireStream; public class AirShield implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); - + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static double MAX_RADIUS = config.get().getDouble("Abilities.Air.AirShield.Radius"); private static boolean isToggle = config.get().getBoolean("Abilities.Air.AirShield.IsAvatarStateToggle"); private static int numberOfStreams = (int) (.75 * (double) MAX_RADIUS); @@ -38,12 +38,12 @@ public class AirShield implements ConfigLoadable { public AirShield(Player player) { /* Initial Check */ if (AvatarState.isAvatarState(player) && instances.containsKey(player) && isToggle) { - //instances.remove(player.getUniqueId()); + // instances.remove(player.getUniqueId()); instances.get(player).remove(); return; } /* End Initial Check */ - //reloadVariables(); + // reloadVariables(); this.player = player; int angle = 0; int di = (int) (maxradius * 2 / numberOfStreams); @@ -58,7 +58,11 @@ public class AirShield implements ConfigLoadable { } public static String getDescription() { - return "Air Shield is one of the most powerful defensive techniques in existence. " + "To use, simply sneak (default: shift). " + "This will create a whirlwind of air around the user, " + "with a small pocket of safe space in the center. " + "This wind will deflect all projectiles and will prevent any creature from " + "entering it for as long as its maintained. "; + return "Air Shield is one of the most powerful defensive techniques in existence. " + + "To use, simply sneak (default: shift). " + "This will create a whirlwind of air around the user, " + + "with a small pocket of safe space in the center. " + + "This wind will deflect all projectiles and will prevent any creature from " + + "entering it for as long as its maintained. "; } public static boolean isWithinShield(Location loc) { @@ -100,7 +104,8 @@ public class AirShield implements ConfigLoadable { } if (isToggle) { - if (((!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirShield")) || (!player.isSneaking())) && !AvatarState.isAvatarState(player)) { + if (((!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirShield")) || (!player.isSneaking())) + && !AvatarState.isAvatarState(player)) { remove(); return false; } @@ -112,25 +117,25 @@ public class AirShield implements ConfigLoadable { } // - // if (((!Methods.getBoundAbility(player).equalsIgnoreCase("AirShield")) || (!player - // .isSneaking()))) { - // remove(); - // return false; - // } + // if (((!Methods.getBoundAbility(player).equalsIgnoreCase("AirShield")) || (!player + // .isSneaking()))) { + // remove(); + // return false; + // } rotateShield(); return true; } - + public static void progressAll() { for (AirShield ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(player); } - + public static void removeAll() { for (AirShield ability : instances.values()) { ability.remove(); @@ -191,7 +196,7 @@ public class AirShield implements ConfigLoadable { entity.setFallDistance(0); } } - + for (Block testblock : GeneralMethods.getBlocksAroundPoint(player.getLocation(), radius)) { if (testblock.getType() == Material.FIRE) { testblock.setType(Material.AIR); @@ -209,7 +214,7 @@ public class AirShield implements ConfigLoadable { y = origin.getY() + factor * (double) i; - //double theta = Math.asin(y/radius); + // double theta = Math.asin(y/radius); double f = Math.sqrt(1 - factor * factor * ((double) i / radius) * ((double) i / radius)); x = origin.getX() + radius * Math.cos(angle) * f; @@ -223,8 +228,8 @@ public class AirShield implements ConfigLoadable { } } - // origin.getWorld().playEffect(effect, Effect.SMOKE, 4, - // (int) AirBlast.defaultrange); + // origin.getWorld().playEffect(effect, Effect.SMOKE, 4, + // (int) AirBlast.defaultrange); angles.put(i, angles.get(i) + (int) (10 * speedfactor)); } diff --git a/src/com/projectkorra/projectkorra/airbending/AirSpout.java b/src/com/projectkorra/projectkorra/airbending/AirSpout.java index 88b9f50b..ff0a1459 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSpout.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSpout.java @@ -14,8 +14,8 @@ import com.projectkorra.projectkorra.util.Flight; public class AirSpout implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); - + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static double HEIGHT = config.get().getDouble("Abilities.Air.AirSpout.Height"); private static final long interval = 100; @@ -31,7 +31,7 @@ public class AirSpout implements ConfigLoadable { return; } /* End Initial Check */ - //reloadVariables(); + // reloadVariables(); this.player = player; time = System.currentTimeMillis(); new Flight(player); @@ -95,8 +95,9 @@ public class AirSpout implements ConfigLoadable { public boolean progress() { if (!GeneralMethods.canBend(player.getName(), "AirSpout") - // || !Methods.hasAbility(player, Abilities.AirSpout) - || player.getEyeLocation().getBlock().isLiquid() || GeneralMethods.isSolid(player.getEyeLocation().getBlock()) || player.isDead() || !player.isOnline()) { + // || !Methods.hasAbility(player, Abilities.AirSpout) + || player.getEyeLocation().getBlock().isLiquid() || GeneralMethods.isSolid(player.getEyeLocation().getBlock()) + || player.isDead() || !player.isOnline()) { remove(); return false; } @@ -119,7 +120,7 @@ public class AirSpout implements ConfigLoadable { } return true; } - + public static void progressAll() { for (AirSpout ability : instances.values()) { ability.progress(); @@ -136,7 +137,7 @@ public class AirSpout implements ConfigLoadable { removeFlight(); instances.remove(player); } - + public static void removeAll() { for (AirSpout ability : instances.values()) { ability.remove(); @@ -156,7 +157,7 @@ public class AirSpout implements ConfigLoadable { if (System.currentTimeMillis() >= time + interval) { time = System.currentTimeMillis(); - + Location location = block.getLocation(); Location playerloc = player.getLocation(); location = new Location(location.getWorld(), playerloc.getX(), location.getY(), playerloc.getZ()); @@ -177,10 +178,7 @@ public class AirSpout implements ConfigLoadable { index = 0; Location effectloc2 = new Location(location.getWorld(), location.getX(), block.getY() + i, location.getZ()); - AirMethods.playAirbendingParticles(effectloc2, 3, 0.4F, 0.4F, 0.4F); - // location.getWorld().playEffect(effectloc2, Effect.SMOKE, - // (int) directions[index], (int) height + 5); // Methods.verbose(directions[index]); diff --git a/src/com/projectkorra/projectkorra/airbending/AirSuction.java b/src/com/projectkorra/projectkorra/airbending/AirSuction.java index b220d6e6..d3589f76 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSuction.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSuction.java @@ -22,7 +22,8 @@ import com.projectkorra.projectkorra.waterbending.WaterSpout; public class AirSuction implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static ConcurrentHashMap origins = new ConcurrentHashMap(); private static final double maxspeed = AirBlast.maxspeed; diff --git a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java index f9b500e0..e432c7eb 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java @@ -29,9 +29,9 @@ import com.projectkorra.projectkorra.waterbending.WaterManipulation; import com.projectkorra.projectkorra.waterbending.WaterMethods; public class AirSwipe implements ConfigLoadable { - - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); - + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static int stepsize = 4; private static int ARC = config.get().getInt("Abilities.Air.AirSwipe.Arc"); @@ -77,7 +77,7 @@ public class AirSwipe implements ConfigLoadable { return; } /* End Initial Check */ - //reloadVariables(); + // reloadVariables(); this.player = player; this.charging = charging; origin = player.getEyeLocation(); @@ -102,7 +102,7 @@ public class AirSwipe implements ConfigLoadable { Location vectorLoc = aswipe.elements.get(vec); if (vectorLoc != null && vectorLoc.getWorld().equals(loc.getWorld())) { if (vectorLoc.distance(loc) <= radius) { - //instances.remove(aswipe.uuid); + // instances.remove(aswipe.uuid); aswipe.remove(); removed = true; } @@ -129,7 +129,10 @@ public class AirSwipe implements ConfigLoadable { double radius = FireBlast.AFFECTING_RADIUS; Player source = player; - if (EarthBlast.annihilateBlasts(location, radius, source) || WaterManipulation.annihilateBlasts(location, radius, source) || FireBlast.annihilateBlasts(location, radius, source) || Combustion.removeAroundPoint(location, radius)) { + if (EarthBlast.annihilateBlasts(location, radius, source) + || WaterManipulation.annihilateBlasts(location, radius, source) + || FireBlast.annihilateBlasts(location, radius, source) + || Combustion.removeAroundPoint(location, radius)) { elements.remove(direction); damage = 0; remove(); @@ -304,7 +307,8 @@ public class AirSwipe implements ConfigLoadable { remove(); return false; } - if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe") || !GeneralMethods.canBend(player.getName(), "AirSwipe")) { + if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe") + || !GeneralMethods.canBend(player.getName(), "AirSwipe")) { remove(); return false; } @@ -331,13 +335,13 @@ public class AirSwipe implements ConfigLoadable { } return true; } - + public static void progressAll() { for (AirSwipe ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(player); } @@ -347,7 +351,7 @@ public class AirSwipe implements ConfigLoadable { ability.remove(); } } - + @Override public void reloadVariables() { ARC = config.get().getInt("Abilities.Air.AirSwipe.Arc"); diff --git a/src/com/projectkorra/projectkorra/airbending/FlightAbility.java b/src/com/projectkorra/projectkorra/airbending/FlightAbility.java index d8d42a48..d5bc8d1e 100644 --- a/src/com/projectkorra/projectkorra/airbending/FlightAbility.java +++ b/src/com/projectkorra/projectkorra/airbending/FlightAbility.java @@ -10,7 +10,7 @@ import com.projectkorra.projectkorra.util.Flight; public class FlightAbility implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); private static ConcurrentHashMap hits = new ConcurrentHashMap(); private static ConcurrentHashMap hovering = new ConcurrentHashMap(); @@ -95,7 +95,7 @@ public class FlightAbility implements ConfigLoadable { } return true; } - + public static void progressAll() { for (FlightAbility ability : instances.values()) { ability.progress(); diff --git a/src/com/projectkorra/projectkorra/airbending/Suffocate.java b/src/com/projectkorra/projectkorra/airbending/Suffocate.java index bc967cbb..fa9ce7ae 100644 --- a/src/com/projectkorra/projectkorra/airbending/Suffocate.java +++ b/src/com/projectkorra/projectkorra/airbending/Suffocate.java @@ -21,16 +21,16 @@ import com.projectkorra.projectkorra.configuration.ConfigLoadable; /** * Suffocate * - * Suffocate is an air ability that causes entities to be surrounded by a sphere - * air that causes constant damage after a configurable delay. Suffocate also - * causes Blinding and Slowing affects to entities depending on how the ability - * is configured. While in AvatarState this ability can be used on multiple - * entities within a large radius. If the user is damaged while performing this + * Suffocate is an air ability that causes entities to be surrounded by a sphere air that causes + * constant damage after a configurable delay. Suffocate also causes Blinding and Slowing affects to + * entities depending on how the ability is configured. While in AvatarState this ability can be + * used on multiple entities within a large radius. If the user is damaged while performing this * ability then the ability is removed. */ public class Suffocate implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); - + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static boolean CAN_SUFFOCATE_UNDEAD = config.get().getBoolean("Abilities.Air.Suffocate.CanBeUsedOnUndeadMobs"); private static boolean REQUIRE_CONSTANT_AIM = config.get().getBoolean("Abilities.Air.Suffocate.RequireConstantAim"); private static double ANIM_RADIUS = config.get().getDouble("Abilities.Air.Suffocate.AnimationRadius"); @@ -76,7 +76,7 @@ public class Suffocate implements ConfigLoadable { tasks = new ArrayList(); time = System.currentTimeMillis(); - //reloadVariables(); + // reloadVariables(); reqConstantAim = REQUIRE_CONSTANT_AIM; canSuffUndead = CAN_SUFFOCATE_UNDEAD; chargeTime = CHARGE_TIME; @@ -141,7 +141,7 @@ public class Suffocate implements ConfigLoadable { else if (bplayer.isOnCooldown("suffocate")) return; bplayer.addCooldown("suffocate", cooldown); - instances.put(player,this); + instances.put(player, this); } /** Stops an entity from being suffocated **/ @@ -169,8 +169,7 @@ public class Suffocate implements ConfigLoadable { } /** - * Removes an instance of Suffocate if player is the one suffocating - * entities + * Removes an instance of Suffocate if player is the one suffocating entities **/ public static void remove(Player player) { if (instances.containsKey(player)) { @@ -183,11 +182,11 @@ public class Suffocate implements ConfigLoadable { ability.remove(); } } - + /** - * Removes all instances of Suffocate at loc within the radius threshold. - * The location of a Suffocate is defined at the benders location, not the - * location of the entities being suffocated. + * Removes all instances of Suffocate at loc within the radius threshold. The location of a + * Suffocate is defined at the benders location, not the location of the entities being + * suffocated. * * @param causer The player causing this instance to be removed **/ @@ -206,9 +205,8 @@ public class Suffocate implements ConfigLoadable { } /** - * Animates this instance of the Suffocate ability. Depending on the - * specific time (dt) the ability will create a different set of - * SuffocationSpirals. + * Animates this instance of the Suffocate ability. Depending on the specific time (dt) the + * ability will create a different set of SuffocationSpirals. */ public void animate() { long curTime = System.currentTimeMillis(); @@ -222,8 +220,10 @@ public class Suffocate implements ConfigLoadable { for (LivingEntity lent : targets) { final LivingEntity target = lent; if (dt < t1) { - new SuffocateSpiral(target, steps, radius, delay, 0, 0.25 - (0.25 * (double) dt / (double) t1), 0, SpiralType.HORIZONTAL1); - new SuffocateSpiral(target, steps, radius, delay, 0, 0.25 - (0.25 * (double) dt / (double) t1), 0, SpiralType.HORIZONTAL2); + new SuffocateSpiral(target, steps, radius, delay, 0, 0.25 - (0.25 * (double) dt / (double) t1), 0, + SpiralType.HORIZONTAL1); + new SuffocateSpiral(target, steps, radius, delay, 0, 0.25 - (0.25 * (double) dt / (double) t1), 0, + SpiralType.HORIZONTAL2); } else if (dt < t2) { new SuffocateSpiral(target, steps, radius, delay, 0, 0, 0, SpiralType.HORIZONTAL1); new SuffocateSpiral(target, steps * 2, radius, delay, 0, 0, 0, SpiralType.VERTICAL1); @@ -233,9 +233,15 @@ public class Suffocate implements ConfigLoadable { new SuffocateSpiral(target, steps, radius, delay, 0, 0, 0, SpiralType.VERTICAL1); new SuffocateSpiral(target, steps, radius, delay, 0, 0, 0, SpiralType.VERTICAL2); } else if (dt < t4) { - new SuffocateSpiral(target, steps, radius - Math.min(radius * 3 / 4, (radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.HORIZONTAL1); - new SuffocateSpiral(target, steps, radius - Math.min(radius * 3 / 4, (radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.VERTICAL1); - new SuffocateSpiral(target, steps, radius - Math.min(radius * 3 / 4, (radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.VERTICAL2); + new SuffocateSpiral(target, steps, radius + - Math.min(radius * 3 / 4, (radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, + 0, SpiralType.HORIZONTAL1); + new SuffocateSpiral(target, steps, radius + - Math.min(radius * 3 / 4, (radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, + 0, SpiralType.VERTICAL1); + new SuffocateSpiral(target, steps, radius + - Math.min(radius * 3 / 4, (radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, + 0, SpiralType.VERTICAL2); } else { new SuffocateSpiral(target, steps, radius - (radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.HORIZONTAL1); new SuffocateSpiral(target, steps, radius - (radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.VERTICAL1); @@ -364,7 +370,8 @@ public class Suffocate implements ConfigLoadable { for (int i = 0; i < targets.size(); i++) { LivingEntity target = targets.get(i); - if (target.isDead() || !target.getWorld().equals(player.getWorld()) || target.getLocation().distance(player.getEyeLocation()) > range) { + if (target.isDead() || !target.getWorld().equals(player.getWorld()) + || target.getLocation().distance(player.getEyeLocation()) > range) { breakSuffocateLocal(target); i--; } else if (target instanceof Player) { @@ -382,7 +389,8 @@ public class Suffocate implements ConfigLoadable { if (reqConstantAim) { double dist = player.getEyeLocation().distance(targets.get(0).getEyeLocation()); - Location targetLoc = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(dist)); + Location targetLoc = player.getEyeLocation().clone() + .add(player.getEyeLocation().getDirection().normalize().multiply(dist)); List ents = GeneralMethods.getEntitiesAroundPoint(targetLoc, aimRadius); for (int i = 0; i < targets.size(); i++) { @@ -440,7 +448,7 @@ public class Suffocate implements ConfigLoadable { } return true; } - + public static void progressAll() { for (Suffocate ability : instances.values()) { ability.progress(); @@ -573,9 +581,9 @@ public class Suffocate implements ConfigLoadable { }; /** - * ** Animates a Spiral of air particles around a location or a targetted - * entity. The direction of the spiral is determined by SpiralType, and each - * type is calculated independently from one another. + * ** Animates a Spiral of air particles around a location or a targetted entity. The direction + * of the spiral is determined by SpiralType, and each type is calculated independently from one + * another. */ public class SuffocateSpiral extends BukkitRunnable { private Location startLoc; @@ -597,7 +605,8 @@ public class Suffocate implements ConfigLoadable { * @param dz z offset * @param type Spiral animation direction */ - public SuffocateSpiral(LivingEntity lent, int totalSteps, double radius, long interval, double dx, double dy, double dz, SpiralType type) { + public SuffocateSpiral(LivingEntity lent, int totalSteps, double radius, long interval, double dx, double dy, double dz, + SpiralType type) { this.target = lent; this.totalSteps = totalSteps; this.radius = radius; @@ -622,7 +631,8 @@ public class Suffocate implements ConfigLoadable { * @param dz z offset * @param type Spiral animation direction */ - public SuffocateSpiral(Location startLoc, int totalSteps, double radius, long interval, double dx, double dy, double dz, SpiralType type) { + public SuffocateSpiral(Location startLoc, int totalSteps, double radius, long interval, double dx, double dy, double dz, + SpiralType type) { this.startLoc = startLoc; this.totalSteps = totalSteps; this.radius = radius; diff --git a/src/com/projectkorra/projectkorra/airbending/Tornado.java b/src/com/projectkorra/projectkorra/airbending/Tornado.java index bb7e7482..f326ec00 100644 --- a/src/com/projectkorra/projectkorra/airbending/Tornado.java +++ b/src/com/projectkorra/projectkorra/airbending/Tornado.java @@ -16,8 +16,8 @@ import com.projectkorra.projectkorra.configuration.ConfigLoadable; import com.projectkorra.projectkorra.util.Flight; public class Tornado implements ConfigLoadable { - - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); private static double MAX_HEIGHT = config.get().getDouble("Abilities.Air.Tornado.Height"); private static double PLAYER_PUSH_FACTOR = config.get().getDouble("Abilities.Air.Tornado.PlayerPushFactor"); @@ -44,7 +44,7 @@ public class Tornado implements ConfigLoadable { // private boolean canfly; public Tornado(Player player) { - //reloadVariables(); + // reloadVariables(); this.player = player; // canfly = player.getAllowFlight(); // player.setAllowFlight(true); @@ -122,17 +122,17 @@ public class Tornado implements ConfigLoadable { rotateTornado(); return true; } - + public static void progressAll() { for (Tornado ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(player); } - + public static void removeAll() { for (Tornado ability : instances.values()) { ability.remove(); @@ -249,7 +249,8 @@ public class Tornado implements ConfigLoadable { AirMethods.playAirbendingSound(effect); } } - // origin.getWorld().playEffect(effect, Effect.SMOKE, 4, (int) AirBlast.defaultrange); + // origin.getWorld().playEffect(effect, Effect.SMOKE, 4, (int) + // AirBlast.defaultrange); angles.put(i, angles.get(i) + 25 * (int) speedfactor); } diff --git a/src/com/projectkorra/projectkorra/earthbending/Catapult.java b/src/com/projectkorra/projectkorra/earthbending/Catapult.java index 3b72e80d..5fc4753b 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Catapult.java +++ b/src/com/projectkorra/projectkorra/earthbending/Catapult.java @@ -16,7 +16,7 @@ import com.projectkorra.projectkorra.configuration.ConfigLoadable; public class Catapult implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); private static int LENGTH = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Catapult.Length"); private static double SPEED = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.Catapult.Speed"); @@ -193,13 +193,13 @@ public class Catapult implements ConfigLoadable { remove(); return true; } - + public static void progressAll() { for (Catapult ability : instances.values()) { ability.progress(); } } - + public static void removeAll() { for (Catapult ability : instances.values()) { ability.remove(); diff --git a/src/com/projectkorra/projectkorra/firebending/ArcOfFire.java b/src/com/projectkorra/projectkorra/firebending/ArcOfFire.java index 0189b891..8a76ae86 100644 --- a/src/com/projectkorra/projectkorra/firebending/ArcOfFire.java +++ b/src/com/projectkorra/projectkorra/firebending/ArcOfFire.java @@ -24,7 +24,7 @@ public class ArcOfFire implements ConfigLoadable { if (bPlayer.isOnCooldown("Blaze")) return; /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); Location location = player.getLocation(); @@ -55,7 +55,9 @@ public class ArcOfFire implements ConfigLoadable { } public static String getDescription() { - return "To use, simply left-click in any direction. " + "An arc of fire will flow from your location, " + "igniting anything in its path." + " Additionally, tap sneak to engulf the area around you " + "in roaring flames."; + return "To use, simply left-click in any direction. " + "An arc of fire will flow from your location, " + + "igniting anything in its path." + " Additionally, tap sneak to engulf the area around you " + + "in roaring flames."; } @Override diff --git a/src/com/projectkorra/projectkorra/firebending/Combustion.java b/src/com/projectkorra/projectkorra/firebending/Combustion.java index 1ea3f569..f6144f8c 100644 --- a/src/com/projectkorra/projectkorra/firebending/Combustion.java +++ b/src/com/projectkorra/projectkorra/firebending/Combustion.java @@ -29,9 +29,9 @@ public class Combustion implements ConfigLoadable { public static boolean breakblocks = config.get().getBoolean("Abilities.Fire.Combustion.BreakBlocks"); public static double radius = config.get().getDouble("Abilities.Fire.Combustion.Radius"); public static double defaultdamage = config.get().getDouble("Abilities.Fire.Combustion.Damage"); - + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); - + private static final int maxticks = 10000; private Location location; @@ -56,7 +56,7 @@ public class Combustion implements ConfigLoadable { if (bPlayer.isOnCooldown("Combustion")) return; /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); this.player = player; starttime = System.currentTimeMillis(); origin = player.getEyeLocation(); @@ -85,7 +85,8 @@ public class Combustion implements ConfigLoadable { if (instances.containsKey(player)) { Combustion combustion = instances.get(player); combustion.createExplosion(combustion.location, combustion.power, breakblocks); - ParticleEffect.EXPLODE.display(combustion.location, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 3); + ParticleEffect.EXPLODE.display(combustion.location, (float) Math.random(), (float) Math.random(), + (float) Math.random(), 0, 3); } } @@ -103,11 +104,13 @@ public class Combustion implements ConfigLoadable { } private void advanceLocation() { - ParticleEffect.FIREWORKS_SPARK.display(location, (float) Math.random()/2, (float) Math.random()/2, (float) Math.random()/2, 0, 5); - ParticleEffect.FLAME.display(location, (float) Math.random()/2, (float) Math.random()/2, (float) Math.random()/2, 0, 2); - //if (Methods.rand.nextInt(4) == 0) { + ParticleEffect.FIREWORKS_SPARK.display(location, (float) Math.random() / 2, (float) Math.random() / 2, + (float) Math.random() / 2, 0, 5); + ParticleEffect.FLAME.display(location, (float) Math.random() / 2, (float) Math.random() / 2, (float) Math.random() / 2, + 0, 2); + // if (Methods.rand.nextInt(4) == 0) { FireMethods.playCombustionSound(location); - //} + // } location = location.add(direction.clone().multiply(speedfactor)); } @@ -115,7 +118,8 @@ public class Combustion implements ConfigLoadable { block.getWorld().createExplosion(block.getX(), block.getY(), block.getZ(), (float) defaultpower, true, breakblocks); for (Entity entity : block.getWorld().getEntities()) { if (entity instanceof LivingEntity) { - if (entity.getLocation().distance(block) < radius) { // They are close enough to the explosion. + if (entity.getLocation().distance(block) < radius) { // They are close enough to the + // explosion. GeneralMethods.damageEntity(player, entity, damage, "Combustion"); AirMethods.breakBreathbendingHold(entity); } @@ -140,7 +144,8 @@ public class Combustion implements ConfigLoadable { return false; } - if (GeneralMethods.getBoundAbility(player) == null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Combustion")) { + if (GeneralMethods.getBoundAbility(player) == null + || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Combustion")) { remove(); return false; } @@ -164,7 +169,8 @@ public class Combustion implements ConfigLoadable { Block block = location.getBlock(); if (block != null) { - if (block.getType() != Material.AIR && block.getType() != Material.WATER && block.getType() != Material.STATIONARY_WATER) { + if (block.getType() != Material.AIR && block.getType() != Material.WATER + && block.getType() != Material.STATIONARY_WATER) { createExplosion(block.getLocation(), power, breakblocks); } } @@ -180,7 +186,7 @@ public class Combustion implements ConfigLoadable { advanceLocation(); return true; } - + public static void progressAll() { for (Combustion ability : instances.values()) { ability.progress(); diff --git a/src/com/projectkorra/projectkorra/firebending/Cook.java b/src/com/projectkorra/projectkorra/firebending/Cook.java index dba4450a..788b0ea2 100644 --- a/src/com/projectkorra/projectkorra/firebending/Cook.java +++ b/src/com/projectkorra/projectkorra/firebending/Cook.java @@ -15,7 +15,9 @@ import com.projectkorra.projectkorra.util.ParticleEffect; * Used in {@link HeatControl}. */ public class Cook { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static final long COOK_TIME = 2000; private static final Material[] cookables = { Material.RAW_BEEF, Material.RAW_CHICKEN, Material.RAW_FISH, Material.PORK, Material.POTATO_ITEM, Material.RABBIT, Material.MUTTON }; diff --git a/src/com/projectkorra/projectkorra/firebending/Extinguish.java b/src/com/projectkorra/projectkorra/firebending/Extinguish.java index 62a12c28..749eb28e 100644 --- a/src/com/projectkorra/projectkorra/firebending/Extinguish.java +++ b/src/com/projectkorra/projectkorra/firebending/Extinguish.java @@ -31,7 +31,7 @@ public class Extinguish implements ConfigLoadable { if (bPlayer.isOnCooldown("HeatControl")) return; /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); double range = FireMethods.getFirebendingDayAugment(defaultrange, player.getWorld()); if (WaterMethods.isMeltable(player.getTargetBlock((HashSet) null, (int) range))) { @@ -39,7 +39,8 @@ public class Extinguish implements ConfigLoadable { return; } double radius = FireMethods.getFirebendingDayAugment(defaultradius, player.getWorld()); - for (Block block : GeneralMethods.getBlocksAroundPoint(player.getTargetBlock((HashSet) null, (int) range).getLocation(), radius)) { + for (Block block : GeneralMethods.getBlocksAroundPoint(player.getTargetBlock((HashSet) null, (int) range) + .getLocation(), radius)) { Material mat = block.getType(); if (mat != Material.FIRE @@ -54,14 +55,11 @@ public class Extinguish implements ConfigLoadable { block.getWorld().playEffect(block.getLocation(), Effect.EXTINGUISH, 0); } /* * else if (block.getType() == Material.STATIONARY_LAVA) { - * block.setType(Material.OBSIDIAN); - * block.getWorld().playEffect(block.getLocation(), - * Effect.EXTINGUISH, 0); } else if (block.getType() == - * Material.LAVA) { if (block.getData() == full) { - * block.setType(Material.OBSIDIAN); } else { + * block.setType(Material.OBSIDIAN); block.getWorld().playEffect(block.getLocation(), + * Effect.EXTINGUISH, 0); } else if (block.getType() == Material.LAVA) { if + * (block.getData() == full) { block.setType(Material.OBSIDIAN); } else { * block.setType(Material.COBBLESTONE); } - * block.getWorld().playEffect(block.getLocation(), - * Effect.EXTINGUISH, 0); } + * block.getWorld().playEffect(block.getLocation(), Effect.EXTINGUISH, 0); } */ } @@ -86,7 +84,11 @@ public class Extinguish implements ConfigLoadable { } public static String getDescription() { - return "While this ability is selected, the firebender becomes impervious " + "to fire damage and cannot be ignited. " + "If the user left-clicks with this ability, the targeted area will be " + "extinguished, although it will leave any creature burning engulfed in flames. " + "This ability can also cool lava. If this ability is used while targetting ice or snow, it" + " will instead melt blocks in that area. Finally, sneaking with this ability will cook any food in your hand."; + return "While this ability is selected, the firebender becomes impervious " + "to fire damage and cannot be ignited. " + + "If the user left-clicks with this ability, the targeted area will be " + + "extinguished, although it will leave any creature burning engulfed in flames. " + + "This ability can also cool lava. If this ability is used while targetting ice or snow, it" + + " will instead melt blocks in that area. Finally, sneaking with this ability will cook any food in your hand."; } @Override diff --git a/src/com/projectkorra/projectkorra/firebending/FireBlast.java b/src/com/projectkorra/projectkorra/firebending/FireBlast.java index 0fae5065..be718586 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBlast.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBlast.java @@ -28,6 +28,7 @@ import com.projectkorra.projectkorra.waterbending.WaterManipulation; import com.projectkorra.projectkorra.waterbending.WaterMethods; public class FireBlast implements ConfigLoadable { + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); private static double SPEED = config.get().getDouble("Abilities.Fire.FireBlast.Speed"); @@ -311,7 +312,7 @@ public class FireBlast implements ConfigLoadable { return true; } - + public static void progressAll() { for (FireBlast ability : instances.values()) { ability.progress(); @@ -321,7 +322,7 @@ public class FireBlast implements ConfigLoadable { public void remove() { instances.remove(id); } - + public static void removeAll() { for (FireBlast ability : instances.values()) { ability.remove(); diff --git a/src/com/projectkorra/projectkorra/firebending/FireBurst.java b/src/com/projectkorra/projectkorra/firebending/FireBurst.java index b7a1d32f..c4eed5ed 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBurst.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBurst.java @@ -19,8 +19,9 @@ import com.projectkorra.projectkorra.ability.AvatarState; import com.projectkorra.projectkorra.configuration.ConfigLoadable; public class FireBurst implements ConfigLoadable { - + public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static double PARTICLES_PERCENTAGE = 5; private Player player; @@ -41,7 +42,7 @@ public class FireBurst implements ConfigLoadable { if (instances.containsKey(player)) return; /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); starttime = System.currentTimeMillis(); if (FireMethods.isDay(player.getWorld())) { @@ -64,7 +65,9 @@ public class FireBurst implements ConfigLoadable { } public static String getDescription() { - return "FireBurst is a very powerful firebending ability. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to launch a cone-shaped burst " + "of flames in front of you, or click to release the burst in a sphere around you. "; + return "FireBurst is a very powerful firebending ability. " + "To use, press and hold sneak to charge your burst. " + + "Once charged, you can either release sneak to launch a cone-shaped burst " + + "of flames in front of you, or click to release the burst in a sphere around you. "; } private void coneBurst() { @@ -116,7 +119,7 @@ public class FireBurst implements ConfigLoadable { public void remove() { instances.remove(player); } - + public static void removeAll() { for (FireBurst ability : instances.values()) { ability.remove(); @@ -124,9 +127,9 @@ public class FireBurst implements ConfigLoadable { } /** - * To combat the sphere FireBurst lag we are only going to show a certain - * percentage of FireBurst particles at a time per tick. As the bursts - * spread out then we can show more at a time. + * To combat the sphere FireBurst lag we are only going to show a certain percentage of + * FireBurst particles at a time per tick. As the bursts spread out then we can show more at a + * time. */ public void handleSmoothParticles() { for (int i = 0; i < blasts.size(); i++) { @@ -172,7 +175,7 @@ public class FireBurst implements ConfigLoadable { } return true; } - + public static void progressAll() { for (FireBurst ability : instances.values()) { ability.progress(); @@ -181,8 +184,8 @@ public class FireBurst implements ConfigLoadable { @Override public void reloadVariables() { - //No need for this because there are no static variables. - //All instance variables are gotten newly from config + // No need for this because there are no static variables. + // All instance variables are gotten newly from config } public void setChargetime(long chargetime) { diff --git a/src/com/projectkorra/projectkorra/firebending/FireCombo.java b/src/com/projectkorra/projectkorra/firebending/FireCombo.java index 2d1a94ba..5483dacc 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireCombo.java +++ b/src/com/projectkorra/projectkorra/firebending/FireCombo.java @@ -102,7 +102,7 @@ public class FireCombo implements ConfigLoadable { return; } /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); time = System.currentTimeMillis(); this.player = player; this.ability = ability; @@ -151,8 +151,8 @@ public class FireCombo implements ConfigLoadable { } /** - * Returns all of the FireCombos created by a specific player but filters - * the abilities based on shift or click. + * Returns all of the FireCombos created by a specific player but filters the abilities based on + * shift or click. */ public static ArrayList getFireCombo(Player player, ClickType type) { ArrayList list = new ArrayList(); @@ -182,7 +182,8 @@ public class FireCombo implements ConfigLoadable { if (ability.equalsIgnoreCase("FireKick") && combo.ability.equalsIgnoreCase("FireKick")) { for (FireComboStream fs : combo.tasks) { - if (fs.getLocation() != null && fs.getLocation().getWorld() == loc.getWorld() && Math.abs(fs.getLocation().distance(loc)) <= radius) { + if (fs.getLocation() != null && fs.getLocation().getWorld() == loc.getWorld() + && Math.abs(fs.getLocation().distance(loc)) <= radius) { fs.remove(); removed = true; } @@ -316,7 +317,8 @@ public class FireCombo implements ConfigLoadable { vec = GeneralMethods.rotateXZ(vec, i - 180); vec.setY(0); - FireComboStream fs = new FireComboStream(this, vec, player.getLocation().clone().add(0, 1, 0), range, speed, "FireSpin"); + FireComboStream fs = new FireComboStream(this, vec, player.getLocation().clone().add(0, 1, 0), range, speed, + "FireSpin"); fs.setSpread(0.0F); fs.setDensity(1); fs.setUseNewParticles(true); @@ -354,7 +356,8 @@ public class FireCombo implements ConfigLoadable { } player.setVelocity(player.getVelocity().normalize().multiply(speed)); - FireComboStream fs = new FireComboStream(this, player.getVelocity().clone().multiply(-1), player.getLocation(), 3, 0.5, "JetBlast"); + FireComboStream fs = new FireComboStream(this, player.getVelocity().clone().multiply(-1), player.getLocation(), + 3, 0.5, "JetBlast"); fs.setDensity(1); fs.setSpread(0.9F); fs.setUseNewParticles(true); @@ -477,8 +480,8 @@ public class FireCombo implements ConfigLoadable { } /** - * Removes this instance of FireCombo, cleans up any blocks that are - * remaining in totalBlocks, and cancels any remaining tasks. + * Removes this instance of FireCombo, cleans up any blocks that are remaining in totalBlocks, + * and cancels any remaining tasks. */ public void remove() { instances.remove(this); @@ -530,7 +533,7 @@ public class FireCombo implements ConfigLoadable { public String getAbility() { return this.ability; } - + public boolean isCancelled() { return cancelled; } diff --git a/src/com/projectkorra/projectkorra/firebending/FireJet.java b/src/com/projectkorra/projectkorra/firebending/FireJet.java index fd355aff..40576bf5 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireJet.java +++ b/src/com/projectkorra/projectkorra/firebending/FireJet.java @@ -11,14 +11,15 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AvatarState; -import com.projectkorra.projectkorra.airbending.AirBurst; import com.projectkorra.projectkorra.configuration.ConfigLoadable; import com.projectkorra.projectkorra.util.Flight; import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.waterbending.WaterMethods; public class FireJet implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static double defaultfactor = config.get().getDouble("Abilities.Fire.FireJet.Speed"); private static long defaultduration = config.get().getLong("Abilities.Fire.FireJet.Duration"); private static boolean isToggle = config.get().getBoolean("Abilities.Fire.FireJet.IsAvatarStateToggle"); @@ -38,16 +39,16 @@ public class FireJet implements ConfigLoadable { if (bPlayer.isOnCooldown("FireJet")) return; /* End Initial Checks */ - //reloadVariables(); - + // reloadVariables(); + factor = FireMethods.getFirebendingDayAugment(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)); if (FireMethods.canFireGrief()) { FireMethods.createTempFire(block.getLocation()); - } - else block.setType(Material.FIRE); + } else + block.setType(Material.FIRE); this.player = player; // canfly = player.getAllowFlight(); new Flight(player); @@ -93,7 +94,8 @@ public class FireJet implements ConfigLoadable { remove(); return false; } - if ((WaterMethods.isWater(player.getLocation().getBlock()) || System.currentTimeMillis() > time + duration) && (!AvatarState.isAvatarState(player) || !isToggle)) { + if ((WaterMethods.isWater(player.getLocation().getBlock()) || System.currentTimeMillis() > time + duration) + && (!AvatarState.isAvatarState(player) || !isToggle)) { // player.setAllowFlight(canfly); remove(); } else { @@ -117,7 +119,7 @@ public class FireJet implements ConfigLoadable { } return true; } - + public static void progressAll() { for (FireJet ability : instances.values()) { ability.progress(); @@ -130,11 +132,11 @@ public class FireJet implements ConfigLoadable { defaultduration = config.get().getLong("Abilities.Fire.FireJet.Duration"); isToggle = config.get().getBoolean("Abilities.Fire.FireJet.IsAvatarStateToggle"); } - + public void remove() { instances.remove(player); } - + public static void removeAll() { for (FireJet ability : instances.values()) { ability.remove(); diff --git a/src/com/projectkorra/projectkorra/firebending/FireMethods.java b/src/com/projectkorra/projectkorra/firebending/FireMethods.java index 5d066bd7..b3193b86 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireMethods.java +++ b/src/com/projectkorra/projectkorra/firebending/FireMethods.java @@ -28,7 +28,7 @@ public class FireMethods { static ProjectKorra plugin; private static FileConfiguration config = ProjectKorra.plugin.getConfig(); - + public static ConcurrentHashMap tempFire = new ConcurrentHashMap(); public FireMethods(ProjectKorra plugin) { @@ -46,24 +46,46 @@ public class FireMethods { return true; return false; } - - /**Returns if fire is allowed to completely replace blocks or if it should place a temp fire block.*/ + + /** + * Returns if fire is allowed to completely replace blocks or if it should place a temp fire + * block. + */ public static boolean canFireGrief() { return config.getBoolean("Properties.Fire.FireGriefing"); } - - /**Creates a fire block meant to replace other blocks but reverts when the fire dissipates or is destroyed.*/ + + /** + * Creates a fire block meant to replace other blocks but reverts when the fire dissipates or is + * destroyed. + */ public static void createTempFire(Location loc) { if (loc.getBlock().getType() == Material.AIR) { loc.getBlock().setType(Material.FIRE); return; } Information info = new Information(); - long time = config.getLong("Properties.Fire.RevertTicks") + (long)(GeneralMethods.rand.nextDouble() * config.getLong("Properties.Fire.RevertTicks")); //Generate a long between the config time and config time x 2. Just so it appears random + long time = config.getLong("Properties.Fire.RevertTicks") + + (long) (GeneralMethods.rand.nextDouble() * config.getLong("Properties.Fire.RevertTicks")); // Generate + // a + // long + // between + // the + // config + // time + // and + // config + // time + // x + // 2. + // Just + // so + // it + // appears + // random if (tempFire.containsKey(loc)) { info = tempFire.get(loc); - } - else { + } else { info.setBlock(loc.getBlock()); info.setLocation(loc); info.setState(loc.getBlock().getState()); @@ -74,13 +96,11 @@ public class FireMethods { } /** - * Gets the firebending dayfactor from the config multiplied by a specific - * value if it is day. + * Gets the firebending dayfactor from the config multiplied by a specific value if it is day. * * @param value The value * @param world The world to pass into {@link #isDay(World)} - * @return value DayFactor multiplied by specified value when - * {@link #isDay(World)} is true
+ * @return value DayFactor multiplied by specified value when {@link #isDay(World)} is true
* else
* value The specified value in the parameters */ @@ -109,7 +129,7 @@ public class FireMethods { public static ChatColor getFireColor() { return ChatColor.valueOf(config.getString("Properties.Chat.Colors.Fire")); } - + /** * Gets the FireSubColor from the config. * @@ -179,22 +199,22 @@ public class FireMethods { list.add("FireShield"); return GeneralMethods.blockAbilities(null, list, loc, 0); } - - /**Removes all temp fire that no longer needs to be there*/ + + /** Removes all temp fire that no longer needs to be there */ public static void removeFire() { Iterator it = tempFire.keySet().iterator(); - while(it.hasNext()) { + while (it.hasNext()) { Location loc = it.next(); Information info = tempFire.get(loc); - if (info.getLocation().getBlock().getType() != Material.FIRE && info.getLocation().getBlock().getType() != Material.AIR) { + if (info.getLocation().getBlock().getType() != Material.FIRE + && info.getLocation().getBlock().getType() != Material.AIR) { revertTempFire(loc); - } - else if (info.getBlock().getType() == Material.AIR || System.currentTimeMillis() > info.getTime()) { + } else if (info.getBlock().getType() == Material.AIR || System.currentTimeMillis() > info.getTime()) { revertTempFire(loc); } } } - + /** * Revert the temp fire at the location if any is there. * @@ -202,14 +222,18 @@ public class FireMethods { * */ @SuppressWarnings("deprecation") public static void revertTempFire(Location location) { - if (!tempFire.containsKey(location)) return; + if (!tempFire.containsKey(location)) + return; Information info = tempFire.get(location); if (info.getLocation().getBlock().getType() != Material.FIRE && info.getLocation().getBlock().getType() != Material.AIR) { if (info.getState().getType() == Material.RED_ROSE || info.getState().getType() == Material.YELLOW_FLOWER) { - info.getState().getBlock().getWorld().dropItemNaturally(info.getLocation(), new ItemStack(info.getState().getData().getItemType(), 1, info.getState().getRawData())); + info.getState() + .getBlock() + .getWorld() + .dropItemNaturally(info.getLocation(), + new ItemStack(info.getState().getData().getItemType(), 1, info.getState().getRawData())); } - } - else { + } else { info.getBlock().setType(info.getState().getType()); info.getBlock().setData(info.getState().getRawData()); } @@ -228,7 +252,7 @@ public class FireMethods { Cook.removeAll(); Illumination.removeAll(); FireCombo.removeAll(); - for (Location loc : tempFire.keySet()){ + for (Location loc : tempFire.keySet()) { revertTempFire(loc); } } diff --git a/src/com/projectkorra/projectkorra/firebending/FireShield.java b/src/com/projectkorra/projectkorra/firebending/FireShield.java index 34338302..86839f39 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireShield.java +++ b/src/com/projectkorra/projectkorra/firebending/FireShield.java @@ -22,7 +22,9 @@ import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.waterbending.WaterManipulation; public class FireShield implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static long interval = 100; private static long DURATION = config.get().getLong("Abilities.Fire.FireShield.Duration"); private static double RADIUS = config.get().getDouble("Abilities.Fire.FireShield.Radius"); @@ -50,7 +52,7 @@ public class FireShield implements ConfigLoadable { if (bPlayer.isOnCooldown("FireShield")) return; /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); this.player = player; this.shield = shield; @@ -64,7 +66,11 @@ public class FireShield implements ConfigLoadable { } public static String getDescription() { - return "FireShield is a basic defensive ability. " + "Clicking with this ability selected will create a " + "small disc of fire in front of you, which will block most " + "attacks and bending. Alternatively, pressing and holding " + "sneak creates a very small shield of fire, blocking most attacks. " + "Creatures that contact this fire are ignited."; + return "FireShield is a basic defensive ability. " + "Clicking with this ability selected will create a " + + "small disc of fire in front of you, which will block most " + + "attacks and bending. Alternatively, pressing and holding " + + "sneak creates a very small shield of fire, blocking most attacks. " + + "Creatures that contact this fire are ignited."; } public static boolean isWithinShield(Location loc) { @@ -143,7 +149,10 @@ public class FireShield implements ConfigLoadable { for (double phi = 0; phi < 360; phi += 20) { double rphi = Math.toRadians(phi); double rtheta = Math.toRadians(theta); - Block block = location.clone().add(radius * Math.cos(rphi) * Math.sin(rtheta), radius * Math.cos(rtheta), radius * Math.sin(rphi) * Math.sin(rtheta)).getBlock(); + Block block = location + .clone() + .add(radius * Math.cos(rphi) * Math.sin(rtheta), radius * Math.cos(rtheta), + radius * Math.sin(rphi) * Math.sin(rtheta)).getBlock(); if (!blocks.contains(block) && !GeneralMethods.isSolid(block) && !block.isLiquid()) blocks.add(block); } @@ -160,7 +169,7 @@ public class FireShield implements ConfigLoadable { } } } - + for (Block testblock : GeneralMethods.getBlocksAroundPoint(player.getLocation(), radius)) { if (testblock.getType() == Material.FIRE) { testblock.setType(Material.AIR); @@ -177,9 +186,9 @@ public class FireShield implements ConfigLoadable { } } - FireBlast.removeFireBlastsAroundPoint(location, radius+1); - FireStream.removeAroundPoint(location, radius+1); - Combustion.removeAroundPoint(location, radius+1); + FireBlast.removeFireBlastsAroundPoint(location, radius + 1); + FireStream.removeAroundPoint(location, radius + 1); + Combustion.removeAroundPoint(location, radius + 1); } else { ArrayList blocks = new ArrayList(); @@ -202,7 +211,7 @@ public class FireShield implements ConfigLoadable { for (Block block : blocks) { if (!GeneralMethods.isRegionProtectedFromBuild(player, "FireShield", block.getLocation())) { if (GeneralMethods.rand.nextInt(1) == 0) { - ParticleEffect.SMOKE.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 1); + ParticleEffect.SMOKE.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 1); } ParticleEffect.FLAME.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 3); if (GeneralMethods.rand.nextInt(4) == 0) { @@ -236,17 +245,17 @@ public class FireShield implements ConfigLoadable { } return true; } - + public static void progressAll() { for (FireShield ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(player); } - + public static void removeAll() { for (FireShield ability : instances.values()) { ability.remove(); diff --git a/src/com/projectkorra/projectkorra/firebending/FireStream.java b/src/com/projectkorra/projectkorra/firebending/FireStream.java index 5346398e..d2257a48 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireStream.java +++ b/src/com/projectkorra/projectkorra/firebending/FireStream.java @@ -18,7 +18,8 @@ import com.projectkorra.projectkorra.waterbending.Plantbending; import com.projectkorra.projectkorra.waterbending.WaterMethods; public class FireStream implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); public static ConcurrentHashMap ignitedblocks = new ConcurrentHashMap(); public static ConcurrentHashMap ignitedtimes = new ConcurrentHashMap(); public static ConcurrentHashMap replacedBlocks = new ConcurrentHashMap(); @@ -30,7 +31,7 @@ public class FireStream implements ConfigLoadable { private static int firedamage = 3; @SuppressWarnings("unused") private static int tickdamage = 2; - + private static int idCounter = 0; private static double speed = 15; private static long interval = (long) (1000. / speed); @@ -80,7 +81,8 @@ public class FireStream implements ConfigLoadable { public static boolean isIgnitable(Player player, Block block) { - Material[] overwriteable = { Material.SAPLING, Material.LONG_GRASS, Material.DEAD_BUSH, Material.YELLOW_FLOWER, Material.RED_ROSE, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.FIRE, Material.SNOW, Material.TORCH }; + Material[] overwriteable = { Material.SAPLING, Material.LONG_GRASS, Material.DEAD_BUSH, Material.YELLOW_FLOWER, + Material.RED_ROSE, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.FIRE, Material.SNOW, Material.TORCH }; if (Arrays.asList(overwriteable).contains(block.getType())) { return true; @@ -88,8 +90,24 @@ public class FireStream implements ConfigLoadable { return false; } - Material[] ignitable = { Material.BEDROCK, Material.BOOKSHELF, Material.BRICK, Material.CLAY, Material.CLAY_BRICK, Material.COAL_ORE, Material.COBBLESTONE, Material.DIAMOND_ORE, Material.DIAMOND_BLOCK, Material.DIRT, Material.ENDER_STONE, Material.GLOWING_REDSTONE_ORE, Material.GOLD_BLOCK, Material.GRAVEL, Material.GRASS, Material.HUGE_MUSHROOM_1, Material.HUGE_MUSHROOM_2, Material.LAPIS_BLOCK, Material.LAPIS_ORE, Material.LOG, Material.MOSSY_COBBLESTONE, Material.MYCEL, Material.NETHER_BRICK, Material.NETHERRACK, Material.OBSIDIAN, Material.REDSTONE_ORE, Material.SAND, Material.SANDSTONE, Material.SMOOTH_BRICK, Material.STONE, Material.SOUL_SAND, Material.WOOD, // Material.SNOW_BLOCK, - Material.WOOL, Material.LEAVES, Material.LEAVES_2, Material.MELON_BLOCK, Material.PUMPKIN, Material.JACK_O_LANTERN, Material.NOTE_BLOCK, Material.GLOWSTONE, Material.IRON_BLOCK, Material.DISPENSER, Material.SPONGE, Material.IRON_ORE, Material.GOLD_ORE, Material.COAL_BLOCK, Material.WORKBENCH, Material.HAY_BLOCK, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.EMERALD_ORE, Material.EMERALD_BLOCK, Material.REDSTONE_BLOCK, Material.QUARTZ_BLOCK, Material.QUARTZ_ORE, Material.STAINED_CLAY, Material.HARD_CLAY }; + Material[] ignitable = { Material.BEDROCK, Material.BOOKSHELF, Material.BRICK, Material.CLAY, Material.CLAY_BRICK, + Material.COAL_ORE, Material.COBBLESTONE, Material.DIAMOND_ORE, Material.DIAMOND_BLOCK, Material.DIRT, + Material.ENDER_STONE, Material.GLOWING_REDSTONE_ORE, Material.GOLD_BLOCK, Material.GRAVEL, Material.GRASS, + Material.HUGE_MUSHROOM_1, Material.HUGE_MUSHROOM_2, Material.LAPIS_BLOCK, Material.LAPIS_ORE, Material.LOG, + Material.MOSSY_COBBLESTONE, Material.MYCEL, Material.NETHER_BRICK, Material.NETHERRACK, Material.OBSIDIAN, + Material.REDSTONE_ORE, + Material.SAND, + Material.SANDSTONE, + Material.SMOOTH_BRICK, + Material.STONE, + Material.SOUL_SAND, + Material.WOOD, // Material.SNOW_BLOCK, + Material.WOOL, Material.LEAVES, Material.LEAVES_2, Material.MELON_BLOCK, Material.PUMPKIN, + Material.JACK_O_LANTERN, Material.NOTE_BLOCK, Material.GLOWSTONE, Material.IRON_BLOCK, Material.DISPENSER, + Material.SPONGE, Material.IRON_ORE, Material.GOLD_ORE, Material.COAL_BLOCK, Material.WORKBENCH, + Material.HAY_BLOCK, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.EMERALD_ORE, + Material.EMERALD_BLOCK, Material.REDSTONE_BLOCK, Material.QUARTZ_BLOCK, Material.QUARTZ_ORE, + Material.STAINED_CLAY, Material.HARD_CLAY }; Block belowblock = block.getRelative(BlockFace.DOWN); if (Arrays.asList(ignitable).contains(belowblock.getType())) { @@ -117,7 +135,7 @@ public class FireStream implements ConfigLoadable { public static void removeAll() { for (Block block : ignitedblocks.keySet()) remove(block); - + Iterator iter = instances.keySet().iterator(); while (iter.hasNext()) { Integer key = iter.next(); @@ -145,8 +163,9 @@ public class FireStream implements ConfigLoadable { private void ignite(Block block) { if (block.getType() != Material.AIR) { if (FireMethods.canFireGrief()) { - if (WaterMethods.isPlant(block)) new Plantbending(block); - } else if (block.getType() != Material.FIRE){ + if (WaterMethods.isPlant(block)) + new Plantbending(block); + } else if (block.getType() != Material.FIRE) { replacedBlocks.put(block.getLocation(), block.getState().getData()); } } @@ -184,13 +203,13 @@ public class FireStream implements ConfigLoadable { } return false; } - + public static void progressAll() { for (FireStream ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(id); } diff --git a/src/com/projectkorra/projectkorra/firebending/Fireball.java b/src/com/projectkorra/projectkorra/firebending/Fireball.java index 21fc4648..a583377f 100644 --- a/src/com/projectkorra/projectkorra/firebending/Fireball.java +++ b/src/com/projectkorra/projectkorra/firebending/Fireball.java @@ -25,9 +25,10 @@ import com.projectkorra.projectkorra.util.ParticleEffect; */ public class Fireball implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static ConcurrentHashMap explosions = new ConcurrentHashMap(); - + private static long defaultchargetime = config.get().getLong("Abilities.Fire.FireBlast.Charged.ChargeTime"); private static long interval = 25; private static double radius = 1.5; @@ -156,8 +157,7 @@ public class Fireball implements ConfigLoadable { } } if (explode) { - if (damage_blocks && explosionradius > 0) - { + if (damage_blocks && explosionradius > 0) { explosion = player.getWorld().spawn(location, TNTPrimed.class); explosion.setFuseTicks(0); float yield = (float) explosionradius; @@ -170,14 +170,10 @@ public class Fireball implements ConfigLoadable { } explosion.setYield(yield); explosions.put(explosion, this); - } - else - { + } else { List l = GeneralMethods.getEntitiesAroundPoint(location, damageradius); - for (Entity e : l) - { - if (e instanceof LivingEntity) - { + for (Entity e : l) { + if (e instanceof LivingEntity) { double slope = -(maxdamage * .5) / (damageradius - innerradius); double damage = slope * (e.getLocation().distance(location) - innerradius) + maxdamage; GeneralMethods.damageEntity(getPlayer(), e, damage, "FireBlast"); @@ -187,7 +183,7 @@ public class Fireball implements ConfigLoadable { ParticleEffect.EXPLOSION_HUGE.display(new Vector(0, 0, 0), 0, location, 256); } } - + ignite(location); remove(); } @@ -224,11 +220,11 @@ public class Fireball implements ConfigLoadable { public double getDamageRadius() { return damageradius; } - + public double getExplosionRadius() { return explosionradius; } - + public boolean getDamageBlocks() { return this.damage_blocks; } @@ -331,17 +327,17 @@ public class Fireball implements ConfigLoadable { } return true; } - + public static void progressAll() { for (Fireball ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(id); } - + public static void removeAll() { for (Fireball ability : instances.values()) { ability.remove(); @@ -372,12 +368,12 @@ public class Fireball implements ConfigLoadable { public void setChargetime(long chargetime) { this.chargetime = chargetime; } - + public void setDamageBlocks(boolean damageblocks) { this.damage_blocks = damageblocks; } - - public void setExplosionRadius (double radius) { + + public void setExplosionRadius(double radius) { this.explosionradius = radius; } diff --git a/src/com/projectkorra/projectkorra/firebending/HeatControl.java b/src/com/projectkorra/projectkorra/firebending/HeatControl.java index 733bb8c1..0cb6adf8 100644 --- a/src/com/projectkorra/projectkorra/firebending/HeatControl.java +++ b/src/com/projectkorra/projectkorra/firebending/HeatControl.java @@ -20,7 +20,9 @@ import com.projectkorra.projectkorra.util.TempBlock; * Created by Carbogen on 11/02/15. Ability HeatControl */ public class HeatControl implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + public static double RANGE = config.get().getDouble("Abilities.Fire.HeatControl.Solidify.Range"); public static int RADIUS = config.get().getInt("Abilities.Fire.HeatControl.Solidify.Radius"); public static int REVERT_TIME = config.get().getInt("Abilities.Fire.HeatControl.Solidify.RevertTime"); @@ -153,7 +155,7 @@ public class HeatControl implements ConfigLoadable { freeze(area); return true; } - + public static void progressAll() { for (HeatControl ability : instances.values()) { ability.progress(); diff --git a/src/com/projectkorra/projectkorra/firebending/HeatMelt.java b/src/com/projectkorra/projectkorra/firebending/HeatMelt.java index 25d7ea13..b7a78324 100644 --- a/src/com/projectkorra/projectkorra/firebending/HeatMelt.java +++ b/src/com/projectkorra/projectkorra/firebending/HeatMelt.java @@ -16,9 +16,11 @@ public class HeatMelt implements ConfigLoadable { private static int radius = config.get().getInt("Abilities.Fire.HeatControl.Melt.Radius"); public HeatMelt(Player player) { - //reloadVariables(); - Location location = GeneralMethods.getTargetedLocation(player, (int) FireMethods.getFirebendingDayAugment(range, player.getWorld())); - for (Block block : GeneralMethods.getBlocksAroundPoint(location, (int) FireMethods.getFirebendingDayAugment(radius, player.getWorld()))) { + // reloadVariables(); + Location location = GeneralMethods.getTargetedLocation(player, + (int) FireMethods.getFirebendingDayAugment(range, player.getWorld())); + for (Block block : GeneralMethods.getBlocksAroundPoint(location, + (int) FireMethods.getFirebendingDayAugment(radius, player.getWorld()))) { if (WaterMethods.isMeltable(block)) { Melt.melt(player, block); } else if (isHeatable(block)) { diff --git a/src/com/projectkorra/projectkorra/firebending/Illumination.java b/src/com/projectkorra/projectkorra/firebending/Illumination.java index 25c18a68..b2dd755e 100644 --- a/src/com/projectkorra/projectkorra/firebending/Illumination.java +++ b/src/com/projectkorra/projectkorra/firebending/Illumination.java @@ -12,7 +12,8 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.configuration.ConfigLoadable; public class Illumination implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); public static ConcurrentHashMap blocks = new ConcurrentHashMap(); private static int range = config.get().getInt("Abilities.Fire.Illumination.Range"); @@ -32,7 +33,7 @@ public class Illumination implements ConfigLoadable { if (instances.containsKey(player)) { instances.get(player).remove(); } else { - //reloadVariables(); + // reloadVariables(); this.player = player; set(); instances.put(player, this); @@ -41,7 +42,11 @@ public class Illumination implements ConfigLoadable { } public static String getDescription() { - return "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking " + "will create a torch that follows you around. The torch will only appear on objects that are " + "ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, " + "it will disappear, but will reappear when you get on another ignitable block. Clicking again " + "dismisses this torch."; + return "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking " + + "will create a torch that follows you around. The torch will only appear on objects that are " + + "ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, " + + "it will disappear, but will reappear when you get on another ignitable block. Clicking again " + + "dismisses this torch."; } public static void revert(Block block) { @@ -49,25 +54,25 @@ public class Illumination implements ConfigLoadable { instances.get(player).revert(); } - // public static void manage(Server server) { - // for (Player player : server.getOnlinePlayers()) { - // if (instances.containsKey(player)) { - // if (!GeneralMethods.canBend(player.getName(), "Illumination")) { - // instances.get(player).revert(); - // instances.remove(player); - // } else { - // instances.get(player).set(); - // } - // } - // } + // public static void manage(Server server) { + // for (Player player : server.getOnlinePlayers()) { + // if (instances.containsKey(player)) { + // if (!GeneralMethods.canBend(player.getName(), "Illumination")) { + // instances.get(player).revert(); + // instances.remove(player); + // } else { + // instances.get(player).set(); + // } + // } + // } // - // for (Player player : instances.keySet()) { - // if (!player.isOnline() || player.isDead()) { - // instances.get(player).revert(); - // instances.remove(player); - // } - // } - // } + // for (Player player : instances.keySet()) { + // if (!player.isOnline() || player.isDead()) { + // instances.get(player).revert(); + // instances.remove(player); + // } + // } + // } public boolean progress() { if (!player.isOnline() || player.isDead()) { @@ -82,7 +87,7 @@ public class Illumination implements ConfigLoadable { } return true; } - + public static void progressAll() { for (Illumination ability : instances.values()) { ability.progress(); @@ -98,7 +103,7 @@ public class Illumination implements ConfigLoadable { revert(); instances.remove(player); } - + public static void removeAll() { for (Illumination ability : instances.values()) { ability.remove(); @@ -120,13 +125,18 @@ public class Illumination implements ConfigLoadable { Block standblock = standingblock.getRelative(BlockFace.DOWN); if (standblock.getType() == Material.GLOWSTONE) { revert(); - } else if ((FireStream.isIgnitable(player, standingblock) && standblock.getType() != Material.LEAVES && standblock.getType() != Material.LEAVES_2) && block == null && !blocks.containsKey(standblock)) { + } else if ((FireStream.isIgnitable(player, standingblock) && standblock.getType() != Material.LEAVES && standblock + .getType() != Material.LEAVES_2) && block == null && !blocks.containsKey(standblock)) { block = standingblock; normaltype = block.getType(); normaldata = block.getData(); block.setType(Material.TORCH); blocks.put(block, player); - } else if ((FireStream.isIgnitable(player, standingblock) && standblock.getType() != Material.LEAVES && standblock.getType() != Material.LEAVES_2) && !block.equals(standblock) && !blocks.containsKey(standblock) && GeneralMethods.isSolid(standblock)) { + } else if ((FireStream.isIgnitable(player, standingblock) && standblock.getType() != Material.LEAVES && standblock + .getType() != Material.LEAVES_2) + && !block.equals(standblock) + && !blocks.containsKey(standblock) + && GeneralMethods.isSolid(standblock)) { revert(); block = standingblock; normaltype = block.getType(); @@ -137,7 +147,8 @@ public class Illumination implements ConfigLoadable { return; } else if (!player.getWorld().equals(block.getWorld())) { revert(); - } else if (player.getLocation().distance(block.getLocation()) > FireMethods.getFirebendingDayAugment(range, player.getWorld())) { + } else if (player.getLocation().distance(block.getLocation()) > FireMethods.getFirebendingDayAugment(range, + player.getWorld())) { revert(); } } diff --git a/src/com/projectkorra/projectkorra/firebending/Lightning.java b/src/com/projectkorra/projectkorra/firebending/Lightning.java index 516d524b..375ebf28 100644 --- a/src/com/projectkorra/projectkorra/firebending/Lightning.java +++ b/src/com/projectkorra/projectkorra/firebending/Lightning.java @@ -23,6 +23,7 @@ import com.projectkorra.projectkorra.configuration.ConfigLoadable; import com.projectkorra.projectkorra.earthbending.EarthMethods; public class Lightning implements ConfigLoadable { + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); public static boolean SELF_HIT_WATER = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitWater"); @@ -375,17 +376,17 @@ public class Lightning implements ConfigLoadable { } return true; } - + public static void progressAll() { for (Lightning ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(id); } - + public static void removeAll() { for (Lightning ability : instances.values()) { ability.remove(); diff --git a/src/com/projectkorra/projectkorra/firebending/RingOfFire.java b/src/com/projectkorra/projectkorra/firebending/RingOfFire.java index 5e284693..09c8f6f1 100644 --- a/src/com/projectkorra/projectkorra/firebending/RingOfFire.java +++ b/src/com/projectkorra/projectkorra/firebending/RingOfFire.java @@ -19,7 +19,7 @@ public class RingOfFire implements ConfigLoadable { if (bPlayer.isOnCooldown("Blaze")) return; /* End Initial Checks */ - //reloadVariables(); + // reloadVariables(); Location location = player.getLocation(); for (double degrees = 0; degrees < 360; degrees += 10) { @@ -47,8 +47,7 @@ public class RingOfFire implements ConfigLoadable { } public static String getDescription() { - return "To use, simply left-click. " - + "A circle of fire will emanate from you, " + return "To use, simply left-click. " + "A circle of fire will emanate from you, " + "engulfing everything around you. Use with extreme caution."; } diff --git a/src/com/projectkorra/projectkorra/firebending/WallOfFire.java b/src/com/projectkorra/projectkorra/firebending/WallOfFire.java index 414a41ed..470eaab4 100644 --- a/src/com/projectkorra/projectkorra/firebending/WallOfFire.java +++ b/src/com/projectkorra/projectkorra/firebending/WallOfFire.java @@ -20,8 +20,9 @@ import com.projectkorra.projectkorra.configuration.ConfigLoadable; import com.projectkorra.projectkorra.util.ParticleEffect; public class WallOfFire implements ConfigLoadable { - public static final ConcurrentHashMap instances = new ConcurrentHashMap<>(); - + + public static ConcurrentHashMap instances = new ConcurrentHashMap<>(); + private static double maxangle = 50; private static int RANGE = config.get().getInt("Abilities.Fire.WallOfFire.Range"); @@ -222,17 +223,17 @@ public class WallOfFire implements ConfigLoadable { } return true; } - + public static void progressAll() { for (WallOfFire ability : instances.values()) { ability.progress(); } } - + public void remove() { instances.remove(player); } - + public static void removeAll() { for (WallOfFire ability : instances.values()) { ability.remove();