mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-12 03:59:06 +00:00
Revert FireAbilities Part 1
This commit is contained in:
parent
7105b0c4c7
commit
10414ffd90
11 changed files with 198 additions and 560 deletions
|
@ -1,333 +0,0 @@
|
|||
package com.projectkorra.projectkorra.ability.api;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Represents the core of all ProjectKorra abilities and implements the
|
||||
* {@link Ability} interface.
|
||||
*
|
||||
* @author jacklin213
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public abstract class CoreAbility implements Ability {
|
||||
|
||||
/**
|
||||
* ConcurrentHashMap that stores all Ability instances under UUID key. To
|
||||
* access this HashMap use either {@link #getInstance()} from the ability
|
||||
* instance or {@link #getInstance(StockAbility)} from the outside.
|
||||
*/
|
||||
private static final ConcurrentHashMap<Integer, CoreAbility> instances = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<StockAbility, ArrayList<Integer>> abilityMap = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<Class<? extends CoreAbility>, ConcurrentHashMap<Integer, CoreAbility>> classAbilityMap = new ConcurrentHashMap<>();
|
||||
|
||||
private static int ID = Integer.MIN_VALUE;
|
||||
|
||||
private final StockAbility stockAbility = getStockAbility();
|
||||
private Player player;
|
||||
private UUID uniqueId;
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* Convenience method to check if a player already has an instance of this
|
||||
* ability.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if instances contains the player
|
||||
*/
|
||||
public static final boolean containsPlayer(Player player, Class<? extends CoreAbility> ability) {
|
||||
CoreAbility coreAbility = getAbilityFromPlayer(player, ability);
|
||||
return coreAbility != null ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of ability instances that the player has created.
|
||||
*
|
||||
* @param player The player to get
|
||||
* @return list of abilities
|
||||
*/
|
||||
public static List<CoreAbility> getAbilitiesFromPlayer(Player player) {
|
||||
List<CoreAbility> abilities = new ArrayList<>();
|
||||
for (CoreAbility ability : instances.values()) {
|
||||
if (ability.getPlayer().getUniqueId().equals(player.getUniqueId())) {
|
||||
abilities.add(ability);
|
||||
}
|
||||
}
|
||||
return abilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ability instance of the player.
|
||||
*
|
||||
* @param player The player to get
|
||||
* @param ability The ability class
|
||||
* @return the ability instance or null
|
||||
*/
|
||||
public static CoreAbility getAbilityFromPlayer(Player player, Class<? extends CoreAbility> ability) {
|
||||
for (CoreAbility coreAbility : instances.values()) {
|
||||
if (ability.isInstance(coreAbility)) {
|
||||
if (coreAbility.getPlayer().getUniqueId().equals(player.getUniqueId())) {
|
||||
return coreAbility;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ability instance by its id.
|
||||
*
|
||||
* @param id The ability id to get
|
||||
* @return the ability instance or null
|
||||
*/
|
||||
public static final CoreAbility getAbility(int id) {
|
||||
return instances.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* An access method to get an the instances of a {@link StockAbility}.
|
||||
* <b>IMPORTANT: </b> If this is used in a for each loop use
|
||||
* {@link #getAbility(int)} to get the ability. Incorrect usage may cause
|
||||
* over looping and is capable of hanging the thead.
|
||||
*
|
||||
* @param ability The instances map to get
|
||||
* @return a map of instances from the specified {@link StockAbility}
|
||||
* @see #getInstances(StockAbility)
|
||||
*/
|
||||
public final static ConcurrentHashMap<Integer, CoreAbility> getInstances(StockAbility ability) {
|
||||
ConcurrentHashMap<Integer, CoreAbility> instanceMap = new ConcurrentHashMap<>();
|
||||
if (abilityMap.containsKey(ability)) {
|
||||
for (Integer id : abilityMap.get(ability)) {
|
||||
instanceMap.put(id, instances.get(id));
|
||||
}
|
||||
}
|
||||
return instanceMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* An access method to get an the instances of a {@link CoreAbility} by its
|
||||
* class. <b>IMPORTANT: </b> If this is used in a for each loop use
|
||||
* {@link #getAbility(int)} to get the ability. Incorrect usage may cause
|
||||
* over looping and is capable of hanging the thead.
|
||||
*
|
||||
* @param ability The instances map to get
|
||||
* @return a map of instances from the specified class
|
||||
* @see #getInstances(StockAbility)
|
||||
*/
|
||||
public final static ConcurrentHashMap<Integer, CoreAbility> getInstances(Class<? extends CoreAbility> ability) {
|
||||
ConcurrentHashMap<Integer, CoreAbility> instanceMap = classAbilityMap.get(ability.getClass());
|
||||
return instanceMap != null ? instanceMap : new ConcurrentHashMap<Integer, CoreAbility>();
|
||||
}
|
||||
|
||||
//TODO: Update bending managers to use below method
|
||||
// /**
|
||||
// * Convenience method that calls {@link #progress()} for all instances.
|
||||
// *
|
||||
// * @see #progressAll(Class)
|
||||
// * @see #progressAll(StockAbility)
|
||||
// */
|
||||
// public static void progressAll() {
|
||||
// for (Integer id : instances.keySet()) {
|
||||
// instances.get(id).progress();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Convenience method that calls {@link #progress()} for all instances of a
|
||||
* specified ability.
|
||||
*
|
||||
* @see #progressAll(StockAbility)
|
||||
*/
|
||||
public static void progressAll(Class<? extends CoreAbility> ability) {
|
||||
ConcurrentHashMap<Integer, CoreAbility> classAbilities = classAbilityMap.get(ability);
|
||||
if (classAbilities != null) {
|
||||
for (Integer id : classAbilities.keySet()) {
|
||||
classAbilities.get(id).progress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method that calls {@link #progress()} for all instances of a
|
||||
* specified stock ability.
|
||||
*
|
||||
* @see #progressAll(Class)
|
||||
*/
|
||||
public static void progressAll(StockAbility ability) {
|
||||
for (Integer id : getInstances(ability).keySet()) {
|
||||
getInstances(ability).get(id).progress();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Update bending managers to use below method
|
||||
// /**
|
||||
// * Convenience method that calls {@link #remove()} for all instances.
|
||||
// *
|
||||
// * @see #removeAll(StockAbility)
|
||||
// * @see #removeAll(Class)
|
||||
// */
|
||||
// public static void removeAll() {
|
||||
// for (Integer id : instances.keySet()) {
|
||||
// instances.get(id).remove();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Convenience method that calls {@link #remove()} for all instances of a
|
||||
* specified stock ability.
|
||||
*
|
||||
* @see #removeAll(StockAbility)
|
||||
*/
|
||||
public static void removeAll(Class<? extends CoreAbility> ability) {
|
||||
for (Integer id : instances.keySet()) {
|
||||
if (ability.isInstance(instances.get(id))) {
|
||||
instances.get(id).remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method that calls {@link #remove()} for all instances of a
|
||||
* specified ability.
|
||||
*
|
||||
* @see #removeAll(Class)
|
||||
*/
|
||||
public static void removeAll(StockAbility ability) {
|
||||
for (Integer id : getInstances(ability).keySet()) {
|
||||
getInstances(ability).get(id).remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if ability is a {@link StockAbility} or not.
|
||||
*
|
||||
* @return true if ability is a stock ability
|
||||
*/
|
||||
public boolean isStockAbility() {
|
||||
return getStockAbility() != null ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id of the ability instance.
|
||||
*
|
||||
* @return id of ability
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to get instance for current ability class.
|
||||
*
|
||||
* @return instance of the current ability
|
||||
*/
|
||||
public CoreAbility getInstance() {
|
||||
return instances.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Ability.InstanceType} of the ability.
|
||||
*
|
||||
* @return single by default
|
||||
*/
|
||||
public InstanceType getInstanceType() {
|
||||
return InstanceType.SINGLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player that invoked the ability.
|
||||
*
|
||||
* @return player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link StockAbility} that created this instance. This method
|
||||
* will return null for abilities that are not stock abilities
|
||||
*
|
||||
* @return StockAbility enum or null
|
||||
*/
|
||||
public abstract StockAbility getStockAbility();
|
||||
|
||||
/**
|
||||
* Gets the {@link UUID} of the player that invoked this ability.
|
||||
*
|
||||
* @return the uuid of the player
|
||||
*/
|
||||
public UUID getUniqueId() {
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put the instance of the ability into the instances map.
|
||||
*
|
||||
* @param player The player
|
||||
* @param ability The ability involved
|
||||
*/
|
||||
protected final void putInstance(Player player, CoreAbility ability) {
|
||||
this.id = ID;
|
||||
this.uniqueId = player.getUniqueId();
|
||||
this.player = player;
|
||||
Class<? extends CoreAbility> classKey = ability.getClass();
|
||||
|
||||
if (!classAbilityMap.containsKey(classKey)) {
|
||||
classAbilityMap.put(classKey, new ConcurrentHashMap<Integer, CoreAbility>());
|
||||
}
|
||||
classAbilityMap.get(classKey).put(id, ability);
|
||||
instances.put(id, ability);
|
||||
|
||||
if (stockAbility != null) {
|
||||
if (abilityMap.containsKey(stockAbility)) {
|
||||
abilityMap.get(stockAbility).add(id);
|
||||
} else {
|
||||
abilityMap.put(stockAbility, new ArrayList<Integer>(Arrays.asList(id)));
|
||||
}
|
||||
}
|
||||
|
||||
if (ID == Integer.MAX_VALUE)
|
||||
ID = Integer.MIN_VALUE;
|
||||
ID++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #removeInstance()}, Developers can override this method to
|
||||
* do other things when remove is called but they <strong>MUST</strong>
|
||||
* remember to call {@code super.remove()} for the ability to be properly
|
||||
* removed from the {@link #instances}.
|
||||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
removeInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the ability instance from the instances map.
|
||||
*/
|
||||
private final void removeInstance() {
|
||||
if (instances.containsKey(id)) {
|
||||
instances.remove(id);
|
||||
}
|
||||
|
||||
if (classAbilityMap.containsKey(this.getClass())) {
|
||||
classAbilityMap.get(this.getClass()).remove(id);
|
||||
}
|
||||
|
||||
if (stockAbility != null) {
|
||||
if (abilityMap.containsKey(stockAbility)) {
|
||||
abilityMap.get(stockAbility).remove(id);
|
||||
if (abilityMap.get(stockAbility).isEmpty()) {
|
||||
abilityMap.remove(stockAbility);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,6 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -17,7 +10,15 @@ import org.bukkit.entity.LivingEntity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Combustion extends CoreAbility {
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
|
||||
public class Combustion implements ConfigLoadable {
|
||||
|
||||
public static long chargeTime = config.get().getLong("Abilities.Fire.Combustion.ChargeTime");
|
||||
public static long cooldown = config.get().getLong("Abilities.Fire.Combustion.Cooldown");
|
||||
|
@ -29,6 +30,8 @@ public class Combustion extends CoreAbility {
|
|||
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<Player, Combustion> instances = new ConcurrentHashMap<>();
|
||||
|
||||
private static final int maxticks = 10000;
|
||||
|
||||
private Location location;
|
||||
|
@ -48,7 +51,7 @@ public class Combustion extends CoreAbility {
|
|||
public Combustion(Player player) {
|
||||
/* Initial Checks */
|
||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||
if (containsPlayer(player, Combustion.class))
|
||||
if (instances.containsKey(player))
|
||||
return;
|
||||
if (bPlayer.isOnCooldown("Combustion"))
|
||||
return;
|
||||
|
@ -74,22 +77,20 @@ public class Combustion extends CoreAbility {
|
|||
return;
|
||||
}
|
||||
|
||||
//instances.put(player, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
bPlayer.addCooldown("Combustion", cooldown);
|
||||
}
|
||||
|
||||
public static void explode(Player player) {
|
||||
if (containsPlayer(player, Combustion.class)) {
|
||||
Combustion combustion = (Combustion) getAbilityFromPlayer(player, Combustion.class);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean removeAroundPoint(Location loc, double radius) {
|
||||
for (Integer id : getInstances(StockAbility.Combustion).keySet()) {
|
||||
Combustion combustion = (Combustion) getAbility(id);
|
||||
for (Combustion combustion : instances.values()) {
|
||||
if (combustion.location.getWorld() == loc.getWorld()) {
|
||||
if (combustion.location.distance(loc) <= radius) {
|
||||
explode(combustion.getPlayer());
|
||||
|
@ -124,14 +125,8 @@ public class Combustion extends CoreAbility {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.Combustion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (!containsPlayer(player, Combustion.class)) {
|
||||
if (!instances.containsKey(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -199,8 +194,11 @@ public class Combustion extends CoreAbility {
|
|||
defaultdamage = config.get().getDouble("Abilities.Fire.Combustion.Damage");
|
||||
}
|
||||
|
||||
// private void launchFireball() {
|
||||
// fireballs.add(player.launchProjectile(org.bukkit.entity.Fireball.class).getEntityId());
|
||||
// }
|
||||
public void remove() {
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.api.AddonAbility;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
|
||||
/**
|
||||
* Used in {@link HeatControl}.
|
||||
*/
|
||||
public class Cook extends AddonAbility {
|
||||
|
||||
public class Cook {
|
||||
public static final ConcurrentHashMap<Player, Cook> 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,
|
||||
|
@ -32,8 +32,7 @@ public class Cook extends AddonAbility {
|
|||
items = player.getItemInHand();
|
||||
time = System.currentTimeMillis();
|
||||
if (isCookable(items.getType())) {
|
||||
//instances.put(player, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +103,6 @@ public class Cook extends AddonAbility {
|
|||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
|
@ -139,8 +137,6 @@ public class Cook extends AddonAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {}
|
||||
|
||||
public void setCooktime(long cooktime) {
|
||||
this.cooktime = cooktime;
|
||||
|
@ -150,4 +146,8 @@ public class Cook extends AddonAbility {
|
|||
this.time = time;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +1,9 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.waterbending.Plantbending;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -23,18 +15,29 @@ import org.bukkit.entity.LivingEntity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.waterbending.Plantbending;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
|
||||
public class FireBlast extends CoreAbility {
|
||||
public class FireBlast implements ConfigLoadable {
|
||||
|
||||
public static ConcurrentHashMap<Integer, FireBlast> instances = new ConcurrentHashMap<>();
|
||||
|
||||
private static double SPEED = config.get().getDouble("Abilities.Fire.FireBlast.Speed");
|
||||
private static double PUSH_FACTOR = config.get().getDouble("Abilities.Fire.FireBlast.Push");
|
||||
private static double RANGE = config.get().getDouble("Abilities.Fire.FireBlast.Range");
|
||||
private static int DAMAGE = config.get().getInt("Abilities.Fire.FireBlast.Damage");
|
||||
private static double fireticks = config.get().getDouble("Abilities.Fire.FireBlast.FireTicks");
|
||||
private static int idCounter = 0;
|
||||
|
||||
/* Package visible variables */
|
||||
static boolean dissipate = config.get().getBoolean("Abilities.Fire.FireBlast.Dissipate");
|
||||
/* End Package visible variables */
|
||||
|
@ -54,6 +57,7 @@ public class FireBlast extends CoreAbility {
|
|||
private Player player;
|
||||
private double speedfactor;
|
||||
private int ticks = 0;
|
||||
private int id = 0;
|
||||
private double range = RANGE;
|
||||
private double damage = DAMAGE;
|
||||
private double speed = SPEED;
|
||||
|
@ -77,8 +81,9 @@ public class FireBlast extends CoreAbility {
|
|||
origin = location.clone();
|
||||
this.direction = direction.clone().normalize();
|
||||
this.damage *= 1.5;
|
||||
//instances.put(id, this);
|
||||
putInstance(player, this);
|
||||
instances.put(idCounter, this);
|
||||
this.id = idCounter;
|
||||
idCounter = (idCounter + 1) % Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public FireBlast(Player player) {
|
||||
|
@ -97,8 +102,9 @@ public class FireBlast extends CoreAbility {
|
|||
origin = player.getEyeLocation();
|
||||
direction = player.getEyeLocation().getDirection().normalize();
|
||||
location = location.add(direction.clone());
|
||||
//instances.put(id, this);
|
||||
putInstance(player, this);
|
||||
instances.put(idCounter, this);
|
||||
this.id = idCounter;
|
||||
idCounter = (idCounter + 1) % Integer.MAX_VALUE;
|
||||
bPlayer.addCooldown("FireBlast", cooldown);
|
||||
// time = System.currentTimeMillis();
|
||||
// timers.put(player, System.currentTimeMillis());
|
||||
|
@ -106,9 +112,7 @@ public class FireBlast extends CoreAbility {
|
|||
|
||||
public static boolean annihilateBlasts(Location location, double radius, Player source) {
|
||||
boolean broke = false;
|
||||
ConcurrentHashMap<Integer, CoreAbility> instances = getInstances(FireBlast.class);
|
||||
for (Integer id : instances.keySet()) {
|
||||
FireBlast blast = (FireBlast) instances.get(id);
|
||||
for (FireBlast blast : instances.values()) {
|
||||
Location fireblastlocation = blast.location;
|
||||
if (location.getWorld() == fireblastlocation.getWorld() && !blast.player.equals(source)) {
|
||||
if (location.distance(fireblastlocation) <= radius) {
|
||||
|
@ -124,9 +128,7 @@ public class FireBlast extends CoreAbility {
|
|||
|
||||
public static ArrayList<FireBlast> getAroundPoint(Location location, double radius) {
|
||||
ArrayList<FireBlast> list = new ArrayList<FireBlast>();
|
||||
ConcurrentHashMap<Integer, CoreAbility> instances = getInstances(FireBlast.class);
|
||||
for (Integer id : instances.keySet()) {
|
||||
FireBlast fireBlast = (FireBlast) instances.get(id);
|
||||
for (FireBlast fireBlast : instances.values()) {
|
||||
Location fireblastlocation = fireBlast.location;
|
||||
if (location.getWorld() == fireblastlocation.getWorld()) {
|
||||
if (location.distance(fireblastlocation) <= radius)
|
||||
|
@ -141,8 +143,7 @@ public class FireBlast extends CoreAbility {
|
|||
}
|
||||
|
||||
public static void removeFireBlastsAroundPoint(Location location, double radius) {
|
||||
for (Integer id : getInstances(StockAbility.FireBlast).keySet()) {
|
||||
FireBlast fireBlast = ((FireBlast)getAbility(id));
|
||||
for (FireBlast fireBlast : instances.values()) {
|
||||
Location fireblastlocation = fireBlast.location;
|
||||
if (location.getWorld() == fireblastlocation.getWorld()) {
|
||||
if (location.distance(fireblastlocation) <= radius)
|
||||
|
@ -193,11 +194,6 @@ public class FireBlast extends CoreAbility {
|
|||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType() {
|
||||
return InstanceType.MULTIPLE;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
@ -214,11 +210,6 @@ public class FireBlast extends CoreAbility {
|
|||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.FireBlast;
|
||||
}
|
||||
|
||||
private void ignite(Location location) {
|
||||
for (Block block : GeneralMethods.getBlocksAroundPoint(location, affectingradius)) {
|
||||
if (FireStream.isIgnitable(player, block) && !safe.contains(block)) {
|
||||
|
@ -239,7 +230,6 @@ public class FireBlast extends CoreAbility {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
|
@ -312,6 +302,10 @@ public class FireBlast extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
SPEED = config.get().getDouble("Abilities.Fire.FireBlast.Speed");
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingManager;
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
@ -15,10 +11,15 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.projectkorra.projectkorra.BendingManager;
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
|
||||
public class FireBurst extends CoreAbility {
|
||||
public class FireBurst implements ConfigLoadable {
|
||||
public static final ConcurrentHashMap<Player, FireBurst> instances = new ConcurrentHashMap<>();
|
||||
private static double PARTICLES_PERCENTAGE = 5;
|
||||
|
||||
private Player player;
|
||||
|
@ -36,7 +37,7 @@ public class FireBurst extends CoreAbility {
|
|||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||
if (bPlayer.isOnCooldown("FireBurst"))
|
||||
return;
|
||||
if (containsPlayer(player, FireBurst.class))
|
||||
if (instances.containsKey(player))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
//reloadVariables();
|
||||
|
@ -52,13 +53,13 @@ public class FireBurst extends CoreAbility {
|
|||
chargetime = 0;
|
||||
}
|
||||
this.player = player;
|
||||
//instances.put(player, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
public static void coneBurst(Player player) {
|
||||
if (containsPlayer(player, FireBurst.class))
|
||||
((FireBurst) getAbilityFromPlayer(player, FireBurst.class)).coneBurst();
|
||||
if (instances.containsKey(player)) {
|
||||
((FireBurst) instances.get(player)).coneBurst();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDescription() {
|
||||
|
@ -111,9 +112,8 @@ public class FireBurst extends CoreAbility {
|
|||
return range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.FireBurst;
|
||||
public void remove() {
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,7 +133,6 @@ public class FireBurst extends CoreAbility {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (!GeneralMethods.canBend(player.getName(), "FireBurst")) {
|
||||
remove();
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FireJet extends CoreAbility {
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
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<Player, FireJet> 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");
|
||||
|
@ -29,8 +29,8 @@ public class FireJet extends CoreAbility {
|
|||
|
||||
public FireJet(Player player) {
|
||||
/* Initial Checks */
|
||||
if (containsPlayer(player, FireJet.class)) {
|
||||
getAbilityFromPlayer(player, FireJet.class).remove();
|
||||
if (instances.containsKey(player)) {
|
||||
instances.get(player).remove();
|
||||
return;
|
||||
}
|
||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||
|
@ -40,7 +40,6 @@ public class FireJet extends CoreAbility {
|
|||
//reloadVariables();
|
||||
|
||||
factor = FireMethods.getFirebendingDayAugment(defaultfactor, player.getWorld());
|
||||
GeneralMethods.invincible.add(this);
|
||||
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));
|
||||
|
@ -54,15 +53,14 @@ public class FireJet extends CoreAbility {
|
|||
player.setAllowFlight(true);
|
||||
time = System.currentTimeMillis();
|
||||
// timers.put(player, time);
|
||||
//instances.put(player, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
bPlayer.addCooldown("FireJet", config.get().getLong("Abilities.Fire.FireJet.Cooldown"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean checkTemporaryImmunity(Player player) {
|
||||
if (containsPlayer(player, FireJet.class)) {
|
||||
if (instances.containsKey(player)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -70,8 +68,8 @@ public class FireJet extends CoreAbility {
|
|||
|
||||
public static ArrayList<Player> getPlayers() {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Integer id : getInstances(StockAbility.FireJet).keySet()) {
|
||||
players.add(getAbility(id).getPlayer());
|
||||
for (FireJet jet : instances.values()) {
|
||||
players.add(jet.getPlayer());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
@ -88,12 +86,6 @@ public class FireJet extends CoreAbility {
|
|||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.FireJet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
// player.setAllowFlight(canfly);
|
||||
|
@ -132,10 +124,8 @@ public class FireJet extends CoreAbility {
|
|||
isToggle = config.get().getBoolean("Abilities.Fire.FireJet.IsAvatarStateToggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
GeneralMethods.invincible.remove(this);
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
@ -18,10 +13,16 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FireShield extends CoreAbility {
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
|
||||
|
||||
public class FireShield implements ConfigLoadable {
|
||||
public static final ConcurrentHashMap<Player, FireShield> 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");
|
||||
|
@ -43,7 +44,7 @@ public class FireShield extends CoreAbility {
|
|||
|
||||
public FireShield(Player player, boolean shield) {
|
||||
/* Initial Checks */
|
||||
if (containsPlayer(player, FireShield.class))
|
||||
if (instances.containsKey(player))
|
||||
return;
|
||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||
if (bPlayer.isOnCooldown("FireShield"))
|
||||
|
@ -56,8 +57,7 @@ public class FireShield extends CoreAbility {
|
|||
if (!player.getEyeLocation().getBlock().isLiquid()) {
|
||||
time = System.currentTimeMillis();
|
||||
starttime = time;
|
||||
//instances.put(player, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
if (!shield)
|
||||
bPlayer.addCooldown("FireShield", GeneralMethods.getGlobalCooldown());
|
||||
}
|
||||
|
@ -68,8 +68,7 @@ public class FireShield extends CoreAbility {
|
|||
}
|
||||
|
||||
public static boolean isWithinShield(Location loc) {
|
||||
for (Integer id : getInstances(StockAbility.FireShield).keySet()) {
|
||||
FireShield fshield = (FireShield) getAbility(id);
|
||||
for (FireShield fshield : instances.values()) {
|
||||
Location playerLoc = fshield.player.getLocation();
|
||||
|
||||
if (fshield.shield) {
|
||||
|
@ -108,7 +107,6 @@ public class FireShield extends CoreAbility {
|
|||
return radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.FireShield;
|
||||
}
|
||||
|
@ -117,7 +115,6 @@ public class FireShield extends CoreAbility {
|
|||
return shield;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (((!player.isSneaking()) && shield) || !GeneralMethods.canBend(player.getName(), "FireShield")) {
|
||||
remove();
|
||||
|
@ -240,6 +237,10 @@ public class FireShield extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
DURATION = config.get().getLong("Abilities.Fire.FireShield.Duration");
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.api.AddonAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.waterbending.Plantbending;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -14,11 +13,12 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class FireStream extends AddonAbility {
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.waterbending.Plantbending;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
|
||||
public class FireStream implements ConfigLoadable {
|
||||
public static final ConcurrentHashMap<Integer, FireStream> instances = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<Block, Player> ignitedblocks = new ConcurrentHashMap<Block, Player>();
|
||||
public static ConcurrentHashMap<Block, Long> ignitedtimes = new ConcurrentHashMap<Block, Long>();
|
||||
public static ConcurrentHashMap<Location, MaterialData> replacedBlocks = new ConcurrentHashMap<Location, MaterialData>();
|
||||
|
@ -31,6 +31,7 @@ public class FireStream extends AddonAbility {
|
|||
@SuppressWarnings("unused")
|
||||
private static int tickdamage = 2;
|
||||
|
||||
private static int idCounter = 0;
|
||||
private static double speed = 15;
|
||||
private static long interval = (long) (1000. / speed);
|
||||
private static long dissipateAfter = 400;
|
||||
|
@ -41,6 +42,7 @@ public class FireStream extends AddonAbility {
|
|||
private Vector direction;
|
||||
private long time;
|
||||
private double range;
|
||||
private int id;
|
||||
|
||||
public FireStream(Location location, Vector direction, Player player, int range) {
|
||||
this.range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
|
||||
|
@ -52,8 +54,9 @@ public class FireStream extends AddonAbility {
|
|||
this.direction = this.direction.clone().normalize();
|
||||
this.location = this.location.clone().add(this.direction);
|
||||
time = System.currentTimeMillis();
|
||||
//instances.put(id, this);
|
||||
putInstance(player, this);
|
||||
instances.put(idCounter, this);
|
||||
this.id = idCounter;
|
||||
idCounter = (idCounter + 1) % Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static void dissipateAll() {
|
||||
|
@ -111,15 +114,19 @@ public class FireStream extends AddonAbility {
|
|||
}
|
||||
}
|
||||
|
||||
public static void removeAll(Class<? extends CoreAbility> abilityClass) {
|
||||
public static void removeAll() {
|
||||
for (Block block : ignitedblocks.keySet())
|
||||
remove(block);
|
||||
AddonAbility.removeAll(abilityClass);
|
||||
|
||||
Iterator<Integer> iter = instances.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Integer key = iter.next();
|
||||
instances.get(key).remove();
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAroundPoint(Location location, double radius) {
|
||||
for (int id : getInstances(FireStream.class).keySet()) {
|
||||
FireStream stream = (FireStream) getAbility(id);
|
||||
for (FireStream stream : instances.values()) {
|
||||
if (stream.location.getWorld().equals(location.getWorld()))
|
||||
if (stream.location.distance(location) <= radius)
|
||||
stream.remove();
|
||||
|
@ -127,11 +134,6 @@ public class FireStream extends AddonAbility {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType() {
|
||||
return InstanceType.MULTIPLE;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
@ -154,7 +156,6 @@ public class FireStream extends AddonAbility {
|
|||
ignitedtimes.put(block, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (System.currentTimeMillis() - time >= interval) {
|
||||
location = location.clone().add(direction);
|
||||
|
@ -184,6 +185,10 @@ public class FireStream extends AddonAbility {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
soonesttime = config.get().getLong("Properties.GlobalCooldown");
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.ability.api.AddonAbility;
|
||||
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
@ -17,19 +14,24 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.airbending.AirMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
|
||||
/**
|
||||
* Ability charged FireBlast
|
||||
*/
|
||||
public class Fireball extends AddonAbility {
|
||||
public class Fireball implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Integer, Fireball> instances = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<Entity, Fireball> explosions = new ConcurrentHashMap<Entity, Fireball>();
|
||||
|
||||
private static long defaultchargetime = config.get().getLong("Abilities.Fire.FireBlast.Charged.ChargeTime");
|
||||
private static long interval = 25;
|
||||
private static double radius = 1.5;
|
||||
private static int idCounter = 0;
|
||||
|
||||
private static double MAX_DAMAGE = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Damage");
|
||||
private static double DAMAGE_RADIUS = config.get().getDouble("Abilities.Fire.FireBlast.Charged.DamageRadius");
|
||||
|
@ -38,6 +40,7 @@ public class Fireball extends AddonAbility {
|
|||
private static boolean DAMAGEBLOCKS = config.get().getBoolean("Abilities.Fire.FireBlast.Charged.DamageBlocks");
|
||||
private static double fireticks = config.get().getDouble("Abilities.Fire.FireBlast.Charged.FireTicks");
|
||||
|
||||
private int id;
|
||||
private double maxdamage = MAX_DAMAGE;
|
||||
private double range = RANGE;
|
||||
private double damageradius = DAMAGE_RADIUS;
|
||||
|
@ -56,7 +59,6 @@ public class Fireball extends AddonAbility {
|
|||
private boolean damage_blocks;
|
||||
|
||||
public Fireball(Player player) {
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
time = System.currentTimeMillis();
|
||||
starttime = time;
|
||||
|
@ -69,15 +71,15 @@ public class Fireball extends AddonAbility {
|
|||
}
|
||||
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
|
||||
if (!player.getEyeLocation().getBlock().isLiquid()) {
|
||||
//instances.put(id, this);
|
||||
putInstance(player, this);
|
||||
instances.put(idCounter, this);
|
||||
this.id = idCounter;
|
||||
idCounter = (idCounter + 1) % Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean annihilateBlasts(Location location, double radius, Player source) {
|
||||
boolean broke = false;
|
||||
for (Integer id : getInstances(Fireball.class).keySet()) {
|
||||
Fireball fireball = (Fireball) getAbility(id);
|
||||
for (Fireball fireball : instances.values()) {
|
||||
if (!fireball.launched)
|
||||
continue;
|
||||
Location fireblastlocation = fireball.location;
|
||||
|
@ -100,8 +102,7 @@ public class Fireball extends AddonAbility {
|
|||
}
|
||||
|
||||
public static boolean isCharging(Player player) {
|
||||
for (Integer id : getInstances(Fireball.class).keySet()) {
|
||||
Fireball fireball = (Fireball) getAbility(id);
|
||||
for (Fireball fireball : instances.values()) {
|
||||
if (fireball.player == player && !fireball.launched)
|
||||
return true;
|
||||
}
|
||||
|
@ -109,8 +110,7 @@ public class Fireball extends AddonAbility {
|
|||
}
|
||||
|
||||
public static void removeFireballsAroundPoint(Location location, double radius) {
|
||||
for (Integer id : getInstances(Fireball.class).keySet()) {
|
||||
Fireball fireball = (Fireball) getAbility(id);
|
||||
for (Fireball fireball : instances.values()) {
|
||||
if (!fireball.launched)
|
||||
continue;
|
||||
Location fireblastlocation = fireball.location;
|
||||
|
@ -237,11 +237,6 @@ public class Fireball extends AddonAbility {
|
|||
return innerradius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType() {
|
||||
return InstanceType.MULTIPLE;
|
||||
}
|
||||
|
||||
public double getMaxdamage() {
|
||||
return maxdamage;
|
||||
}
|
||||
|
@ -269,7 +264,6 @@ public class Fireball extends AddonAbility {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (GeneralMethods.getBoundAbility(player) == null) {
|
||||
remove();
|
||||
|
@ -338,6 +332,10 @@ public class Fireball extends AddonAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
defaultchargetime = config.get().getLong("Abilities.Fire.FireBlast.Charged.ChargeTime");
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
|
||||
/**
|
||||
* Created by Carbogen on 11/02/15. Ability HeatControl
|
||||
*/
|
||||
public class HeatControl extends CoreAbility {
|
||||
public class HeatControl implements ConfigLoadable {
|
||||
public static final ConcurrentHashMap<Player, HeatControl> 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");
|
||||
|
@ -52,7 +53,7 @@ public class HeatControl extends CoreAbility {
|
|||
|
||||
lastBlockTime = System.currentTimeMillis();
|
||||
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -106,11 +107,6 @@ public class HeatControl extends CoreAbility {
|
|||
return revertTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.HeatControl;
|
||||
}
|
||||
|
||||
public boolean isEligible(Player player) {
|
||||
if (!GeneralMethods.canBend(player.getName(), "HeatControl"))
|
||||
return false;
|
||||
|
@ -136,7 +132,6 @@ public class HeatControl extends CoreAbility {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (!player.isOnline() || player.isDead() || !isEligible(player) || !player.isSneaking()) {
|
||||
remove();
|
||||
|
@ -169,13 +164,12 @@ public class HeatControl extends CoreAbility {
|
|||
revertTime = REVERT_TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
final HeatControl ability = this;
|
||||
ProjectKorra.plugin.getServer().getScheduler().scheduleSyncDelayedTask(ProjectKorra.plugin, new Runnable() {
|
||||
public void run() {
|
||||
revertAll();
|
||||
ability.remove();
|
||||
instances.remove(ability);
|
||||
}
|
||||
}, getRevertTime());
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class Illumination extends CoreAbility {
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
|
||||
public class Illumination implements ConfigLoadable {
|
||||
public static final ConcurrentHashMap<Player, Illumination> instances = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<Block, Player> blocks = new ConcurrentHashMap<Block, Player>();
|
||||
|
||||
private static int range = config.get().getInt("Abilities.Fire.Illumination.Range");
|
||||
|
@ -30,14 +30,13 @@ public class Illumination extends CoreAbility {
|
|||
return;
|
||||
/* End Initial Checks */
|
||||
|
||||
if (containsPlayer(player, Illumination.class)) {
|
||||
getAbilityFromPlayer(player, Illumination.class).remove();
|
||||
if (instances.containsKey(player)) {
|
||||
instances.get(player).remove();
|
||||
} else {
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
set();
|
||||
//instances.put(player, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
bPlayer.addCooldown("Illumination", GeneralMethods.getGlobalCooldown());
|
||||
}
|
||||
}
|
||||
|
@ -48,12 +47,7 @@ public class Illumination extends CoreAbility {
|
|||
|
||||
public static void revert(Block block) {
|
||||
Player player = blocks.get(block);
|
||||
((Illumination) getAbilityFromPlayer(player, Illumination.class)).revert();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.Illumination;
|
||||
instances.get(player).revert();
|
||||
}
|
||||
|
||||
// public static void manage(Server server) {
|
||||
|
@ -76,7 +70,6 @@ public class Illumination extends CoreAbility {
|
|||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (!player.isOnline() || player.isDead()) {
|
||||
remove();
|
||||
|
@ -96,10 +89,9 @@ public class Illumination extends CoreAbility {
|
|||
range = config.get().getInt("Abilities.Fire.Illumination.Range");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
revert();
|
||||
super.remove();
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
Loading…
Reference in a new issue