mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-12 03:59:06 +00:00
Finish decoreability
This commit is contained in:
parent
6760985369
commit
e84b239665
33 changed files with 877 additions and 353 deletions
|
@ -61,7 +61,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.ability.combo.ComboManager;
|
||||
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
|
||||
import com.projectkorra.projectkorra.airbending.AirBlast;
|
||||
|
@ -833,7 +832,7 @@ public class PKListener implements Listener {
|
|||
}
|
||||
if (e.getCause() == DamageCause.ENTITY_ATTACK && GeneralMethods.getBendingPlayer(sourceplayer.getName()).isElementToggled(Element.Chi) == true) {
|
||||
if (GeneralMethods.getBoundAbility(sourceplayer) != null && GeneralMethods.getBoundAbility(sourceplayer).equalsIgnoreCase("Paralyze") && e.getDamage() == 1) {
|
||||
if (CoreAbility.getAbilitiesFromPlayer(sourceplayer).isEmpty()) {
|
||||
if (sourceplayer.getWorld().equals(targetplayer.getWorld()) && Math.abs(sourceplayer.getLocation().distance(targetplayer.getLocation())) < 3) {
|
||||
new Paralyze(sourceplayer, targetplayer);
|
||||
}
|
||||
}
|
||||
|
|
333
src/com/projectkorra/projectkorra/ability/api/CoreAbility.java
Normal file
333
src/com/projectkorra/projectkorra/ability/api/CoreAbility.java
Normal file
|
@ -0,0 +1,333 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
|
|||
import com.projectkorra.projectkorra.util.Flight;
|
||||
|
||||
public class AirBlast implements ConfigLoadable {
|
||||
|
||||
public static ConcurrentHashMap<Integer, AirBlast> instances = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<Player, Location> origins = new ConcurrentHashMap<Player, Location>();
|
||||
|
||||
|
@ -461,6 +462,12 @@ public class AirBlast implements ConfigLoadable {
|
|||
instances.remove(id);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (AirBlast ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
speed = config.get().getDouble("Abilities.Air.AirBlast.Speed");
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -14,10 +9,14 @@ import org.bukkit.block.Block;
|
|||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
|
||||
public class AirBubble implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, AirBubble> 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");
|
||||
|
||||
|
@ -31,13 +30,12 @@ public class AirBubble implements ConfigLoadable {
|
|||
// reloadVariables();
|
||||
this.player = player;
|
||||
waterorigins = new ConcurrentHashMap<Block, BlockState>();
|
||||
// instances.put(uuid, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
public static boolean canFlowTo(Block block) {
|
||||
for (Integer id : getInstances(StockAbility.AirBubble).keySet()) {
|
||||
if (((AirBubble) getAbility(id)).blockInBubble(block)) {
|
||||
for (AirBubble airBubble : instances.values()) {
|
||||
if (airBubble.blockInBubble(block)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -55,14 +53,14 @@ public class AirBubble implements ConfigLoadable {
|
|||
if (GeneralMethods.getBoundAbility(player) != null) {
|
||||
if (GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirBubble")
|
||||
|| GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterBubble")) {
|
||||
if (!containsPlayer(player, AirBubble.class) && player.isSneaking()) {
|
||||
if (instances.containsKey(player) && player.isSneaking()) {
|
||||
new AirBubble(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CoreAbility.progressAll(StockAbility.AirBubble);
|
||||
AirBubble.progressAll();
|
||||
}
|
||||
|
||||
public boolean blockInBubble(Block block) {
|
||||
|
@ -156,9 +154,13 @@ public class AirBubble implements ConfigLoadable {
|
|||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (AirBubble ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -182,7 +184,13 @@ public class AirBubble implements ConfigLoadable {
|
|||
waterorigins.get(block).update(true);
|
||||
}
|
||||
// instances.remove(uuid);
|
||||
super.remove();
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (AirBubble ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaultAirRadius(double defaultAirRadius) {
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
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.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -13,10 +9,15 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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 AirBurst extends CoreAbility {
|
||||
public class AirBurst implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, AirBurst> instances = new ConcurrentHashMap<>();
|
||||
private static double PARTICLES_PERCENTAGE = 50;
|
||||
|
||||
private static double threshold = config.get().getDouble("Abilities.Air.AirBurst.FallThreshold");
|
||||
|
@ -41,7 +42,7 @@ public class AirBurst extends CoreAbility {
|
|||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||
if (bPlayer.isOnCooldown("AirBurst"))
|
||||
return;
|
||||
if (containsPlayer(player, AirBurst.class))
|
||||
if (instances.containsKey(player))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
//reloadVariables();
|
||||
|
@ -49,13 +50,12 @@ public class AirBurst extends CoreAbility {
|
|||
if (AvatarState.isAvatarState(player))
|
||||
chargetime = 0;
|
||||
this.player = player;
|
||||
//instances.put(player.getUniqueId(), this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
public static void coneBurst(Player player) {
|
||||
if (containsPlayer(player, AirBurst.class)) {
|
||||
((AirBurst) getAbilityFromPlayer(player, AirBurst.class)).coneBurst();
|
||||
if (instances.containsKey(player)) {
|
||||
instances.get(player).coneBurst();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class AirBurst extends CoreAbility {
|
|||
if (GeneralMethods.getBoundAbility(player) == null) {
|
||||
return;
|
||||
}
|
||||
if (containsPlayer(player, AirBurst.class)) {
|
||||
if (instances.containsKey(player)) {
|
||||
return;
|
||||
}
|
||||
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirBurst")) {
|
||||
|
@ -124,11 +124,6 @@ public class AirBurst extends CoreAbility {
|
|||
remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.AirBurst;
|
||||
}
|
||||
|
||||
public void handleSmoothParticles() {
|
||||
for (int i = 0; i < blasts.size(); i++) {
|
||||
final AirBlast blast = blasts.get(i);
|
||||
|
@ -147,7 +142,6 @@ public class AirBurst extends CoreAbility {
|
|||
return affectedentities.contains(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (!GeneralMethods.canBend(player.getName(), "AirBurst")) {
|
||||
remove();
|
||||
|
@ -187,6 +181,22 @@ public class AirBurst extends CoreAbility {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
threshold = config.get().getDouble("Abilities.Air.AirBurst.FallThreshold");
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.projectkorra.projectkorra.Element;
|
|||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.AbilityModuleManager;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -171,17 +170,16 @@ public class AirMethods {
|
|||
* Stops all airbending systems. SHOULD ONLY BE USED ON PLUGIN DISABLING!
|
||||
*/
|
||||
public static void stopBending() {
|
||||
AirBlast.removeAll(StockAbility.AirBlast);
|
||||
AirBubble.removeAll(StockAbility.AirBubble);
|
||||
AirShield.removeAll(StockAbility.AirShield);
|
||||
AirSuction.removeAll(StockAbility.AirSuction);
|
||||
AirScooter.removeAll(StockAbility.AirScooter);
|
||||
AirSpout.removeAll(StockAbility.AirSpout);
|
||||
AirSwipe.removeAll(StockAbility.AirSwipe);
|
||||
Tornado.removeAll(StockAbility.Tornado);
|
||||
;
|
||||
AirBurst.removeAll(StockAbility.AirBurst);
|
||||
Suffocate.removeAll(StockAbility.Suffocate);
|
||||
AirBlast.removeAll();
|
||||
AirBubble.removeAll();
|
||||
AirShield.removeAll();
|
||||
AirSuction.removeAll();
|
||||
AirScooter.removeAll();
|
||||
AirSpout.removeAll();
|
||||
AirSwipe.removeAll();
|
||||
Tornado.removeAll();
|
||||
AirBurst.removeAll();
|
||||
Suffocate.removeAll();
|
||||
AirCombo.removeAll();
|
||||
FlightAbility.removeAll();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -12,9 +10,13 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
|
||||
public class AirScooter extends CoreAbility {
|
||||
public class AirScooter implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, AirScooter> instances = new ConcurrentHashMap<>();
|
||||
|
||||
private static double configSpeed = config.get().getDouble("Abilities.Air.AirScooter.Speed");
|
||||
private static final long interval = 100;
|
||||
|
@ -31,7 +33,8 @@ public class AirScooter extends CoreAbility {
|
|||
if (check(player)) {
|
||||
return;
|
||||
}
|
||||
if (!player.isSprinting() || GeneralMethods.isSolid(player.getEyeLocation().getBlock()) || player.getEyeLocation().getBlock().isLiquid())
|
||||
if (!player.isSprinting() || GeneralMethods.isSolid(player.getEyeLocation().getBlock())
|
||||
|| player.getEyeLocation().getBlock().isLiquid())
|
||||
return;
|
||||
if (GeneralMethods.isSolid(player.getLocation().add(0, -.5, 0).getBlock()))
|
||||
return;
|
||||
|
@ -48,9 +51,8 @@ public class AirScooter extends CoreAbility {
|
|||
for (int i = 0; i < 5; i++) {
|
||||
angles.add((double) (60 * i));
|
||||
}
|
||||
//instances.put(uuid, this);
|
||||
instances.put(player, this);
|
||||
speed = configSpeed;
|
||||
putInstance(player, this);
|
||||
progress();
|
||||
}
|
||||
|
||||
|
@ -61,8 +63,8 @@ public class AirScooter extends CoreAbility {
|
|||
* @return false If player doesn't have an instance
|
||||
*/
|
||||
public static boolean check(Player player) {
|
||||
if (containsPlayer(player, AirScooter.class)) {
|
||||
getAbilityFromPlayer(player, AirScooter.class).remove();
|
||||
if (instances.containsKey(player)) {
|
||||
instances.get(player).remove();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -70,8 +72,8 @@ public class AirScooter extends CoreAbility {
|
|||
|
||||
public static ArrayList<Player> getPlayers() {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Integer id : getInstances(StockAbility.AirScooter).keySet()) {
|
||||
players.add(getAbility(id).getPlayer());
|
||||
for (AirScooter scooter : instances.values()) {
|
||||
players.add(scooter.getPlayer());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
@ -99,12 +101,6 @@ public class AirScooter extends CoreAbility {
|
|||
this.speed = value; // Used in PK Items
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.AirScooter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
getFloor();
|
||||
// Methods.verbose(player);
|
||||
|
@ -171,21 +167,31 @@ public class AirScooter extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (AirScooter ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
configSpeed = config.get().getDouble("Abilities.Air.AirScooter.Speed");
|
||||
this.speed = configSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
//instances.remove(uuid);
|
||||
super.remove();
|
||||
instances.remove(player);
|
||||
player.setFlying(false);
|
||||
player.setAllowFlight(false);
|
||||
player.setSprinting(false);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (AirScooter ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void spinScooter() {
|
||||
Location origin = player.getLocation().clone();
|
||||
origin.add(0, -scooterradius, 0);
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
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.command.Commands;
|
||||
import com.projectkorra.projectkorra.firebending.Combustion;
|
||||
import com.projectkorra.projectkorra.firebending.FireBlast;
|
||||
import com.projectkorra.projectkorra.firebending.FireStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
@ -17,10 +12,17 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AvatarState;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.firebending.Combustion;
|
||||
import com.projectkorra.projectkorra.firebending.FireBlast;
|
||||
import com.projectkorra.projectkorra.firebending.FireStream;
|
||||
|
||||
public class AirShield extends CoreAbility {
|
||||
public class AirShield implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, AirShield> 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");
|
||||
|
@ -35,9 +37,9 @@ public class AirShield extends CoreAbility {
|
|||
|
||||
public AirShield(Player player) {
|
||||
/* Initial Check */
|
||||
if (AvatarState.isAvatarState(player) && containsPlayer(player, AirShield.class) && isToggle) {
|
||||
if (AvatarState.isAvatarState(player) && instances.containsKey(player) && isToggle) {
|
||||
//instances.remove(player.getUniqueId());
|
||||
getAbilityFromPlayer(player, AirShield.class).remove();
|
||||
instances.get(player).remove();
|
||||
return;
|
||||
}
|
||||
/* End Initial Check */
|
||||
|
@ -52,8 +54,7 @@ public class AirShield extends CoreAbility {
|
|||
angle = 0;
|
||||
}
|
||||
|
||||
//instances.put(player.getUniqueId(), this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
public static String getDescription() {
|
||||
|
@ -61,8 +62,7 @@ public class AirShield extends CoreAbility {
|
|||
}
|
||||
|
||||
public static boolean isWithinShield(Location loc) {
|
||||
for (Integer id : getInstances(StockAbility.AirShield).keySet()) {
|
||||
AirShield ashield = (AirShield) getAbility(id);
|
||||
for (AirShield ashield : instances.values()) {
|
||||
if (ashield.player.getLocation().getWorld() != loc.getWorld())
|
||||
return false;
|
||||
if (ashield.player.getLocation().distance(loc) <= ashield.radius)
|
||||
|
@ -79,12 +79,6 @@ public class AirShield extends CoreAbility {
|
|||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.AirShield;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
|
@ -127,6 +121,22 @@ public class AirShield extends CoreAbility {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
MAX_RADIUS = config.get().getDouble("Abilities.Air.AirShield.Radius");
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
|
||||
public class AirSpout extends CoreAbility {
|
||||
public class AirSpout implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, AirSpout> instances = new ConcurrentHashMap<>();
|
||||
|
||||
private static double HEIGHT = config.get().getDouble("Abilities.Air.AirSpout.Height");
|
||||
private static final long interval = 100;
|
||||
|
@ -24,8 +26,8 @@ public class AirSpout extends CoreAbility {
|
|||
|
||||
public AirSpout(Player player) {
|
||||
/* Initial Check */
|
||||
if (containsPlayer(player, AirSpout.class)) {
|
||||
getAbilityFromPlayer(player, AirSpout.class).remove();
|
||||
if (instances.containsKey(player)) {
|
||||
instances.get(player).remove();
|
||||
return;
|
||||
}
|
||||
/* End Initial Check */
|
||||
|
@ -33,23 +35,21 @@ public class AirSpout extends CoreAbility {
|
|||
this.player = player;
|
||||
time = System.currentTimeMillis();
|
||||
new Flight(player);
|
||||
//instances.put(player.getUniqueId(), this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
progress();
|
||||
}
|
||||
|
||||
public static ArrayList<Player> getPlayers() {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Integer id : getInstances(StockAbility.AirSpout).keySet()) {
|
||||
players.add(getAbility(id).getPlayer());
|
||||
for (AirSpout spout : instances.values()) {
|
||||
players.add(spout.getPlayer());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
public static boolean removeSpouts(Location loc0, double radius, Player sourceplayer) {
|
||||
boolean removed = false;
|
||||
for (Integer id : getInstances(StockAbility.AirSpout).keySet()) {
|
||||
Player player = getAbility(id).getPlayer();
|
||||
for (Player player : instances.keySet()) {
|
||||
if (!player.equals(sourceplayer)) {
|
||||
Location loc1 = player.getLocation().getBlock().getLocation();
|
||||
loc0 = loc0.getBlock().getLocation();
|
||||
|
@ -60,7 +60,7 @@ public class AirSpout extends CoreAbility {
|
|||
double distance = Math.sqrt(dx * dx + dz * dz);
|
||||
|
||||
if (distance <= radius && dy > 0 && dy < HEIGHT) {
|
||||
getAbility(id).remove();
|
||||
instances.get(player).remove();
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
|
@ -93,12 +93,6 @@ public class AirSpout extends CoreAbility {
|
|||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.AirSpout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (!GeneralMethods.canBend(player.getName(), "AirSpout")
|
||||
// || !Methods.hasAbility(player, Abilities.AirSpout)
|
||||
|
@ -126,17 +120,27 @@ public class AirSpout extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (AirSpout ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
HEIGHT = config.get().getDouble("Abilities.Air.AirSpout.Height");
|
||||
height = HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
removeFlight();
|
||||
//instances.remove(uuid);
|
||||
super.remove();
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (AirSpout ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFlight() {
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
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.command.Commands;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
@ -18,11 +9,20 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.command.Commands;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthMethods;
|
||||
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
||||
|
||||
public class AirSuction extends CoreAbility {
|
||||
public class AirSuction implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, AirSuction> instances = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<Player, Location> origins = new ConcurrentHashMap<Player, Location>();
|
||||
|
||||
private static final double maxspeed = AirBlast.maxspeed;
|
||||
|
@ -60,8 +60,9 @@ public class AirSuction extends CoreAbility {
|
|||
if (player.getEyeLocation().getBlock().isLiquid()) {
|
||||
return;
|
||||
}
|
||||
if (AirSpout.getPlayers().contains(player) || WaterSpout.getPlayers().contains(player))
|
||||
if (AirSpout.getPlayers().contains(player) || WaterSpout.getPlayers().contains(player)) {
|
||||
return;
|
||||
}
|
||||
/* End Initial Check */
|
||||
// reloadVariables();
|
||||
this.player = player;
|
||||
|
@ -83,15 +84,17 @@ public class AirSuction extends CoreAbility {
|
|||
}
|
||||
// }
|
||||
|
||||
//instances.put(uuid, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
bPlayer.addCooldown("AirSuction", GeneralMethods.getGlobalCooldown());
|
||||
// time = System.currentTimeMillis();
|
||||
// timers.put(player, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public static String getDescription() {
|
||||
return "To use, simply left-click in a direction. " + "A gust of wind will originate as far as it can in that direction" + " and flow towards you, sucking anything in its path harmlessly with it." + " Skilled benders can use this technique to pull items from precarious locations. " + "Additionally, tapping sneak will change the origin of your next " + "AirSuction to your targeted location.";
|
||||
return "To use, simply left-click in a direction. " + "A gust of wind will originate as far as it can in that direction"
|
||||
+ " and flow towards you, sucking anything in its path harmlessly with it."
|
||||
+ " Skilled benders can use this technique to pull items from precarious locations. "
|
||||
+ "Additionally, tapping sneak will change the origin of your next " + "AirSuction to your targeted location.";
|
||||
}
|
||||
|
||||
private static void playOriginEffect(Player player) {
|
||||
|
@ -108,7 +111,8 @@ public class AirSuction extends CoreAbility {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSuction") || !GeneralMethods.canBend(player.getName(), "AirSuction")) {
|
||||
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSuction")
|
||||
|| !GeneralMethods.canBend(player.getName(), "AirSuction")) {
|
||||
origins.remove(player);
|
||||
return;
|
||||
}
|
||||
|
@ -125,7 +129,9 @@ public class AirSuction extends CoreAbility {
|
|||
}
|
||||
|
||||
public static void progressAll() {
|
||||
CoreAbility.progressAll(StockAbility.AirSuction);
|
||||
for (AirSuction ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
for (Player player : origins.keySet()) {
|
||||
playOriginEffect(player);
|
||||
}
|
||||
|
@ -164,7 +170,8 @@ public class AirSuction extends CoreAbility {
|
|||
Location location = origin.clone();
|
||||
for (double i = 1; i <= range; i++) {
|
||||
location = origin.clone().add(direction.clone().multiply(i));
|
||||
if (!EarthMethods.isTransparentToEarthbending(player, location.getBlock()) || GeneralMethods.isRegionProtectedFromBuild(player, "AirSuction", location)) {
|
||||
if (!EarthMethods.isTransparentToEarthbending(player, location.getBlock())
|
||||
|| GeneralMethods.isRegionProtectedFromBuild(player, "AirSuction", location)) {
|
||||
return origin.clone().add(direction.clone().multiply(i - 1));
|
||||
}
|
||||
}
|
||||
|
@ -187,12 +194,6 @@ public class AirSuction extends CoreAbility {
|
|||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.AirSuction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
|
@ -275,10 +276,19 @@ public class AirSuction extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (AirSuction ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean removeAirSuctionsAroundPoint(Location location, double radius) {
|
||||
boolean removed = false;
|
||||
for (Integer id : getInstances(StockAbility.AirSuction).keySet()) {
|
||||
AirSuction airSuction = ((AirSuction)getAbility(id));
|
||||
for (AirSuction airSuction : instances.values()) {
|
||||
Location airSuctionlocation = airSuction.location;
|
||||
if (location.getWorld() == airSuctionlocation.getWorld()) {
|
||||
if (location.distance(airSuctionlocation) <= radius)
|
||||
|
@ -316,9 +326,4 @@ public class AirSuction extends CoreAbility {
|
|||
public void setSpeed(double speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType() {
|
||||
return InstanceType.MULTIPLE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
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.command.Commands;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.projectkorra.firebending.Combustion;
|
||||
import com.projectkorra.projectkorra.firebending.FireBlast;
|
||||
import com.projectkorra.projectkorra.firebending.Illumination;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -24,12 +14,23 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
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.command.Commands;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.projectkorra.firebending.Combustion;
|
||||
import com.projectkorra.projectkorra.firebending.FireBlast;
|
||||
import com.projectkorra.projectkorra.firebending.Illumination;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterMethods;
|
||||
|
||||
public class AirSwipe extends CoreAbility {
|
||||
public class AirSwipe implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, AirSwipe> instances = new ConcurrentHashMap<>();
|
||||
|
||||
private static int stepsize = 4;
|
||||
|
||||
|
@ -82,8 +83,7 @@ public class AirSwipe extends CoreAbility {
|
|||
origin = player.getEyeLocation();
|
||||
time = System.currentTimeMillis();
|
||||
|
||||
//instances.put(uuid, this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
|
||||
bPlayer.addCooldown("AirSwipe", ProjectKorra.plugin.getConfig().getLong("Abilities.Air.AirSwipe.Cooldown"));
|
||||
|
||||
|
@ -97,9 +97,7 @@ public class AirSwipe extends CoreAbility {
|
|||
|
||||
public static boolean removeSwipesAroundPoint(Location loc, double radius) {
|
||||
boolean removed = false;
|
||||
for (Integer id : getInstances(StockAbility.AirSwipe).keySet()) {
|
||||
AirSwipe aswipe = (AirSwipe) getAbility(id);
|
||||
|
||||
for (AirSwipe aswipe : instances.values()) {
|
||||
for (Vector vec : aswipe.elements.keySet()) {
|
||||
Location vectorLoc = aswipe.elements.get(vec);
|
||||
if (vectorLoc != null && vectorLoc.getWorld().equals(loc.getWorld())) {
|
||||
|
@ -259,11 +257,6 @@ public class AirSwipe extends CoreAbility {
|
|||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.AirSwipe;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean isBlockBreakable(Block block) {
|
||||
Integer id = block.getTypeId();
|
||||
|
@ -293,7 +286,6 @@ public class AirSwipe extends CoreAbility {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
|
@ -340,6 +332,22 @@ public class AirSwipe extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (AirSwipe ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (AirSwipe ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
ARC = config.get().getInt("Abilities.Air.AirSwipe.Arc");
|
||||
|
|
|
@ -16,17 +16,17 @@ public class AirbendingManager implements Runnable {
|
|||
public void run() {
|
||||
AirBlast.progressAll();
|
||||
AirPassive.handlePassive(Bukkit.getServer());
|
||||
AirBurst.progressAll(AirBurst.class);
|
||||
AirScooter.progressAll(AirScooter.class);
|
||||
Suffocate.progressAll(Suffocate.class);
|
||||
AirSpout.progressAll(AirSpout.class);
|
||||
AirBurst.progressAll();
|
||||
AirScooter.progressAll();
|
||||
Suffocate.progressAll();
|
||||
AirSpout.progressAll();
|
||||
AirBubble.handleBubbles(Bukkit.getServer());
|
||||
AirSuction.progressAll();
|
||||
AirSwipe.progressAll(AirSwipe.class);
|
||||
Tornado.progressAll(Tornado.class);
|
||||
AirShield.progressAll(AirShield.class);
|
||||
AirSwipe.progressAll();
|
||||
Tornado.progressAll();
|
||||
AirShield.progressAll();
|
||||
AirCombo.progressAll();
|
||||
FlightAbility.progressAll(FlightAbility.class);
|
||||
FlightAbility.progressAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
|
||||
public class FlightAbility extends CoreAbility {
|
||||
public class FlightAbility implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, FlightAbility> instances = new ConcurrentHashMap<>();
|
||||
|
||||
private static ConcurrentHashMap<String, Integer> hits = new ConcurrentHashMap<String, Integer>();
|
||||
private static ConcurrentHashMap<String, Boolean> hovering = new ConcurrentHashMap<String, Boolean>();
|
||||
|
@ -24,8 +25,7 @@ public class FlightAbility extends CoreAbility {
|
|||
player.setAllowFlight(true);
|
||||
player.setVelocity(player.getEyeLocation().getDirection().normalize());
|
||||
this.player = player;
|
||||
//instances.put(player.getUniqueId(), this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
public static void addHit(Player player) {
|
||||
|
@ -42,7 +42,7 @@ public class FlightAbility extends CoreAbility {
|
|||
}
|
||||
|
||||
public static boolean contains(Player player) {
|
||||
return containsPlayer(player, FlightAbility.class);
|
||||
return instances.containsKey(player);
|
||||
}
|
||||
|
||||
public static boolean isHovering(Player player) {
|
||||
|
@ -51,11 +51,13 @@ public class FlightAbility extends CoreAbility {
|
|||
|
||||
public static void remove(Player player) {
|
||||
if (contains(player))
|
||||
getAbilityFromPlayer(player, FlightAbility.class).remove();
|
||||
instances.get(player).remove();
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
CoreAbility.removeAll(StockAbility.Flight);
|
||||
for (FlightAbility ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
hits.clear();
|
||||
hovering.clear();
|
||||
}
|
||||
|
@ -75,12 +77,6 @@ public class FlightAbility extends CoreAbility {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.Flight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (!AirMethods.canFly(player, false, isHovering(player))) {
|
||||
remove(player);
|
||||
|
@ -100,15 +96,19 @@ public class FlightAbility extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (FlightAbility ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
String name = player.getName();
|
||||
//instances.remove(uuid);
|
||||
super.remove();
|
||||
instances.remove(player);
|
||||
hits.remove(name);
|
||||
hovering.remove(name);
|
||||
if (flight != null)
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
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.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -15,10 +12,11 @@ import org.bukkit.potion.PotionEffect;
|
|||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
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.configuration.ConfigLoadable;
|
||||
|
||||
/**
|
||||
* Suffocate
|
||||
|
@ -30,7 +28,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* entities within a large radius. If the user is damaged while performing this
|
||||
* ability then the ability is removed.
|
||||
*/
|
||||
public class Suffocate extends CoreAbility {
|
||||
public class Suffocate implements ConfigLoadable {
|
||||
public static final ConcurrentHashMap<Player, Suffocate> 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");
|
||||
|
@ -96,8 +96,9 @@ public class Suffocate extends CoreAbility {
|
|||
blindDelay = BLIND_DELAY;
|
||||
blindRepeat = BLIND_INTERVAL;
|
||||
|
||||
if (containsPlayer(player, Suffocate.class))
|
||||
if (instances.containsKey(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AvatarState.isAvatarState(player)) {
|
||||
cooldown = 0;
|
||||
|
@ -140,28 +141,21 @@ public class Suffocate extends CoreAbility {
|
|||
else if (bplayer.isOnCooldown("suffocate"))
|
||||
return;
|
||||
bplayer.addCooldown("suffocate", cooldown);
|
||||
//instances.put(player,this);
|
||||
putInstance(player, this);
|
||||
instances.put(player,this);
|
||||
}
|
||||
|
||||
/** Stops an entity from being suffocated **/
|
||||
public static void breakSuffocate(Entity entity) {
|
||||
for (Integer id : getInstances().keySet()) {
|
||||
Suffocate suffocate = (Suffocate) getAbility(id);
|
||||
for (Suffocate suffocate : instances.values()) {
|
||||
if (suffocate.targets.contains(entity)) {
|
||||
suffocate.breakSuffocateLocal(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ConcurrentHashMap<Integer, CoreAbility> getInstances() {
|
||||
return getInstances(StockAbility.Suffocate);
|
||||
}
|
||||
|
||||
/** Checks if an entity is being suffocated **/
|
||||
public static boolean isBreathbent(Entity entity) {
|
||||
for (Integer id : getInstances().keySet()) {
|
||||
Suffocate suffocate = (Suffocate) getAbility(id);
|
||||
for (Suffocate suffocate : instances.values()) {
|
||||
if (suffocate.targets.contains(entity)) {
|
||||
return suffocate.started;
|
||||
}
|
||||
|
@ -171,9 +165,7 @@ public class Suffocate extends CoreAbility {
|
|||
|
||||
/** Determines if a player is Suffocating entities **/
|
||||
public static boolean isChannelingSphere(Player player) {
|
||||
if (containsPlayer(player, Suffocate.class))
|
||||
return true;
|
||||
return false;
|
||||
return instances.containsKey(player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,8 +173,15 @@ public class Suffocate extends CoreAbility {
|
|||
* entities
|
||||
**/
|
||||
public static void remove(Player player) {
|
||||
if (containsPlayer(player, Suffocate.class))
|
||||
getAbilityFromPlayer(player, Suffocate.class).remove();
|
||||
if (instances.containsKey(player)) {
|
||||
instances.get(player).remove();
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (Suffocate ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,15 +192,12 @@ public class Suffocate extends CoreAbility {
|
|||
* @param causer The player causing this instance to be removed
|
||||
**/
|
||||
public static boolean removeAtLocation(Player causer, Location loc, double radius) {
|
||||
Iterator<Integer> it = getInstances().keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Integer key = it.next();
|
||||
Suffocate val = (Suffocate) getAbility(key);
|
||||
|
||||
if (causer == null || !key.equals(causer)) {
|
||||
Location playerLoc = val.getPlayer().getLocation();
|
||||
for (Player player : instances.keySet()) {
|
||||
Suffocate suff = instances.get(player);
|
||||
if (causer == null || !player.equals(causer)) {
|
||||
Location playerLoc = suff.getPlayer().getLocation();
|
||||
if (playerLoc.getWorld().equals(loc.getWorld()) && playerLoc.distance(loc) <= radius) {
|
||||
it.remove();
|
||||
suff.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -322,11 +318,6 @@ public class Suffocate extends CoreAbility {
|
|||
return speedFactor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.Suffocate;
|
||||
}
|
||||
|
||||
public ArrayList<LivingEntity> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
@ -450,6 +441,12 @@ public class Suffocate extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Suffocate ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
CAN_SUFFOCATE_UNDEAD = config.get().getBoolean("Abilities.Air.Suffocate.CanBeUsedOnUndeadMobs");
|
||||
|
@ -475,8 +472,7 @@ public class Suffocate extends CoreAbility {
|
|||
|
||||
/** Removes this instance of the ability **/
|
||||
public void remove() {
|
||||
//instances.remove(player);
|
||||
super.remove();
|
||||
instances.remove(player);
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
tasks.get(i).cancel();
|
||||
tasks.remove(i);
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -12,11 +10,14 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
|
||||
public class Tornado extends CoreAbility {
|
||||
public class Tornado implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, Tornado> 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");
|
||||
|
@ -60,14 +61,13 @@ public class Tornado extends CoreAbility {
|
|||
|
||||
new Flight(player);
|
||||
player.setAllowFlight(true);
|
||||
//instances.put(player.getEntityId(), this);
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
public static ArrayList<Player> getPlayers() {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Integer id : getInstances(StockAbility.Tornado).keySet()) {
|
||||
players.add(getAbility(id).getPlayer());
|
||||
for (Tornado tornado : instances.values()) {
|
||||
players.add(tornado.getPlayer());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
@ -96,12 +96,6 @@ public class Tornado extends CoreAbility {
|
|||
return range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.Tornado;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
|
@ -129,6 +123,22 @@ public class Tornado extends CoreAbility {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
MAX_HEIGHT = config.get().getDouble("Abilities.Air.Tornado.Height");
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.projectkorra.projectkorra.earthbending;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.StockAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.CoreAbility;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -12,9 +9,14 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
|
||||
public class Catapult extends CoreAbility {
|
||||
public class Catapult implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, Catapult> 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");
|
||||
|
@ -66,8 +68,7 @@ public class Catapult extends CoreAbility {
|
|||
distance = distance / 2;
|
||||
|
||||
moving = true;
|
||||
putInstance(player, this);
|
||||
GeneralMethods.invincible.add(this);
|
||||
instances.put(player, this);
|
||||
bplayer.addCooldown("Catapult", GeneralMethods.getGlobalCooldown());
|
||||
}
|
||||
|
||||
|
@ -83,7 +84,7 @@ public class Catapult extends CoreAbility {
|
|||
direction = source.direction.clone();
|
||||
distance = source.distance;
|
||||
|
||||
putInstance(player, this);
|
||||
instances.put(player, this);
|
||||
EarthMethods.playEarthbendingSound(player.getLocation());
|
||||
fly();
|
||||
}
|
||||
|
@ -99,8 +100,8 @@ public class Catapult extends CoreAbility {
|
|||
|
||||
public static ArrayList<Player> getPlayers() {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Integer id : getInstances(Catapult.class).keySet()) {
|
||||
players.add(getAbility(id).getPlayer());
|
||||
for (Catapult cata : instances.values()) {
|
||||
players.add(cata.getPlayer());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
@ -149,11 +150,6 @@ public class Catapult extends CoreAbility {
|
|||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockAbility getStockAbility() {
|
||||
return StockAbility.Catapult;
|
||||
}
|
||||
|
||||
private boolean moveEarth() {
|
||||
location = location.clone().add(direction);
|
||||
if (catapult) {
|
||||
|
@ -179,7 +175,6 @@ public class Catapult extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
|
@ -199,6 +194,18 @@ public class Catapult extends CoreAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Catapult ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (Catapult ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
LENGTH = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Catapult.Length");
|
||||
|
@ -206,10 +213,8 @@ public class Catapult extends CoreAbility {
|
|||
PUSH = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.Catapult.Push");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
GeneralMethods.invincible.remove(this);
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public void setLength(int length) {
|
||||
|
|
|
@ -636,7 +636,7 @@ public class EarthMethods {
|
|||
}
|
||||
|
||||
public static void stopBending() {
|
||||
Catapult.removeAll(Catapult.class);
|
||||
Catapult.removeAll();
|
||||
CompactColumn.removeAll();
|
||||
EarthBlast.removeAll();
|
||||
EarthColumn.removeAll();
|
||||
|
|
|
@ -20,7 +20,7 @@ public class EarthbendingManager implements Runnable {
|
|||
RevertChecker.revertEarthBlocks();
|
||||
EarthTunnel.progressAll();
|
||||
EarthArmor.moveArmorAll();
|
||||
Catapult.progressAll(Catapult.class);
|
||||
Catapult.progressAll();
|
||||
Tremorsense.manage(Bukkit.getServer());
|
||||
EarthColumn.progressAll();
|
||||
CompactColumn.progressAll();
|
||||
|
|
|
@ -181,6 +181,12 @@ public class Combustion implements ConfigLoadable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Combustion ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
chargeTime = config.get().getLong("Abilities.Fire.Combustion.ChargeTime");
|
||||
|
|
|
@ -17,8 +17,7 @@ import com.projectkorra.projectkorra.util.ParticleEffect;
|
|||
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,
|
||||
private static final Material[] cookables = { Material.RAW_BEEF, Material.RAW_CHICKEN, Material.RAW_FISH, Material.PORK,
|
||||
Material.POTATO_ITEM, Material.RABBIT, Material.MUTTON };
|
||||
|
||||
private Player player;
|
||||
|
@ -137,6 +136,21 @@ public class Cook {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Cook ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (Cook ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCooktime(long cooktime) {
|
||||
this.cooktime = cooktime;
|
||||
|
@ -146,8 +160,4 @@ public class Cook {
|
|||
this.time = time;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
}
|
|
@ -312,10 +312,22 @@ public class FireBlast implements ConfigLoadable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (FireBlast ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(id);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (FireBlast ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
SPEED = config.get().getDouble("Abilities.Fire.FireBlast.Speed");
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.projectkorra.projectkorra.ability.AvatarState;
|
|||
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
|
||||
|
||||
public class FireBurst implements ConfigLoadable {
|
||||
|
||||
public static final ConcurrentHashMap<Player, FireBurst> instances = new ConcurrentHashMap<>();
|
||||
private static double PARTICLES_PERCENTAGE = 5;
|
||||
|
||||
|
@ -116,6 +117,12 @@ public class FireBurst implements ConfigLoadable {
|
|||
instances.remove(player);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (FireBurst ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -166,6 +173,12 @@ public class FireBurst implements ConfigLoadable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (FireBurst ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
//No need for this because there are no static variables.
|
||||
|
|
|
@ -11,6 +11,7 @@ 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;
|
||||
|
@ -117,6 +118,12 @@ public class FireJet implements ConfigLoadable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (FireJet ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
defaultfactor = config.get().getDouble("Abilities.Fire.FireJet.Speed");
|
||||
|
@ -128,6 +135,12 @@ public class FireJet implements ConfigLoadable {
|
|||
instances.remove(player);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (FireJet ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
|
|
@ -217,16 +217,16 @@ public class FireMethods {
|
|||
}
|
||||
|
||||
public static void stopBending() {
|
||||
FireStream.removeAll(FireStream.class);
|
||||
Fireball.removeAll(Fireball.class);
|
||||
WallOfFire.removeAll(WallOfFire.class);
|
||||
Lightning.removeAll(Lightning.class);
|
||||
FireShield.removeAll(FireShield.class);
|
||||
FireBlast.removeAll(FireBlast.class);
|
||||
FireBurst.removeAll(FireBurst.class);
|
||||
FireJet.removeAll(FireJet.class);
|
||||
Cook.removeAll(Cook.class);
|
||||
Illumination.removeAll(Illumination.class);
|
||||
FireStream.removeAll();
|
||||
Fireball.removeAll();
|
||||
WallOfFire.removeAll();
|
||||
Lightning.removeAll();
|
||||
FireShield.removeAll();
|
||||
FireBlast.removeAll();
|
||||
FireBurst.removeAll();
|
||||
FireJet.removeAll();
|
||||
Cook.removeAll();
|
||||
Illumination.removeAll();
|
||||
FireCombo.removeAll();
|
||||
for (Location loc : tempFire.keySet()){
|
||||
revertTempFire(loc);
|
||||
|
|
|
@ -237,10 +237,22 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
DURATION = config.get().getLong("Abilities.Fire.FireShield.Duration");
|
||||
|
|
|
@ -185,6 +185,12 @@ public class FireStream implements ConfigLoadable {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (FireStream ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(id);
|
||||
}
|
||||
|
|
|
@ -332,8 +332,20 @@ public class Fireball implements ConfigLoadable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Fireball ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
instances.remove(this.id);
|
||||
instances.remove(id);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (Fireball ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,25 +15,25 @@ public class FirebendingManager implements Runnable {
|
|||
|
||||
public void run() {
|
||||
FirePassive.handlePassive();
|
||||
FireJet.progressAll(FireJet.class);
|
||||
Cook.progressAll(Cook.class);
|
||||
Illumination.progressAll(Illumination.class);
|
||||
FireBlast.progressAll(FireBlast.class);
|
||||
Fireball.progressAll(Fireball.class);
|
||||
FireBurst.progressAll(FireBurst.class);
|
||||
FireShield.progressAll(FireShield.class);
|
||||
Lightning.progressAll(Lightning.class);
|
||||
WallOfFire.progressAll(WallOfFire.class);
|
||||
Combustion.progressAll(Combustion.class);
|
||||
FireJet.progressAll();
|
||||
Cook.progressAll();
|
||||
Illumination.progressAll();
|
||||
FireBlast.progressAll();
|
||||
Fireball.progressAll();
|
||||
FireBurst.progressAll();
|
||||
FireShield.progressAll();
|
||||
Lightning.progressAll();
|
||||
WallOfFire.progressAll();
|
||||
Combustion.progressAll();
|
||||
for (Block block : FireStream.ignitedblocks.keySet()) {
|
||||
if (block.getType() != Material.FIRE) {
|
||||
FireStream.ignitedblocks.remove(block);
|
||||
}
|
||||
}
|
||||
FireMethods.removeFire();
|
||||
HeatControl.progressAll(HeatControl.class);
|
||||
HeatControl.progressAll();
|
||||
FireStream.dissipateAll();
|
||||
FireStream.progressAll(FireStream.class);
|
||||
FireStream.progressAll();
|
||||
FireCombo.progressAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,6 +154,12 @@ public class HeatControl implements ConfigLoadable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (HeatControl ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
RANGE = config.get().getDouble("Abilities.Fire.HeatControl.Solidify.Range");
|
||||
|
|
|
@ -83,6 +83,12 @@ public class Illumination implements ConfigLoadable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Illumination ability : instances.values()) {
|
||||
ability.progress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
range = config.get().getInt("Abilities.Fire.Illumination.Range");
|
||||
|
@ -93,6 +99,12 @@ public class Illumination implements ConfigLoadable {
|
|||
instances.remove(player);
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (Illumination ability : instances.values()) {
|
||||
ability.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void revert() {
|
||||
if (block != null) {
|
||||
|
|
|
@ -376,10 +376,22 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
SELF_HIT_WATER = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitWater");
|
||||
|
|
|
@ -223,10 +223,22 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadVariables() {
|
||||
RANGE = config.get().getInt("Abilities.Fire.WallOfFire.Range");
|
||||
|
|
|
@ -341,8 +341,7 @@ public class WaterArms {
|
|||
}
|
||||
|
||||
private void checkIfZapped() {
|
||||
for (Integer id : Lightning.getInstances(Lightning.class).keySet()) {
|
||||
Lightning l = (Lightning) Lightning.getInstances(Lightning.class).get(id);
|
||||
for (Lightning l : Lightning.instances.values()) {
|
||||
for (Lightning.Arc arc : l.getArcs()) {
|
||||
for (Block arm : revert.keySet()) {
|
||||
for (Location loc : arc.getPoints()) {
|
||||
|
|
Loading…
Reference in a new issue