New system

This commit is contained in:
Jack Lin 2015-07-31 12:16:13 +12:00
parent f4a21e7646
commit 608b3ccc36
34 changed files with 2207 additions and 1921 deletions

View file

@ -0,0 +1,14 @@
package com.projectkorra.ProjectKorra.Ability;
/**
* Represents a {@link Ability} that is either an addon or
* an addition to an existing ability
*/
public abstract class AddonAbility extends CoreAbility {
@Override
public StockAbilities getStockAbility() {
return null;
}
}

View file

@ -1,177 +0,0 @@
package com.projectkorra.ProjectKorra.Ability;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.configuration.ConfigLoadable;
/**
* Represents an {@link ConfigLoadable} Ability.
*/
public abstract class BaseAbility 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(StockAbilities)} from the
* outside.
*/
private static ConcurrentHashMap<StockAbilities, ConcurrentHashMap<Object, BaseAbility>> instances = new ConcurrentHashMap<>();
//protected static AbilityMap<Ability> instances = new AbilityMap<>();
private static int ID = Integer.MIN_VALUE;
private final StockAbilities stockAbility = getStockAbility();
private final InstanceType type = getInstanceType();
private Player player;
private UUID uniqueId;
private int id;
protected final void putInstance(Player player, BaseAbility ability) {
if (type == InstanceType.MULTIPLE) {
this.id = ID;
} else {
this.id = -1;
}
this.uniqueId = player.getUniqueId();
this.player = player;
if (instances.containsKey(stockAbility)) {
if (type == InstanceType.MULTIPLE) {
instances.get(stockAbility).put(id, ability);
} else {
instances.get(stockAbility).put(uniqueId, ability);
}
} else {
ConcurrentHashMap<Object, BaseAbility> map = new ConcurrentHashMap<>();
if (type == InstanceType.MULTIPLE) {
map.put(id, ability);
} else {
map.put(uniqueId, ability);
}
instances.put(stockAbility, map);
}
if (id != -1) {
if (ID == Integer.MAX_VALUE)
ID = Integer.MIN_VALUE;
ID++;
}
}
/**
* Removes the UUID from the instances map
*/
private final void removeInstance() {
if (instances.containsKey(stockAbility)) {
if (instances.get(stockAbility) != null) {
if (type == InstanceType.MULTIPLE) {
instances.get(getStockAbility()).remove(id);
} else {
instances.get(getStockAbility()).remove(uniqueId);
}
}
}
}
/**
* An access method to get an the instances of a {@link StockAbilities StockAbility}.
*
* @param abilty The instances map to get
* @return a map of instances from the specified {@link StockAbilities StockAbility}
*/
public final static ConcurrentHashMap<Object, BaseAbility> getInstance(StockAbilities ability) {
if (instances.containsKey(ability)) {
return instances.get(ability);
}
return new ConcurrentHashMap<Object, BaseAbility>();
}
/**
* Convenience method that calls {@link #progress()} for all instances
* of a specified ability.
*
* @see #progressAll()
*/
public static void progressAll(StockAbilities ability) {
for (Object object : getInstance(ability).keySet()) {
instances.get(ability).get(object).progress();
}
}
/**
* Convenience method that calls {@link #progress()} for all instances.
*
* @see #progressAll(StockAbilities)
*/
public static void progressAll() {
for (StockAbilities ability : instances.keySet()) {
progressAll(ability);
}
}
/**
* Convenience method that calls {@link #remove()} for all instances
* of a specified ability.
*
* @see #removeAll()
*/
public static void removeAll(StockAbilities ability) {
for (Object object : getInstance(ability).keySet()) {
instances.get(ability).get(object).remove();
}
}
/**
* Convenience method that calls {@link #remove()} for all instances.
*
* @see #removeAll(StockAbilities)
*/
public static void removeAll() {
for (StockAbilities ability : instances.keySet()) {
removeAll(ability);
}
}
/**
* 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 UUID to be properly removed from the {@link #instances}.
*/
@Override
public void remove() {
removeInstance();
}
/**
* Gets the {@link StockAbilities StockAbility} that created this instance.
*
* @return stockabilities enum or null
*/
public abstract StockAbilities getStockAbility();
/**
* Convenience method to get instance map for current ability class.
*
* @return {@link #getInstance(StockAbilities)} for the current ability
*/
public ConcurrentHashMap<Object, BaseAbility> getInstance() {
return getInstance(stockAbility);
}
public Player getPlayer() {
return player;
}
public UUID getUniqueId() {
return uniqueId;
}
public InstanceType getInstanceType() {
return InstanceType.SINGLE;
}
public int getID() {
return id;
}
}

View file

@ -0,0 +1,326 @@
package com.projectkorra.ProjectKorra.Ability;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.configuration.ConfigLoadable;
/**
* Represents an {@link ConfigLoadable} Ability.
*/
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(StockAbilities)} from the
* outside.
*/
//private static ConcurrentHashMap<StockAbilities, ConcurrentHashMap<UUID, CoreAbility>> instances = new ConcurrentHashMap<>();
//private static ConcurrentHashMap<UUID, ConcurrentHashMap<Integer, CoreAbility>> instances = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Integer, CoreAbility> instances = new ConcurrentHashMap<>();
//protected static AbilityMap<Ability> instances = new AbilityMap<>();
private static ConcurrentHashMap<StockAbilities, ArrayList<Integer>> abilityMap = new ConcurrentHashMap<>();
private static int ID = Integer.MIN_VALUE;
private final StockAbilities stockAbility = getStockAbility();
private final InstanceType type = getInstanceType();
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) {
List<CoreAbility> abilities = getAbilitiesFromPlayer(player);
for (CoreAbility coreAbility : abilities) {
if (ability.isInstance(coreAbility)) {
if (coreAbility.getPlayer().getUniqueId().equals(player.getUniqueId())) {
return true;
}
}
}
return 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 map with all the instances of CoreAbiliy's.
*
* @return a map of core abilities
*/
public static ConcurrentHashMap<Integer, CoreAbility> getInstances() {
return instances;
}
/**
* An access method to get an the instances of a {@link StockAbilities StockAbility}.
*
* @param ability The instances map to get
* @return a map of instances from the specified {@link StockAbilities StockAbility}
*/
public final static ConcurrentHashMap<Integer, CoreAbility> getInstances(StockAbilities 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;
}
public final static ConcurrentHashMap<Integer, CoreAbility> getInstances(Class<? extends CoreAbility> ability) {
ConcurrentHashMap<Integer, CoreAbility> instanceMap = new ConcurrentHashMap<>();
for (Integer id : instances.keySet()) {
if (ability.isInstance(instances.get(id))) {
instanceMap.put(id, instances.get(id));
}
}
return instanceMap;
}
/**
* Convenience method that calls {@link #progress()} for all instances.
*
* @see #progressAll(Class)
* @see #progressAll(StockAbilities)
*/
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()
* @see #progressAll(StockAbilities)
*/
public static void progressAll(Class<? extends CoreAbility> ability) {
for (Integer id : instances.keySet()) {
if (ability.isInstance(instances.get(id))) {
instances.get(id).progress();
}
}
}
/**
* Convenience method that calls {@link #progress()} for all instances
* of a specified stock ability.
*
* @see #progressAll()
* @see #progressAll(Class)
*/
public static void progressAll(StockAbilities ability) {
for (Integer id : getInstances(ability).keySet()) {
getInstances(ability).get(id).progress();
}
}
/**
* Convenience method that calls {@link #remove()} for all instances.
*
* @see #removeAll(StockAbilities)
* @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()
* @see #removeAll(StockAbilities)
*/
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()
* @see #removeAll(Class)
*/
public static void removeAll(StockAbilities ability) {
for (Integer id : getInstances(ability).keySet()) {
getInstances(ability).get(id).remove();
}
}
/**
* 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 {@link #getInstance(StockAbilities)} for the current ability
*/
public CoreAbility getInstance() {
return instances.get(id);
}
public InstanceType getInstanceType() {
return InstanceType.SINGLE;
}
public Player getPlayer() {
return player;
}
/**
* Gets the {@link StockAbilities StockAbility} that created this instance.
* This method will return null for abilities that are not stock abilities
*
* @return stockabilities enum or null
*/
public abstract StockAbilities getStockAbility();
/**
* Gets the {@link InstanceType} of the ability.
*
* @return instance type
*/
public InstanceType getType() {
return type;
}
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;
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 (instances.containsKey(stockAbility)) {
// if (type == InstanceType.MULTIPLE) {
// instances.get(stockAbility).put(id, ability);
// } else {
// instances.get(stockAbility).put(uniqueId, ability);
// }
// } else {
// ConcurrentHashMap<Object, CoreAbility> map = new ConcurrentHashMap<>();
// if (type == InstanceType.MULTIPLE) {
// map.put(id, ability);
// } else {
// map.put(uniqueId, ability);
// }
// instances.put(stockAbility, map);
// }
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 UUID to be properly removed from the {@link #instances}.
*/
@Override
public void remove() {
removeInstance();
}
/**
* Removes the UUID from the instances map
*/
private final void removeInstance() {
// if (instances.containsKey(stockAbility)) {
// if (instances.get(stockAbility) != null) {
// if (type == InstanceType.MULTIPLE) {
// instances.get(getStockAbility()).remove(id);
// } else {
// instances.get(getStockAbility()).remove(uniqueId);
// }
// }
// }
if (instances.containsKey(id)) {
instances.remove(id);
}
if (stockAbility != null) {
if (abilityMap.containsKey(stockAbility)) {
abilityMap.get(stockAbility).remove(id);
if (abilityMap.get(stockAbility).isEmpty()) {
abilityMap.remove(stockAbility);
}
}
}
}
}

View file

@ -25,11 +25,11 @@ import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.Objects.HorizontalVelocityTracker;
public class AirBlast extends BaseAbility {
public class AirBlast extends CoreAbility {
private static ConcurrentHashMap<Player, Location> origins = new ConcurrentHashMap<Player, Location>();
@ -38,8 +38,8 @@ public class AirBlast extends BaseAbility {
public static double affectingradius = config.get().getDouble("Abilities.Air.AirBlast.Radius");
public static double defaultpushfactor = config.get().getDouble("Abilities.Air.AirBlast.Push");
private static double originselectrange = 10;
private static final int maxticks = 10000;
/* Package visible variables */
static final int maxticks = 10000;
static double maxspeed = 1. / defaultpushfactor;
/* End Package visible variables */
@ -144,7 +144,7 @@ public class AirBlast extends BaseAbility {
}
public static void progressAll() {
BaseAbility.progressAll(StockAbilities.AirBlast);
CoreAbility.progressAll(StockAbilities.AirBlast);
for (Player player : origins.keySet()) {
playOriginEffect(player);
}
@ -259,6 +259,7 @@ public class AirBlast extends BaseAbility {
@SuppressWarnings("deprecation")
public boolean progress() {
//ProjectKorra.log.info("FireBlast id: " + getID());
if (player.isDead() || !player.isOnline()) {
remove();
return false;

View file

@ -11,12 +11,12 @@ import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Element;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
public class AirBubble extends BaseAbility {
public class AirBubble extends CoreAbility {
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");
@ -36,8 +36,8 @@ public class AirBubble extends BaseAbility {
}
public static boolean canFlowTo(Block block) {
for (Object uuid : getInstance(StockAbilities.AirBubble).keySet()) {
if (((AirBubble) getInstance(StockAbilities.AirBubble).get(uuid)).blockInBubble(block)) {
for (Integer id : getInstances(StockAbilities.AirBubble).keySet()) {
if (((AirBubble) getInstances(StockAbilities.AirBubble).get(id)).blockInBubble(block)) {
return false;
}
}
@ -54,14 +54,14 @@ public class AirBubble extends BaseAbility {
for (Player player : server.getOnlinePlayers()) {
if (GeneralMethods.getBoundAbility(player) != null) {
if (GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirBubble") || GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterBubble")) {
if (!getInstance(StockAbilities.AirBubble).containsKey(player.getUniqueId()) && player.isSneaking()) {
if (!containsPlayer(player, AirBubble.class) && player.isSneaking()) {
new AirBubble(player);
}
}
}
}
BaseAbility.progressAll(StockAbilities.AirBubble);
CoreAbility.progressAll(StockAbilities.AirBubble);
}
public boolean blockInBubble(Block block) {

View file

@ -12,10 +12,10 @@ 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.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
public class AirBurst extends BaseAbility {
public class AirBurst extends CoreAbility {
private static double PARTICLES_PERCENTAGE = 50;
@ -29,7 +29,7 @@ public class AirBurst extends BaseAbility {
private long starttime;
private long chargetime = config.get().getLong("Abilities.Air.AirBurst.ChargeTime");
private boolean charged = false;
public ArrayList<AirBlast> blasts = new ArrayList<AirBlast>();
private ArrayList<AirBlast> blasts = new ArrayList<AirBlast>();
private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
public AirBurst() {
@ -41,7 +41,7 @@ public class AirBurst extends BaseAbility {
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("AirBurst"))
return;
if (getInstance(StockAbilities.AirBurst).containsKey(player.getUniqueId()))
if (containsPlayer(player, AirBurst.class))
return;
/* End Initial Checks */
reloadVariables();
@ -54,8 +54,9 @@ public class AirBurst extends BaseAbility {
}
public static void coneBurst(Player player) {
if (getInstance(StockAbilities.AirBurst).containsKey(player.getUniqueId()))
((AirBurst) getInstance(StockAbilities.AirBurst).get(player.getUniqueId())).coneBurst();
if (containsPlayer(player, AirBurst.class)) {
((AirBurst) getAbilityFromPlayer(player, AirBurst.class)).coneBurst();;
}
}
public static void fallBurst(Player player) {
@ -68,7 +69,7 @@ public class AirBurst extends BaseAbility {
if (GeneralMethods.getBoundAbility(player) == null) {
return;
}
if (getInstance(StockAbilities.AirBurst).containsKey(player.getUniqueId())) {
if (containsPlayer(player, AirBurst.class)) {
return;
}
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirBurst")) {

View file

@ -1,9 +1,7 @@
package com.projectkorra.ProjectKorra.airbending;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -13,10 +11,10 @@ import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
public class AirScooter extends BaseAbility {
public class AirScooter extends CoreAbility {
private static double speed = config.get().getDouble("Abilities.Air.AirScooter.Speed");
private static final long interval = 100;
@ -29,8 +27,7 @@ public class AirScooter extends BaseAbility {
public AirScooter(Player player) {
/* Initial Check */
if (getInstance(StockAbilities.AirScooter).containsKey(player.getUniqueId())) {
getInstance(StockAbilities.AirScooter).get(player.getUniqueId()).remove();
if (check(player)) {
return;
}
if (!player.isSprinting()
@ -57,16 +54,25 @@ public class AirScooter extends BaseAbility {
progress();
}
public static void check(Player player) {
if (getInstance(StockAbilities.AirScooter).containsKey(player.getUniqueId())) {
getInstance(StockAbilities.AirScooter).get(player.getUniqueId()).remove();
/**
* Checks if player has an instance already and removes
* if they do.
*
* @param player The player to check
* @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();
return true;
}
return false;
}
public static ArrayList<Player> getPlayers() {
ArrayList<Player> players = new ArrayList<Player>();
for (Object uuid : getInstance(StockAbilities.AirScooter).keySet()) {
players.add(Bukkit.getPlayer((UUID) uuid));
for (Integer id : getInstances(StockAbilities.AirScooter).keySet()) {
players.add(getInstances(StockAbilities.AirScooter).get(id).getPlayer());
}
return players;
}

View file

@ -11,14 +11,14 @@ import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
import com.projectkorra.ProjectKorra.firebending.Combustion;
import com.projectkorra.ProjectKorra.firebending.FireBlast;
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
public class AirShield extends BaseAbility {
public class AirShield extends CoreAbility {
private static double MAX_RADIUS = config.get().getDouble("Abilities.Air.AirShield.Radius");
private static boolean isToggle = config.get().getBoolean("Abilities.Air.AirShield.IsAvatarStateToggle");
@ -33,8 +33,7 @@ public class AirShield extends BaseAbility {
public AirShield(Player player) {
/* Initial Check */
if (AvatarState.isAvatarState(player)
&& getInstance(StockAbilities.AirShield).containsKey(player.getUniqueId()) && isToggle) {
if (AvatarState.isAvatarState(player) && containsPlayer(player, AirShield.class) && isToggle) {
//instances.remove(player.getUniqueId());
super.remove();
return;
@ -65,8 +64,8 @@ public class AirShield extends BaseAbility {
}
public static boolean isWithinShield(Location loc){
for (Object uuid : getInstance(StockAbilities.AirShield).keySet()) {
AirShield ashield = (AirShield) getInstance(StockAbilities.AirShield).get(uuid);
for (Integer id : getInstances(StockAbilities.AirShield).keySet()) {
AirShield ashield = (AirShield) getInstances(StockAbilities.AirShield).get(id);
if (ashield.player.getLocation().getWorld() != loc.getWorld())
return false;
if(ashield.player.getLocation().distance(loc) <= ashield.radius)

View file

@ -1,9 +1,7 @@
package com.projectkorra.ProjectKorra.airbending;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -11,10 +9,10 @@ import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
public class AirSpout extends BaseAbility {
public class AirSpout extends CoreAbility {
private static double HEIGHT = config.get().getDouble("Abilities.Air.AirSpout.Height");
private static final long interval = 100;
@ -26,8 +24,8 @@ public class AirSpout extends BaseAbility {
public AirSpout(Player player) {
/* Initial Check */
if (getInstance(StockAbilities.AirSpout).containsKey(player.getUniqueId())) {
getInstance(StockAbilities.AirSpout).get(player.getUniqueId()).remove();
if (containsPlayer(player, AirSpout.class)) {
getAbilityFromPlayer(player, AirSpout.class).remove();
return;
}
/* End Initial Check */
@ -42,8 +40,8 @@ public class AirSpout extends BaseAbility {
public static ArrayList<Player> getPlayers() {
ArrayList<Player> players = new ArrayList<Player>();
for (Object uuid: getInstance(StockAbilities.AirSpout).keySet()) {
players.add(Bukkit.getPlayer((UUID) uuid));
for (Integer id: getInstances(StockAbilities.AirSpout).keySet()) {
players.add(getInstances(StockAbilities.AirSpout).get(id).getPlayer());
}
return players;
}
@ -51,8 +49,8 @@ public class AirSpout extends BaseAbility {
public static boolean removeSpouts(Location loc0, double radius,
Player sourceplayer) {
boolean removed = false;
for (Object uuid : getInstance(StockAbilities.AirSpout).keySet()) {
Player player = Bukkit.getPlayer((UUID) uuid);
for (Integer id : getInstances(StockAbilities.AirSpout).keySet()) {
Player player = getInstances(StockAbilities.AirSpout).get(id).getPlayer();
if (!player.equals(sourceplayer)) {
Location loc1 = player.getLocation().getBlock().getLocation();
loc0 = loc0.getBlock().getLocation();
@ -63,7 +61,7 @@ public class AirSpout extends BaseAbility {
double distance = Math.sqrt(dx * dx + dz * dz);
if (distance <= radius && dy > 0 && dy < HEIGHT){
getInstance(StockAbilities.AirSpout).get(uuid).remove();
getInstances(StockAbilities.AirSpout).get(id).remove();
removed = true;
}
}

View file

@ -15,18 +15,17 @@ import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
public class AirSuction extends BaseAbility {
public class AirSuction extends CoreAbility {
private static ConcurrentHashMap<Player, Location> origins = new ConcurrentHashMap<Player, Location>();
static final double maxspeed = AirBlast.maxspeed;
private static final int maxticks = AirBlast.maxticks;
private static final double maxspeed = AirBlast.maxspeed;
private static final int maxticks = 10000;
//private static long soonesttime = config.get().getLong("Properties.GlobalCooldown");
private static double SPEED = config.get().getDouble("Abilities.Air.AirSuction.Speed");
@ -131,7 +130,7 @@ public class AirSuction extends BaseAbility {
}
public static void progressAll() {
BaseAbility.progressAll(StockAbilities.AirSuction);
CoreAbility.progressAll(StockAbilities.AirSuction);
for (Player player : origins.keySet()) {
playOriginEffect(player);
}

View file

@ -20,7 +20,7 @@ import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
import com.projectkorra.ProjectKorra.firebending.Combustion;
@ -29,7 +29,7 @@ import com.projectkorra.ProjectKorra.firebending.Illumination;
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
public class AirSwipe extends BaseAbility {
public class AirSwipe extends CoreAbility {
private static int stepsize = 4;
@ -97,15 +97,15 @@ public class AirSwipe extends BaseAbility {
public static boolean removeSwipesAroundPoint(Location loc, double radius) {
boolean removed = false;
for (Object id : getInstance(StockAbilities.AirSwipe).keySet()) {
AirSwipe aswipe = (AirSwipe) getInstance(StockAbilities.AirSwipe).get(id);
for (Integer id : getInstances(StockAbilities.AirSwipe).keySet()) {
AirSwipe aswipe = (AirSwipe) getInstances(StockAbilities.AirSwipe).get(id);
for (Vector vec : aswipe.elements.keySet()) {
Location vectorLoc = aswipe.elements.get(vec);
if (vectorLoc != null && vectorLoc.getWorld().equals(loc.getWorld())) {
if (vectorLoc.distance(loc) <= radius) {
//instances.remove(aswipe.uuid);
getInstance(StockAbilities.AirSwipe).remove(id); //TODO: Check if this works
aswipe.remove();
removed = true;
}
}

View file

@ -6,10 +6,10 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
public class FlightAbility extends BaseAbility {
public class FlightAbility extends CoreAbility {
private static ConcurrentHashMap<String, Integer> hits = new ConcurrentHashMap<String, Integer>();
private static ConcurrentHashMap<String, Boolean> hovering = new ConcurrentHashMap<String, Boolean>();
@ -40,7 +40,7 @@ public class FlightAbility extends BaseAbility {
}
public static boolean contains(Player player) {
return getInstance(StockAbilities.Flight).containsKey(player.getUniqueId());
return containsPlayer(player, FlightAbility.class);
}
public static boolean isHovering(Player player) {
@ -49,11 +49,11 @@ public class FlightAbility extends BaseAbility {
public static void remove(Player player) {
if (contains(player))
getInstance(StockAbilities.Flight).get(player.getUniqueId()).remove();
getAbilityFromPlayer(player, FlightAbility.class).remove();
}
public static void removeAll() {
BaseAbility.removeAll(StockAbilities.Flight);
CoreAbility.removeAll(StockAbilities.Flight);
hits.clear();
hovering.clear();
}

View file

@ -17,7 +17,7 @@ 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.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
/**
@ -30,7 +30,7 @@ import com.projectkorra.ProjectKorra.Ability.StockAbilities;
* be used on multiple entities within a large radius.
* If the user is damaged while performing this ability then the ability is removed.
*/
public class Suffocate extends BaseAbility {
public class Suffocate extends CoreAbility {
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,7 +96,7 @@ public class Suffocate extends BaseAbility {
blindDelay = BLIND_DELAY;
blindRepeat = BLIND_INTERVAL;
if (getInstances().containsKey(player.getUniqueId()))
if (containsPlayer(player, Suffocate.class))
return;
if (AvatarState.isAvatarState(player)) {
@ -146,22 +146,22 @@ public class Suffocate extends BaseAbility {
/** Stops an entity from being suffocated **/
public static void breakSuffocate(Entity entity) {
for (Object uuid : getInstances().keySet()) {
Suffocate suffocate = (Suffocate) getInstances().get(uuid);
for (Integer id : getInstances().keySet()) {
Suffocate suffocate = (Suffocate) getInstances().get(id);
if (suffocate.targets.contains(entity)) {
suffocate.breakSuffocateLocal(entity);
}
}
}
public static ConcurrentHashMap<Object, ? extends BaseAbility> getInstances() {
return getInstance(StockAbilities.Suffocate);
public static ConcurrentHashMap<Integer, CoreAbility> getInstances() {
return getInstances(StockAbilities.Suffocate);
}
/** Checks if an entity is being suffocated **/
public static boolean isBreathbent(Entity entity) {
for (Object uuid : getInstances().keySet()) {
Suffocate suffocate = (Suffocate) getInstances().get(uuid);
for (Integer id : getInstances().keySet()) {
Suffocate suffocate = (Suffocate) getInstances().get(id);
if (suffocate.targets.contains(entity)) {
return suffocate.started;
}
@ -171,14 +171,14 @@ public class Suffocate extends BaseAbility {
/** Determines if a player is Suffocating entities **/
public static boolean isChannelingSphere(Player player) {
if (getInstances().containsKey(player.getUniqueId())) return true;
if (containsPlayer(player, Suffocate.class)) return true;
return false;
}
/** Removes an instance of Suffocate if player is the one suffocating entities **/
public static void remove(Player player) {
if (getInstances().containsKey(player.getUniqueId()))
getInstances().get(player.getUniqueId()).remove();
if (containsPlayer(player, Suffocate.class))
getAbilityFromPlayer(player, Suffocate.class).remove();
}
/** Removes all instances of Suffocate at loc within the radius threshold.
@ -187,9 +187,9 @@ public class Suffocate extends BaseAbility {
* @param causer: the player causing this instance to be removed
* **/
public static boolean removeAtLocation(Player causer, Location loc, double radius) {
Iterator<Object> it = getInstances().keySet().iterator();
Iterator<Integer> it = getInstances().keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
Integer key = it.next();
Suffocate val = (Suffocate) getInstances().get(key);
if (causer == null || !key.equals(causer)) {

View file

@ -2,10 +2,8 @@ package com.projectkorra.ProjectKorra.airbending;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
@ -15,10 +13,10 @@ import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
public class Tornado extends BaseAbility {
public class Tornado extends CoreAbility {
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");
@ -67,18 +65,12 @@ public class Tornado extends BaseAbility {
public static ArrayList<Player> getPlayers() {
ArrayList<Player> players = new ArrayList<Player>();
for (Object uuid : getInstance(StockAbilities.Tornado).keySet()) {
players.add(Bukkit.getPlayer((UUID) uuid));
for (Integer id : getInstances(StockAbilities.Tornado).keySet()) {
players.add(getInstances(StockAbilities.Tornado).get(id).getPlayer());
}
return players;
}
public static void progressAll() {
for (Object uuid : getInstance(StockAbilities.Tornado).keySet()) {
((Tornado) getInstance(StockAbilities.Tornado).get(uuid)).progress();
}
}
public double getMaxheight() {
return maxheight;
}

View file

@ -6,19 +6,25 @@ import org.bukkit.util.Vector;
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 ArcOfFire {
/**
* Used for the ability Blaze.
*/
public class ArcOfFire implements ConfigLoadable {
private static int defaultarc = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.Blaze.ArcOfFire.Arc");
private static int defaultrange = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.Blaze.ArcOfFire.Range");
private static int defaultarc = config.get().getInt("Abilities.Fire.Blaze.ArcOfFire.Arc");
private static int defaultrange = config.get().getInt("Abilities.Fire.Blaze.ArcOfFire.Range");
private static int stepsize = 2;
public ArcOfFire(Player player) {
/* Initial Checks */
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("Blaze")) return;
/* End Initial Checks */
reloadVariables();
Location location = player.getLocation();
int arc = (int) FireMethods.getFirebendingDayAugment(defaultarc,
@ -56,4 +62,10 @@ public class ArcOfFire {
+ "in roaring flames.";
}
@Override
public void reloadVariables() {
defaultarc = config.get().getInt("Abilities.Fire.Blaze.ArcOfFire.Arc");
defaultrange = config.get().getInt("Abilities.Fire.Blaze.ArcOfFire.Range");
}
}

View file

@ -1,11 +1,8 @@
package com.projectkorra.ProjectKorra.firebending;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -15,47 +12,46 @@ 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.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
import com.projectkorra.ProjectKorra.airbending.AirMethods;
public class Combustion {
public class Combustion extends CoreAbility {
static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static long chargeTime = config.get().getLong("Abilities.Fire.Combustion.ChargeTime");
public static long cooldown = config.get().getLong("Abilities.Fire.Combustion.Cooldown");
public static long chargeTime = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.Combustion.ChargeTime");
public static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.Combustion.Cooldown");
public static double speed = config.get().getDouble("Abilities.Fire.Combustion.Speed");
public static double defaultrange = config.get().getDouble("Abilities.Fire.Combustion.Range");
public static double defaultpower = config.get().getDouble("Abilities.Fire.Combustion.Power");
public static boolean breakblocks = config.get().getBoolean("Abilities.Fire.Combustion.BreakBlocks");
public static double radius = config.get().getDouble("Abilities.Fire.Combustion.Radius");
public static double defaultdamage = config.get().getDouble("Abilities.Fire.Combustion.Damage");
private static final int maxticks = 10000;
public static double speed = config.getDouble("Abilities.Fire.Combustion.Speed");
public static double defaultrange = config.getDouble("Abilities.Fire.Combustion.Range");
public static double defaultpower = config.getDouble("Abilities.Fire.Combustion.Power");
public static boolean breakblocks = config.getBoolean("Abilities.Fire.Combustion.BreakBlocks");
public static double radius = config.getDouble("Abilities.Fire.Combustion.Radius");
public static double defaultdamage = config.getDouble("Abilities.Fire.Combustion.Damage");
public Location location;
private Location location;
private Location origin;
private Player player;
private Vector direction;
private double range = defaultrange;
private double speedfactor;
static final int maxticks = 10000;
private int ticks = 0;
private float power;
private double damage;
public Player player;
@SuppressWarnings("unused")
private long starttime;
@SuppressWarnings("unused")
private boolean charged = false;
public static ConcurrentHashMap<Player, Combustion> instances = new ConcurrentHashMap<Player, Combustion>();
public Combustion(Player player) {
/* Initial Checks */
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (instances.containsKey(player)) return;
if (containsPlayer(player, Combustion.class)) return;
if (bPlayer.isOnCooldown("Combustion")) return;
/* End Initial Checks */
reloadVariables();
this.player = player;
starttime = System.currentTimeMillis();
origin = player.getEyeLocation();
@ -76,46 +72,97 @@ public class Combustion {
return;
}
instances.put(player, this);
//instances.put(player, this);
putInstance(player, this);
bPlayer.addCooldown("Combustion", cooldown);
}
private void progress() {
public static void explode(Player player) {
if (containsPlayer(player, Combustion.class)) {
Combustion combustion = (Combustion) getAbilityFromPlayer(player, Combustion.class);
combustion.createExplosion(combustion.location, combustion.power, breakblocks);
ParticleEffect.EXPLODE.display(combustion.location, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 3);
}
}
if (!instances.containsKey(player)) {
return;
public static boolean removeAroundPoint(Location loc, double radius) {
for (Integer id: getInstances(StockAbilities.Combustion).keySet()) {
Combustion combustion = (Combustion) getInstances(StockAbilities.Combustion).get(id);
if (combustion.location.getWorld() == loc.getWorld()) {
if (combustion.location.distance(loc) <= radius) {
explode(combustion.getPlayer());
combustion.remove();
return true;
}
}
}
return false;
}
private void advanceLocation() {
ParticleEffect.FIREWORKS_SPARK.display(location, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 5);
ParticleEffect.FLAME.display(location, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 2);
//if (Methods.rand.nextInt(4) == 0) {
FireMethods.playCombustionSound(location);
//}
location = location.add(direction.clone().multiply(speedfactor));
}
private void createExplosion(Location block, float power, boolean breakblocks) {
block.getWorld().createExplosion(block.getX(), block.getY(), block.getZ(), (float) defaultpower, true, breakblocks);
for (Entity entity: block.getWorld().getEntities()) {
if (entity instanceof LivingEntity) {
if (entity.getLocation().distance(block) < radius) { // They are close enough to the explosion.
GeneralMethods.damageEntity(player, entity, damage);
AirMethods.breakBreathbendingHold(entity);
}
}
}
remove();
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.Combustion;
}
@Override
public boolean progress() {
if (!containsPlayer(player, Combustion.class)) {
return false;
}
if (player.isDead() || !player.isOnline()) {
instances.remove(player);
return;
remove();
return false;
}
if (!GeneralMethods.canBend(player.getName(), "Combustion")) {
instances.remove(player);
return;
remove();
return false;
}
if (GeneralMethods.getBoundAbility(player) == null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Combustion")) {
instances.remove(player);
return;
remove();
return false;
}
if (GeneralMethods.isRegionProtectedFromBuild(player, "Combustion", location)) {
instances.remove(player);
return;
remove();
return false;
}
speedfactor = speed * (ProjectKorra.time_step / 1000.);
ticks++;
if (ticks > maxticks) {
instances.remove(player);
return;
remove();
return false;
}
if (location.distance(origin) > range) {
instances.remove(player);
return;
remove();
return false;
}
Block block = location.getBlock();
@ -133,59 +180,21 @@ public class Combustion {
}
}
advanceLocation();
return true;
}
private void createExplosion(Location block, float power, boolean breakblocks) {
block.getWorld().createExplosion(block.getX(), block.getY(), block.getZ(), (float) defaultpower, true, breakblocks);
for (Entity entity: block.getWorld().getEntities()) {
if (entity instanceof LivingEntity) {
if (entity.getLocation().distance(block) < radius) { // They are close enough to the explosion.
GeneralMethods.damageEntity(player, entity, damage);
AirMethods.breakBreathbendingHold(entity);
}
}
}
instances.remove(player);
@Override
public void reloadVariables() {
chargeTime = config.get().getLong("Abilities.Fire.Combustion.ChargeTime");
cooldown = config.get().getLong("Abilities.Fire.Combustion.Cooldown");
}
public static void explode(Player player) {
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);
}
}
private void advanceLocation() {
ParticleEffect.FIREWORKS_SPARK.display(location, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 5);
ParticleEffect.FLAME.display(location, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 2);
//if (Methods.rand.nextInt(4) == 0) {
FireMethods.playCombustionSound(location);
//}
location = location.add(direction.clone().multiply(speedfactor));
}
public static boolean removeAroundPoint(Location loc, double radius) {
for (Player player: instances.keySet()) {
Combustion combustion = instances.get(player);
if (combustion.location.getWorld() == loc.getWorld()) {
if (combustion.location.distance(loc) <= radius) {
explode(player);
instances.remove(player);
return true;
}
}
}
return false;
}
public static void progressAll() {
for (Player player: instances.keySet()) {
instances.get(player).progress();
}
speed = config.get().getDouble("Abilities.Fire.Combustion.Speed");
defaultrange = config.get().getDouble("Abilities.Fire.Combustion.Range");
defaultpower = config.get().getDouble("Abilities.Fire.Combustion.Power");
breakblocks = config.get().getBoolean("Abilities.Fire.Combustion.BreakBlocks");
radius = config.get().getDouble("Abilities.Fire.Combustion.Radius");
defaultdamage = config.get().getDouble("Abilities.Fire.Combustion.Damage");
}
// private void launchFireball() {

View file

@ -2,18 +2,19 @@ package com.projectkorra.ProjectKorra.firebending;
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 com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.Ability.AddonAbility;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
public class Cook {
public static ConcurrentHashMap<Player, Cook> instances = new ConcurrentHashMap<Player, Cook>();
/**
* Used in {@link HeatControl}.
*/
public class Cook extends AddonAbility {
private static final long COOK_TIME = 2000;
private static final Material[] cookables = { Material.RAW_BEEF,
@ -26,27 +27,30 @@ public class Cook {
private long cooktime = COOK_TIME;
public Cook(Player player) {
reloadVariables();
this.player = player;
items = player.getItemInHand();
time = System.currentTimeMillis();
if (isCookable(items.getType())) {
instances.put(player, this);
//instances.put(player, this);
putInstance(player, this);
}
}
private void progress() {
@Override
public boolean progress() {
if (player.isDead() || !player.isOnline()) {
cancel();
return;
remove();
return false;
}
if (GeneralMethods.getBoundAbility(player) == null) {
cancel();
return;
remove();
return false;
}
if (!player.isSneaking() || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) {
cancel();
return;
remove();
return false;
}
if (!items.equals(player.getItemInHand())) {
@ -55,8 +59,8 @@ public class Cook {
}
if (!isCookable(items.getType())) {
cancel();
return;
remove();
return false;
}
if (System.currentTimeMillis() > time + cooktime) {
@ -65,10 +69,7 @@ public class Cook {
}
ParticleEffect.FLAME.display(player.getEyeLocation(), 0.6F, 0.6F, 0.6F, 0, 6);
ParticleEffect.SMOKE.display(player.getEyeLocation(), 0.6F, 0.6F, 0.6F, 0, 6);
}
private void cancel() {
instances.remove(player);
return true;
}
private static boolean isCookable(Material material) {
@ -99,9 +100,9 @@ public class Cook {
break;
case RAW_FISH:
ItemStack salmon = new ItemStack(Material.RAW_FISH, 1, (short) 1);
if(is.getDurability() == salmon.getDurability()) {
if (is.getDurability() == salmon.getDurability()) {
cooked = new ItemStack(Material.COOKED_FISH, 1, (short) 1);
}else{
} else {
cooked = new ItemStack(Material.COOKED_FISH, 1);
}
break;
@ -126,16 +127,6 @@ public class Cook {
return cooked;
}
public static void progressAll() {
for (Player player : instances.keySet()) {
instances.get(player).progress();
}
}
public static void removeAll() {
instances.clear();
}
public Player getPlayer() {
return player;
}
@ -156,4 +147,7 @@ public class Cook {
this.cooktime = cooktime;
}
@Override
public void reloadVariables() {}
}

View file

@ -10,23 +10,28 @@ import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.BendingPlayer;
import com.projectkorra.ProjectKorra.Element;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.airbending.AirBlast;
import com.projectkorra.ProjectKorra.configuration.ConfigLoadable;
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
public class Extinguish {
/**
* Used in {@link Cook HeatControl}.
*/
public class Extinguish implements ConfigLoadable {
private static double defaultrange = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.HeatControl.Extinguish.Range");
private static double defaultradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.HeatControl.Extinguish.Radius");
private static double defaultrange = config.get().getDouble("Abilities.Fire.HeatControl.Extinguish.Range");
private static double defaultradius = config.get().getDouble("Abilities.Fire.HeatControl.Extinguish.Radius");
@SuppressWarnings("unused")
private static byte full = AirBlast.full;
public Extinguish(Player player) {
/* Initial Checks */
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("HeatControl")) return;
/* End Initial Checks */
reloadVariables();
double range = FireMethods.getFirebendingDayAugment(defaultrange, player.getWorld());
if (WaterMethods.isMeltable(player.getTargetBlock((HashSet<Material>) null, (int) range))) {
new HeatMelt(player);
@ -37,12 +42,11 @@ public class Extinguish {
player.getTargetBlock((HashSet<Material>) null, (int) range).getLocation(), radius)) {
Material mat = block.getType();
if(mat != Material.FIRE
if (mat != Material.FIRE
/*&& mat != Material.STATIONARY_LAVA
&& mat != Material.LAVA*/)
continue;
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze",
block.getLocation()))
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze", block.getLocation()))
continue;
if (block.getType() == Material.FIRE) {
block.setType(Material.AIR);
@ -88,4 +92,10 @@ public class Extinguish {
+ "This ability can also cool lava. If this ability is used while targetting ice or snow, it"
+ " will instead melt blocks in that area. Finally, sneaking with this ability will cook any food in your hand.";
}
@Override
public void reloadVariables() {
defaultrange = config.get().getDouble("Abilities.Fire.HeatControl.Extinguish.Range");
defaultradius = config.get().getDouble("Abilities.Fire.HeatControl.Extinguish.Radius");
}
}

View file

@ -3,7 +3,6 @@ package com.projectkorra.ProjectKorra.firebending;
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;
@ -19,6 +18,8 @@ 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.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
import com.projectkorra.ProjectKorra.airbending.AirMethods;
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
@ -26,33 +27,30 @@ import com.projectkorra.ProjectKorra.waterbending.Plantbending;
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
public class FireBlast {
public class FireBlast extends CoreAbility {
Random rand = new Random();
public static ConcurrentHashMap<Integer, FireBlast> instances = new ConcurrentHashMap<Integer, FireBlast>();
private static double SPEED = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Speed");
private static double PUSH_FACTOR = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Push");
private static double RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Range");
static boolean dissipate = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire.FireBlast.Dissipate");
private static int DAMAGE = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.FireBlast.Damage");
private static double fireticks = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.FireTicks");
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");
/* Package visible variables */
static boolean dissipate = config.get().getBoolean("Abilities.Fire.FireBlast.Dissipate");
/* End Package visible variables */
long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBlast.Cooldown");
public static double AFFECTING_RADIUS = 2;
// public static long interval = 2000;
public static byte full = 0x0;
private static int ID = Integer.MIN_VALUE;
private static boolean canPowerFurnace = true;
static final int maxticks = 10000;
private static final int maxticks = 10000;
private long cooldown = config.get().getLong("Abilities.Fire.FireBlast.Cooldown");
public Location location;
private Location location;
private List<Block> safe = new ArrayList<Block>();
private Location origin;
private Vector direction;
private Player player;
private int id;
private double speedfactor;
private int ticks = 0;
private double range = RANGE;
@ -61,35 +59,15 @@ public class FireBlast {
private double pushfactor = PUSH_FACTOR;
private double affectingradius = AFFECTING_RADIUS;
private boolean showParticles = true;
public FireBlast(Player player) {
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("FireBlast")) return;
if (player.getEyeLocation().getBlock().isLiquid() || Fireball.isCharging(player)) {
return;
}
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
this.player = player;
location = player.getEyeLocation();
origin = player.getEyeLocation();
direction = player.getEyeLocation().getDirection().normalize();
location = location.add(direction.clone());
id = ID;
instances.put(id, this);
bPlayer.addCooldown("FireBlast", cooldown);
if (ID == Integer.MAX_VALUE)
ID = Integer.MIN_VALUE;
ID++;
// time = System.currentTimeMillis();
// timers.put(player, System.currentTimeMillis());
}
private Random rand = new Random();
public FireBlast(Location location, Vector direction, Player player, int damage, List<Block> safeblocks) {
/* Initial Checks */
if (location.getBlock().isLiquid()) {
return;
}
/* End Initial Checks */
reloadVariables();
safe = safeblocks;
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
// timers.put(player, System.currentTimeMillis());
@ -98,21 +76,175 @@ public class FireBlast {
origin = location.clone();
this.direction = direction.clone().normalize();
this.damage *= 1.5;
id = ID;
instances.put(id, this);
if (ID == Integer.MAX_VALUE)
ID = Integer.MIN_VALUE;
ID++;
//instances.put(id, this);
putInstance(player, this);
}
public FireBlast(Player player) {
/* Initial Checks */
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("FireBlast")) return;
if (player.getEyeLocation().getBlock().isLiquid() || Fireball.isCharging(player)) {
return;
}
/* End Initial Checks */
reloadVariables();
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
this.player = player;
location = player.getEyeLocation();
origin = player.getEyeLocation();
direction = player.getEyeLocation().getDirection().normalize();
location = location.add(direction.clone());
//instances.put(id, this);
putInstance(player, this);
bPlayer.addCooldown("FireBlast", cooldown);
// time = System.currentTimeMillis();
// timers.put(player, System.currentTimeMillis());
}
public static boolean annihilateBlasts(Location location, double radius, Player source) {
boolean broke = false;
for (Integer id : getInstances(FireBlast.class).keySet()) {
FireBlast blast = (FireBlast) getInstances(FireBlast.class).get(id);
Location fireblastlocation = blast.location;
if (location.getWorld() == fireblastlocation.getWorld() && !blast.player.equals(source)) {
if (location.distance(fireblastlocation) <= radius) {
blast.remove();
broke = true;
}
}
}
if (Fireball.annihilateBlasts(location, radius, source))
broke = true;
return broke;
}
public static ArrayList<FireBlast> getAroundPoint(Location location, double radius) {
ArrayList<FireBlast> list = new ArrayList<FireBlast>();
for (Integer id : getInstances(StockAbilities.FireBlast).keySet()) {
FireBlast fireBlast = (FireBlast) getInstances(StockAbilities.FireBlast).get(id);
Location fireblastlocation = fireBlast.location;
if (location.getWorld() == fireblastlocation.getWorld()) {
if (location.distance(fireblastlocation) <= radius)
list.add(fireBlast);
}
}
return list;
}
public static String getDescription() {
return "FireBlast is the most fundamental bending technique of a firebender. "
+ "To use, simply left-click in a direction. A blast of fire will be created at your fingertips. "
+ "If this blast contacts an enemy, it will dissipate and engulf them in flames, "
+ "doing additional damage and knocking them back slightly. "
+ "If the blast hits terrain, it will ignite the nearby area. "
+ "Additionally, if you hold sneak, you will charge up the fireblast. "
+ "If you release it when it's charged, it will instead launch a powerful "
+ "fireball that explodes on contact.";
}
public static void removeFireBlastsAroundPoint(Location location, double radius) {
for (Integer id : getInstances(StockAbilities.FireBlast).keySet()) {
FireBlast fireBlast = (FireBlast) getInstances(StockAbilities.FireBlast).get(id);
Location fireblastlocation = fireBlast.location;
if (location.getWorld() == fireblastlocation.getWorld()) {
if (location.distance(fireblastlocation) <= radius)
fireBlast.remove();
}
}
Fireball.removeFireballsAroundPoint(location, radius);
}
private void advanceLocation() {
if (showParticles) {
//ParticleEffect.RED_DUST.display((float) 16, (float) 111, (float) 227, 0.01F, 0, location, 256D);
ParticleEffect.FLAME.display(location, 0.6F, 0.6F, 0.6F, 0, 20);
ParticleEffect.SMOKE.display(location, 0.6F, 0.6F, 0.6F, 0, 20);
}
location = location.add(direction.clone().multiply(speedfactor));
if (rand.nextInt(4) == 0) {
FireMethods.playFirebendingSound(location);
}
}
private void affect(Entity entity) {
if (entity.getUniqueId() != player.getUniqueId()) {
if (AvatarState.isAvatarState(player)) {
GeneralMethods.setVelocity(entity, direction.clone().multiply(AvatarState.getValue(pushfactor)));
} else {
GeneralMethods.setVelocity(entity, direction.clone().multiply(pushfactor));
}
if (entity instanceof LivingEntity) {
entity.setFireTicks((int) (fireticks * 20));
GeneralMethods.damageEntity(player, entity, (int) FireMethods.getFirebendingDayAugment((double) damage, entity.getWorld()));
AirMethods.breakBreathbendingHold(entity);
new Enflamed(entity, player);
remove();
}
}
}
public double getAffectingradius() {
return affectingradius;
}
public long getCooldown() {
return cooldown;
}
public double getDamage() {
return damage;
}
@Override
public InstanceType getInstanceType() {
return InstanceType.MULTIPLE;
}
public Player getPlayer() {
return player;
}
public double getPushfactor() {
return pushfactor;
}
public double getRange() {
return range;
}
public double getSpeed() {
return speed;
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.FireBlast;
}
private void ignite(Location location) {
for (Block block : GeneralMethods.getBlocksAroundPoint(location, affectingradius)) {
if (FireStream.isIgnitable(player, block) && !safe.contains(block)) {
if (WaterMethods.isPlant(block))
new Plantbending(block);
block.setType(Material.FIRE);
if (dissipate) {
FireStream.ignitedblocks.put(block, player);
FireStream.ignitedtimes.put(block, System.currentTimeMillis());
}
}
}
}
@Override
public boolean progress() {
ProjectKorra.log.info("FireBlast id: " + getID());
if (player.isDead() || !player.isOnline()) {
instances.remove(id);
remove();
return false;
}
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze", location)) {
instances.remove(id);
remove();
return false;
}
@ -121,7 +253,7 @@ public class FireBlast {
ticks++;
if (ticks > maxticks) {
instances.remove(id);
remove();
return false;
}
@ -136,12 +268,12 @@ public class FireBlast {
} else if (FireStream.isIgnitable(player, block.getRelative(BlockFace.UP))) {
ignite(location);
}
instances.remove(id);
remove();
return false;
}
if (location.distance(origin) > range) {
instances.remove(id);
remove();
return false;
}
@ -153,7 +285,7 @@ public class FireBlast {
if (EarthBlast.annihilateBlasts(location, radius, source)
|| WaterManipulation.annihilateBlasts(location, radius, source)
|| FireBlast.annihilateBlasts(location, radius, source)) {
instances.remove(id);
remove();
return false;
}
@ -179,131 +311,24 @@ public class FireBlast {
return true;
}
private void advanceLocation() {
if (showParticles) {
//ParticleEffect.RED_DUST.display((float) 16, (float) 111, (float) 227, 0.01F, 0, location, 256D);
ParticleEffect.FLAME.display(location, 0.6F, 0.6F, 0.6F, 0, 20);
ParticleEffect.SMOKE.display(location, 0.6F, 0.6F, 0.6F, 0, 20);
}
location = location.add(direction.clone().multiply(speedfactor));
if (rand.nextInt(4) == 0) {
FireMethods.playFirebendingSound(location);
}
@Override
public void reloadVariables() {
SPEED = config.get().getDouble("Abilities.Fire.FireBlast.Speed");
PUSH_FACTOR = config.get().getDouble("Abilities.Fire.FireBlast.Push");
RANGE = config.get().getDouble("Abilities.Fire.FireBlast.Range");
DAMAGE = config.get().getInt("Abilities.Fire.FireBlast.Damage");
fireticks = config.get().getDouble("Abilities.Fire.FireBlast.FireTicks");
dissipate = config.get().getBoolean("Abilities.Fire.FireBlast.Dissipate");
cooldown = config.get().getLong("Abilities.Fire.FireBlast.Cooldown");
range = RANGE;
damage = DAMAGE;
speed = SPEED;
pushfactor = PUSH_FACTOR;
affectingradius = AFFECTING_RADIUS;
}
private void ignite(Location location) {
for (Block block : GeneralMethods.getBlocksAroundPoint(location, affectingradius)) {
if (FireStream.isIgnitable(player, block) && !safe.contains(block)) {
if (WaterMethods.isPlant(block))
new Plantbending(block);
block.setType(Material.FIRE);
if (dissipate) {
FireStream.ignitedblocks.put(block, player);
FireStream.ignitedtimes.put(block, System.currentTimeMillis());
}
}
}
}
public void setDamage(double dmg) {
this.damage = dmg;
}
public void setRange(double range) {
this.range = range;
}
public void setShowParticles(boolean show) {
this.showParticles = show;
}
public static boolean progress(int ID) {
if (instances.containsKey(ID))
return instances.get(ID).progress();
return false;
}
public static void progressAll() {
for (int id : instances.keySet()) {
progress(id);
}
}
private void affect(Entity entity) {
if (entity.getEntityId() != player.getEntityId()) {
if (AvatarState.isAvatarState(player)) {
GeneralMethods.setVelocity(entity, direction.clone().multiply(AvatarState.getValue(pushfactor)));
} else {
GeneralMethods.setVelocity(entity, direction.clone().multiply(pushfactor));
}
if (entity instanceof LivingEntity) {
entity.setFireTicks((int) (fireticks * 20));
GeneralMethods.damageEntity(player, entity, (int) FireMethods.getFirebendingDayAugment((double) damage, entity.getWorld()));
AirMethods.breakBreathbendingHold(entity);
new Enflamed(entity, player);
instances.remove(id);
}
}
}
public static void removeFireBlastsAroundPoint(Location location, double radius) {
for (int id : instances.keySet()) {
Location fireblastlocation = instances.get(id).location;
if (location.getWorld() == fireblastlocation.getWorld()) {
if (location.distance(fireblastlocation) <= radius)
instances.remove(id);
}
}
Fireball.removeFireballsAroundPoint(location, radius);
}
public static ArrayList<FireBlast> getAroundPoint(Location location, double radius) {
ArrayList<FireBlast> list = new ArrayList<FireBlast>();
for (int id : instances.keySet()) {
Location fireblastlocation = instances.get(id).location;
if (location.getWorld() == fireblastlocation.getWorld()) {
if (location.distance(fireblastlocation) <= radius)
list.add(instances.get(id));
}
}
return list;
}
public static boolean annihilateBlasts(Location location, double radius, Player source) {
boolean broke = false;
for (int id : instances.keySet()) {
FireBlast blast = instances.get(id);
Location fireblastlocation = blast.location;
if (location.getWorld() == fireblastlocation.getWorld() && !blast.player.equals(source)) {
if (location.distance(fireblastlocation) <= radius) {
instances.remove(id);
broke = true;
}
}
}
if (Fireball.annihilateBlasts(location, radius, source))
broke = true;
return broke;
}
public static void removeAll() {
for (int id : instances.keySet()) {
instances.remove(id);
}
}
public static String getDescription() {
return "FireBlast is the most fundamental bending technique of a firebender. "
+ "To use, simply left-click in a direction. A blast of fire will be created at your fingertips. "
+ "If this blast contacts an enemy, it will dissipate and engulf them in flames, "
+ "doing additional damage and knocking them back slightly. "
+ "If the blast hits terrain, it will ignite the nearby area. "
+ "Additionally, if you hold sneak, you will charge up the fireblast. "
+ "If you release it when it's charged, it will instead launch a powerful "
+ "fireball that explodes on contact.";
}
public long getCooldown() {
return cooldown;
public void setAffectingradius(double affectingradius) {
this.affectingradius = affectingradius;
}
public void setCooldown(long cooldown) {
@ -312,40 +337,24 @@ public class FireBlast {
GeneralMethods.getBendingPlayer(player.getName()).addCooldown("FireBlast", cooldown);
}
public Player getPlayer() {
return player;
}
public double getSpeed() {
return speed;
}
public void setSpeed(double speed) {
this.speed = speed;
}
public double getPushfactor() {
return pushfactor;
public void setDamage(double dmg) {
this.damage = dmg;
}
public void setPushfactor(double pushfactor) {
this.pushfactor = pushfactor;
}
public double getAffectingradius() {
return affectingradius;
public void setRange(double range) {
this.range = range;
}
public void setAffectingradius(double affectingradius) {
this.affectingradius = affectingradius;
public void setShowParticles(boolean show) {
this.showParticles = show;
}
public double getRange() {
return range;
}
public double getDamage() {
return damage;
public void setSpeed(double speed) {
this.speed = speed;
}
}

View file

@ -2,7 +2,6 @@ package com.projectkorra.ProjectKorra.firebending;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Effect;
import org.bukkit.Location;
@ -16,44 +15,55 @@ 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.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
public class FireBurst {
private static ConcurrentHashMap<Player, FireBurst> instances = new ConcurrentHashMap<Player, FireBurst>();
public class FireBurst extends CoreAbility {
private static double PARTICLES_PERCENTAGE = 5;
private Player player;
private long starttime;
private int damage = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.FireBurst.Damage");
private long chargetime = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBurst.ChargeTime");
private long range = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBurst.Range");
private int damage = config.get().getInt("Abilities.Fire.FireBurst.Damage");
private long chargetime = config.get().getLong("Abilities.Fire.FireBurst.ChargeTime");
private long range = config.get().getLong("Abilities.Fire.FireBurst.Range");
private double deltheta = 10;
private double delphi = 10;
private boolean charged = false;
private ArrayList<FireBlast> blasts = new ArrayList<FireBlast>();
public FireBurst(Player player) {
/* Initial Checks */
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("FireBurst")) return;
if (instances.containsKey(player))
if (containsPlayer(player, FireBurst.class))
return;
/* End Initial Checks */
reloadVariables();
starttime = System.currentTimeMillis();
if (FireMethods.isDay(player.getWorld())) {
chargetime /= ProjectKorra.plugin.getConfig().getDouble("Properties.Fire.DayFactor");
chargetime /= config.get().getDouble("Properties.Fire.DayFactor");
}
if (AvatarState.isAvatarState(player))
chargetime = 0;
if (BendingManager.events.containsKey(player.getWorld())) {
if(BendingManager.events.get(player.getWorld()).equalsIgnoreCase("SozinsComet")) chargetime = 0;
if (BendingManager.events.get(player.getWorld()).equalsIgnoreCase("SozinsComet")) chargetime = 0;
}
this.player = player;
instances.put(player, this);
//instances.put(player, this);
putInstance(player, this);
}
public static void coneBurst(Player player) {
if (instances.containsKey(player))
instances.get(player).coneBurst();
if (containsPlayer(player, FireBurst.class))
((FireBurst) getAbilityFromPlayer(player, FireBurst.class)).coneBurst();
}
public static String getDescription() {
return "FireBurst is a very powerful firebending ability. "
+ "To use, press and hold sneak to charge your burst. "
+ "Once charged, you can either release sneak to launch a cone-shaped burst "
+ "of flames in front of you, or click to release the burst in a sphere around you. ";
}
private void coneBurst() {
@ -84,7 +94,97 @@ public class FireBurst {
}
}
// Methods.verbose("--" + AirBlast.instances.size() + "--");
instances.remove(player);
remove();
}
public long getChargetime() {
return chargetime;
}
public int getDamage() {
return damage;
}
public Player getPlayer() {
return player;
}
public long getRange() {
return range;
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.FireBurst;
}
/**
* To combat the sphere FireBurst lag we are only going to show a certain
* percentage of FireBurst particles at a time per tick. As the bursts spread out
* then we can show more at a time.
*/
public void handleSmoothParticles() {
for (int i = 0; i < blasts.size(); i++) {
final FireBlast fblast = blasts.get(i);
int toggleTime = (int) (i % (100 / PARTICLES_PERCENTAGE));
new BukkitRunnable() {
public void run() {
fblast.setShowParticles(true);
}
}.runTaskLater(ProjectKorra.plugin, toggleTime);
}
}
@Override
public boolean progress() {
if (!GeneralMethods.canBend(player.getName(), "FireBurst")) {
remove();
return false;
}
if (GeneralMethods.getBoundAbility(player) == null) {
remove();
return false;
}
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBurst")) {
remove();
return false;
}
if (System.currentTimeMillis() > starttime + chargetime && !charged) {
charged = true;
}
if (!player.isSneaking()) {
if (charged) {
sphereBurst();
} else {
remove();
}
} else if (charged) {
Location location = player.getEyeLocation();
// location = location.add(location.getDirection().normalize());
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 4, 3);
}
return true;
}
@Override
public void reloadVariables() {
//No need for this because there are no static variables.
//All instance variables are gotten newly from config
}
public void setChargetime(long chargetime) {
this.chargetime = chargetime;
}
public void setDamage(int damage) {
this.damage = damage;
}
public void setRange(long range) {
this.range = range;
}
private void sphereBurst() {
@ -110,101 +210,7 @@ public class FireBurst {
}
}
// Methods.verbose("--" + AirBlast.instances.size() + "--");
instances.remove(player);
remove();
handleSmoothParticles();
}
private void progress() {
if (!GeneralMethods.canBend(player.getName(), "FireBurst")) {
instances.remove(player);
return;
}
if (GeneralMethods.getBoundAbility(player) == null) {
instances.remove(player);
return;
}
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBurst")) {
instances.remove(player);
return;
}
if (System.currentTimeMillis() > starttime + chargetime && !charged) {
charged = true;
}
if (!player.isSneaking()) {
if (charged) {
sphereBurst();
} else {
instances.remove(player);
}
} else if (charged) {
Location location = player.getEyeLocation();
// location = location.add(location.getDirection().normalize());
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 4, 3);
}
}
public void handleSmoothParticles() {
/*
* To combat the sphere FireBurst lag we are only going to show a certain
* percentage of FireBurst particles at a time per tick. As the bursts spread out
* then we can show more at a time.
*/
for (int i = 0; i < blasts.size(); i++) {
final FireBlast fblast = blasts.get(i);
int toggleTime = (int) (i % (100 / PARTICLES_PERCENTAGE));
new BukkitRunnable() {
public void run() {
fblast.setShowParticles(true);
}
}.runTaskLater(ProjectKorra.plugin, toggleTime);
}
}
public static void progressAll() {
for (Player player : instances.keySet())
instances.get(player).progress();
}
public static String getDescription() {
return "FireBurst is a very powerful firebending ability. "
+ "To use, press and hold sneak to charge your burst. "
+ "Once charged, you can either release sneak to launch a cone-shaped burst "
+ "of flames in front of you, or click to release the burst in a sphere around you. ";
}
public static void removeAll() {
instances.clear();
}
public Player getPlayer() {
return player;
}
public int getDamage() {
return damage;
}
public void setDamage(int damage) {
this.damage = damage;
}
public long getChargetime() {
return chargetime;
}
public void setChargetime(long chargetime) {
this.chargetime = chargetime;
}
public long getRange() {
return range;
}
public void setRange(long range) {
this.range = range;
}
}

View file

@ -24,12 +24,10 @@ import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.Utilities.ClickType;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
import com.projectkorra.ProjectKorra.airbending.AirMethods;
import com.projectkorra.ProjectKorra.chiblocking.ChiMethods;
import com.projectkorra.ProjectKorra.chiblocking.Paralyze;
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
import com.projectkorra.ProjectKorra.configuration.ConfigLoadable;
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
public class FireCombo {
public class FireCombo implements ConfigLoadable {
public static final List<String> abilitiesToBlock = new ArrayList<String>() {
private static final long serialVersionUID = 5395690551860441647L;
{
@ -45,46 +43,46 @@ public class FireCombo {
add("AirSweep");
}
};
private static boolean enabled = ProjectKorra.plugin.getConfig()
private static boolean enabled = config.get()
.getBoolean("Abilities.Fire.FireCombo.Enabled");
private static final double FIRE_WHEEL_STARTING_HEIGHT = 2;
private static final double FIRE_WHEEL_RADIUS = 1;
public static double fireticksFireWheel = ProjectKorra.plugin.getConfig()
public static double fireticksFireWheel = config.get()
.getDouble("Abilities.Fire.FireCombo.FireWheel.FireTicks");
public static double fireticksJetBlaze = ProjectKorra.plugin.getConfig()
public static double fireticksJetBlaze = config.get()
.getDouble("Abilities.Fire.FireCombo.JetBlaze.FireTicks");
public static double FIRE_KICK_RANGE = ProjectKorra.plugin.getConfig()
public static double FIRE_KICK_RANGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireKick.Range");
public static double FIRE_KICK_DAMAGE = ProjectKorra.plugin.getConfig()
public static double FIRE_KICK_DAMAGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireKick.Damage");
public static double FIRE_SPIN_RANGE = ProjectKorra.plugin.getConfig()
public static double FIRE_SPIN_RANGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireSpin.Range");
public static double FIRE_SPIN_DAMAGE = ProjectKorra.plugin.getConfig()
public static double FIRE_SPIN_DAMAGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireSpin.Damage");
public static double FIRE_SPIN_KNOCKBACK = ProjectKorra.plugin.getConfig()
public static double FIRE_SPIN_KNOCKBACK = config.get()
.getDouble("Abilities.Fire.FireCombo.FireSpin.Knockback");
public static double FIRE_WHEEL_DAMAGE = ProjectKorra.plugin.getConfig()
public static double FIRE_WHEEL_DAMAGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireWheel.Damage");
public static double FIRE_WHEEL_RANGE = ProjectKorra.plugin.getConfig()
public static double FIRE_WHEEL_RANGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireWheel.Range");
public static double FIRE_WHEEL_SPEED = ProjectKorra.plugin.getConfig()
public static double FIRE_WHEEL_SPEED = config.get()
.getDouble("Abilities.Fire.FireCombo.FireWheel.Speed");
public static double JET_BLAST_SPEED = ProjectKorra.plugin.getConfig()
public static double JET_BLAST_SPEED = config.get()
.getDouble("Abilities.Fire.FireCombo.JetBlast.Speed");
public static double JET_BLAZE_SPEED = ProjectKorra.plugin.getConfig()
public static double JET_BLAZE_SPEED = config.get()
.getDouble("Abilities.Fire.FireCombo.JetBlaze.Speed");
public static double JET_BLAZE_DAMAGE = ProjectKorra.plugin.getConfig()
public static double JET_BLAZE_DAMAGE = config.get()
.getDouble("Abilities.Fire.FireCombo.JetBlaze.Damage");
public static long FIRE_KICK_COOLDOWN = ProjectKorra.plugin.getConfig()
public static long FIRE_KICK_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.FireKick.Cooldown");
public static long FIRE_SPIN_COOLDOWN = ProjectKorra.plugin.getConfig()
public static long FIRE_SPIN_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.FireSpin.Cooldown");
public static long FIRE_WHEEL_COOLDOWN = ProjectKorra.plugin.getConfig()
public static long FIRE_WHEEL_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.FireWheel.Cooldown");
public static long JET_BLAST_COOLDOWN = ProjectKorra.plugin.getConfig()
public static long JET_BLAST_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.JetBlast.Cooldown");
public static long JET_BLAZE_COOLDOWN = ProjectKorra.plugin.getConfig()
public static long JET_BLAZE_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.JetBlaze.Cooldown");
public static ArrayList<FireCombo> instances = new ArrayList<FireCombo>();
@ -108,6 +106,7 @@ public class FireCombo {
public FireCombo(Player player, String ability) {
// Dont' call Methods.canBind directly, it doesn't let you combo as fast
/* Initial Checks */
if (!enabled)
return;
if(!GeneralMethods.getBendingPlayer(player.getName()).hasElement(Element.Fire))
@ -119,15 +118,16 @@ public class FireCombo {
return;
if (!GeneralMethods.getBendingPlayer(player.getName()).isToggled())
return;
if (GeneralMethods.canBend(player.getDisplayName(), ability)) {
return;
}
/* End Initial Checks */
reloadVariables();
time = System.currentTimeMillis();
this.player = player;
this.ability = ability;
this.bplayer = GeneralMethods.getBendingPlayer(player.getName());
if (GeneralMethods.canBend(player.getDisplayName(), ability)) {
return;
}
if (ability.equalsIgnoreCase("FireKick")) {
damage = FIRE_KICK_DAMAGE;
range = FIRE_KICK_RANGE;
@ -159,6 +159,131 @@ public class FireCombo {
instances.add(this);
}
/**
* Returns all the FireCombos created by a specific player.
*/
public static ArrayList<FireCombo> getFireCombo(Player player) {
ArrayList<FireCombo> list = new ArrayList<FireCombo>();
for (FireCombo lf : instances)
if (lf.player != null && lf.player == player)
list.add(lf);
return list;
}
/**
* Returns all of the FireCombos created by a specific player but
* filters the abilities based on shift or click.
*/
public static ArrayList<FireCombo> getFireCombo(Player player,
ClickType type) {
ArrayList<FireCombo> list = new ArrayList<FireCombo>();
for (FireCombo lf : instances)
if (lf.player != null && lf.player == player && lf.type != null
&& lf.type == type)
list.add(lf);
return list;
}
public static void progressAll() {
for (int i = instances.size() - 1; i >= 0; i--)
instances.get(i).progress();
}
public static void removeAll() {
for (int i = instances.size() - 1; i >= 0; i--) {
instances.get(i).remove();
}
}
public static boolean removeAroundPoint(Player player, String ability,
Location loc, double radius) {
boolean removed = false;
for (int i = 0; i < instances.size(); i++) {
FireCombo combo = instances.get(i);
if (combo.getPlayer().equals(player))
continue;
if (ability.equalsIgnoreCase("FireKick")
&& combo.ability.equalsIgnoreCase("FireKick")) {
for (FireComboStream fs : combo.tasks) {
if (fs.getLocation() != null && fs.getLocation().getWorld() == loc.getWorld()
&& Math.abs(fs.getLocation().distance(loc)) <= radius) {
fs.remove();
removed = true;
}
}
}
else if (ability.equalsIgnoreCase("FireSpin")
&& combo.ability.equalsIgnoreCase("FireSpin")) {
for (FireComboStream fs : combo.tasks) {
if (fs.getLocation() != null
&& fs.getLocation().getWorld().equals(loc.getWorld())) {
if (Math.abs(fs.getLocation().distance(loc)) <= radius) {
fs.remove();
removed = true;
}
}
}
}
else if (ability.equalsIgnoreCase("FireWheel")
&& combo.ability.equalsIgnoreCase("FireWheel")) {
if (combo.currentLoc != null
&& Math.abs(combo.currentLoc.distance(loc)) <= radius) {
instances.remove(combo);
removed = true;
}
}
}
return removed;
}
public void checkSafeZone() {
if (currentLoc != null
&& GeneralMethods.isRegionProtectedFromBuild(player, "Blaze",
currentLoc))
remove();
}
public void collision(LivingEntity entity, Vector direction,
FireComboStream fstream) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze",
entity.getLocation()))
return;
entity.getLocation()
.getWorld()
.playSound(entity.getLocation(), Sound.VILLAGER_HIT, 0.3f, 0.3f);
if (ability.equalsIgnoreCase("FireKick")) {
GeneralMethods.damageEntity(player, entity, damage);
fstream.remove();
} else if (ability.equalsIgnoreCase("FireSpin")) {
double knockback = AvatarState.isAvatarState(player) ? FIRE_SPIN_KNOCKBACK + 0.5
: FIRE_SPIN_KNOCKBACK;
GeneralMethods.damageEntity(player, entity, damage);
entity.setVelocity(direction.normalize().multiply(knockback));
fstream.remove();
} else if (ability.equalsIgnoreCase("JetBlaze")) {
if (!affectedEntities.contains(entity)) {
affectedEntities.add(entity);
GeneralMethods.damageEntity(player, entity, damage);
entity.setFireTicks((int) (fireticksJetBlaze * 20));
}
} else if (ability.equalsIgnoreCase("FireWheel")) {
if (!affectedEntities.contains(entity)) {
affectedEntities.add(entity);
GeneralMethods.damageEntity(player, entity, damage);
entity.setFireTicks((int) (fireticksFireWheel * 20));
this.remove();
}
}
}
public Player getPlayer() {
return player;
}
public void progress() {
progressCounter++;
for (int i = 0; i < tasks.size(); i++) {
@ -259,7 +384,7 @@ public class FireCombo {
if (System.currentTimeMillis() - time > 5000) {
remove();
return;
} else if (FireJet.instances.containsKey(player)) {
} else if (FireJet.checkTemporaryImmunity(player)) {
if (firstTime) {
if (bplayer.isOnCooldown("JetBlast")
&& !AvatarState.isAvatarState(player)) {
@ -301,7 +426,7 @@ public class FireCombo {
} else if (System.currentTimeMillis() - time > 5000) {
remove();
return;
} else if (FireJet.instances.containsKey(player)) {
} else if (FireJet.checkTemporaryImmunity(player)) {
direction = player.getVelocity().clone().multiply(-1);
player.setVelocity(player.getVelocity().normalize()
.multiply(speed));
@ -389,141 +514,59 @@ public class FireCombo {
checkSafeZone();
}
public void checkSafeZone() {
if (currentLoc != null
&& GeneralMethods.isRegionProtectedFromBuild(player, "Blaze",
currentLoc))
remove();
}
public void collision(LivingEntity entity, Vector direction,
FireComboStream fstream) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze",
entity.getLocation()))
return;
entity.getLocation()
.getWorld()
.playSound(entity.getLocation(), Sound.VILLAGER_HIT, 0.3f, 0.3f);
if (ability.equalsIgnoreCase("FireKick")) {
GeneralMethods.damageEntity(player, entity, damage);
fstream.remove();
} else if (ability.equalsIgnoreCase("FireSpin")) {
double knockback = AvatarState.isAvatarState(player) ? FIRE_SPIN_KNOCKBACK + 0.5
: FIRE_SPIN_KNOCKBACK;
GeneralMethods.damageEntity(player, entity, damage);
entity.setVelocity(direction.normalize().multiply(knockback));
fstream.remove();
} else if (ability.equalsIgnoreCase("JetBlaze")) {
if (!affectedEntities.contains(entity)) {
affectedEntities.add(entity);
GeneralMethods.damageEntity(player, entity, damage);
entity.setFireTicks((int) (fireticksJetBlaze * 20));
}
} else if (ability.equalsIgnoreCase("FireWheel")) {
if (!affectedEntities.contains(entity)) {
affectedEntities.add(entity);
GeneralMethods.damageEntity(player, entity, damage);
entity.setFireTicks((int) (fireticksFireWheel * 20));
this.remove();
}
}
@Override
public void reloadVariables() {
enabled = config.get()
.getBoolean("Abilities.Fire.FireCombo.Enabled");
fireticksFireWheel = config.get()
.getDouble("Abilities.Fire.FireCombo.FireWheel.FireTicks");
fireticksJetBlaze = config.get()
.getDouble("Abilities.Fire.FireCombo.JetBlaze.FireTicks");
FIRE_KICK_RANGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireKick.Range");
FIRE_KICK_DAMAGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireKick.Damage");
FIRE_SPIN_RANGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireSpin.Range");
FIRE_SPIN_DAMAGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireSpin.Damage");
FIRE_SPIN_KNOCKBACK = config.get()
.getDouble("Abilities.Fire.FireCombo.FireSpin.Knockback");
FIRE_WHEEL_DAMAGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireWheel.Damage");
FIRE_WHEEL_RANGE = config.get()
.getDouble("Abilities.Fire.FireCombo.FireWheel.Range");
FIRE_WHEEL_SPEED = config.get()
.getDouble("Abilities.Fire.FireCombo.FireWheel.Speed");
JET_BLAST_SPEED = config.get()
.getDouble("Abilities.Fire.FireCombo.JetBlast.Speed");
JET_BLAZE_SPEED = config.get()
.getDouble("Abilities.Fire.FireCombo.JetBlaze.Speed");
JET_BLAZE_DAMAGE = config.get()
.getDouble("Abilities.Fire.FireCombo.JetBlaze.Damage");
FIRE_KICK_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.FireKick.Cooldown");
FIRE_SPIN_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.FireSpin.Cooldown");
FIRE_WHEEL_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.FireWheel.Cooldown");
JET_BLAST_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.JetBlast.Cooldown");
JET_BLAZE_COOLDOWN = config.get()
.getLong("Abilities.Fire.FireCombo.JetBlaze.Cooldown");
}
/**
* Removes this instance of FireCombo, cleans up any blocks that are
* remaining in totalBlocks, and cancels any remaining tasks.
*/
public void remove() {
/**
* Removes this instance of FireCombo, cleans up any blocks that are
* remaining in totalBlocks, and cancels any remaining tasks.
*/
instances.remove(this);
for (BukkitRunnable task : tasks)
task.cancel();
}
public static void progressAll() {
for (int i = instances.size() - 1; i >= 0; i--)
instances.get(i).progress();
}
public static void removeAll() {
for (int i = instances.size() - 1; i >= 0; i--) {
instances.get(i).remove();
}
}
public Player getPlayer() {
return player;
}
public static ArrayList<FireCombo> getFireCombo(Player player) {
/**
* Returns all the FireCombos created by a specific player.
*/
ArrayList<FireCombo> list = new ArrayList<FireCombo>();
for (FireCombo lf : instances)
if (lf.player != null && lf.player == player)
list.add(lf);
return list;
}
public static ArrayList<FireCombo> getFireCombo(Player player,
ClickType type) {
/**
* Returns all of the FireCombos created by a specific player but
* filters the abilities based on shift or click.
*/
ArrayList<FireCombo> list = new ArrayList<FireCombo>();
for (FireCombo lf : instances)
if (lf.player != null && lf.player == player && lf.type != null
&& lf.type == type)
list.add(lf);
return list;
}
public static boolean removeAroundPoint(Player player, String ability,
Location loc, double radius) {
boolean removed = false;
for (int i = 0; i < instances.size(); i++) {
FireCombo combo = instances.get(i);
if (combo.getPlayer().equals(player))
continue;
if (ability.equalsIgnoreCase("FireKick")
&& combo.ability.equalsIgnoreCase("FireKick")) {
for (FireComboStream fs : combo.tasks) {
if (fs.getLocation() != null && fs.getLocation().getWorld() == loc.getWorld()
&& Math.abs(fs.getLocation().distance(loc)) <= radius) {
fs.remove();
removed = true;
}
}
}
else if (ability.equalsIgnoreCase("FireSpin")
&& combo.ability.equalsIgnoreCase("FireSpin")) {
for (FireComboStream fs : combo.tasks) {
if (fs.getLocation() != null
&& fs.getLocation().getWorld().equals(loc.getWorld())) {
if (Math.abs(fs.getLocation().distance(loc)) <= radius) {
fs.remove();
removed = true;
}
}
}
}
else if (ability.equalsIgnoreCase("FireWheel")
&& combo.ability.equalsIgnoreCase("FireWheel")) {
if (combo.currentLoc != null
&& Math.abs(combo.currentLoc.distance(loc)) <= radius) {
instances.remove(combo);
removed = true;
}
}
}
return removed;
}
public static class FireComboStream extends BukkitRunnable {
private Vector direction;
private double speed;
@ -552,6 +595,27 @@ public class FireCombo {
this.distance = distance;
}
public void cancel() {
remove();
}
public Vector getDirection() {
return this.direction.clone();
}
public Location getLocation() {
return this.currentLoc;
}
public boolean isCancelled() {
return cancelled;
}
public void remove() {
super.cancel();
this.cancelled = true;
}
public void run() {
Block block = currentLoc.getBlock();
if (block.getRelative(BlockFace.UP).getType() != Material.AIR
@ -587,41 +651,8 @@ public class FireCombo {
remove();
}
public void cancel() {
remove();
}
public void remove() {
super.cancel();
this.cancelled = true;
}
public Location getLocation() {
return this.currentLoc;
}
public Vector getDirection() {
return this.direction.clone();
}
public void setSpread(float spread) {
this.spread = spread;
}
public void setUseNewParticles(boolean b) {
useNewParticles = b;
}
public void setDensity(int density) {
this.density = density;
}
public boolean isCancelled() {
return cancelled;
}
public void setParticleEffect(ParticleEffect effect) {
this.particleEffect = effect;
public void setCheckCollisionDelay(int delay) {
this.checkCollisionDelay = delay;
}
public void setCollides(boolean b) {
@ -632,12 +663,24 @@ public class FireCombo {
this.collisionRadius = radius;
}
public void setDensity(int density) {
this.density = density;
}
public void setParticleEffect(ParticleEffect effect) {
this.particleEffect = effect;
}
public void setSinglePoint(boolean b) {
this.singlePoint = b;
}
public void setCheckCollisionDelay(int delay) {
this.checkCollisionDelay = delay;
public void setSpread(float spread) {
this.spread = spread;
}
public void setUseNewParticles(boolean b) {
useNewParticles = b;
}
}

View file

@ -1,7 +1,6 @@
package com.projectkorra.ProjectKorra.firebending;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -11,19 +10,17 @@ import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.BendingPlayer;
import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
public class FireJet extends CoreAbility {
public class FireJet {
public static ConcurrentHashMap<Player, FireJet> instances = new ConcurrentHashMap<Player, FireJet>();
private static final double defaultfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireJet.Speed");
private static final long defaultduration = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireJet.Duration");
private static boolean isToggle = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire.FireJet.IsAvatarStateToggle");
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");
private Player player;
private long time;
@ -31,17 +28,19 @@ public class FireJet {
private double factor = defaultfactor;
public FireJet(Player player) {
if (instances.containsKey(player)) {
instances.remove(player);
/* Initial Checks */
if (containsPlayer(player, FireJet.class)) {
remove();
return;
}
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("FireJet")) return;
/* End Initial Checks */
reloadVariables();
factor = FireMethods.getFirebendingDayAugment(defaultfactor, player.getWorld());
Block block = player.getLocation().getBlock();
if (FireStream.isIgnitable(player, block) || block.getType() == Material.AIR || AvatarState.isAvatarState(player)) {
if (FireStream.isIgnitable(player, block) || block.getType() == Material.AIR || AvatarState.isAvatarState(player)) {
player.setVelocity(player.getEyeLocation().getDirection().clone().normalize().multiply(factor));
block.setType(Material.FIRE);
this.player = player;
@ -50,29 +49,31 @@ public class FireJet {
player.setAllowFlight(true);
time = System.currentTimeMillis();
// timers.put(player, time);
instances.put(player, this);
bPlayer.addCooldown("FireJet", ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireJet.Cooldown"));
//instances.put(player, this);
putInstance(player, this);
bPlayer.addCooldown("FireJet", config.get().getLong("Abilities.Fire.FireJet.Cooldown"));
}
}
public static boolean checkTemporaryImmunity(Player player) {
if (instances.containsKey(player)) {
if (containsPlayer(player, FireJet.class)) {
return true;
}
return false;
}
public void progress() {
@Override
public boolean progress() {
if (player.isDead() || !player.isOnline()) {
// player.setAllowFlight(canfly);
instances.remove(player);
return;
remove();
return false;
}
if ((WaterMethods.isWater(player.getLocation().getBlock()) || System.currentTimeMillis() > time + duration)
&& (!AvatarState.isAvatarState(player) || !isToggle)) {
// player.setAllowFlight(canfly);
instances.remove(player);
remove();
} else {
if (GeneralMethods.rand.nextInt(2) == 0) {
FireMethods.playFirebendingSound(player.getLocation());
@ -92,18 +93,13 @@ public class FireJet {
player.setVelocity(velocity);
player.setFallDistance(0);
}
}
public static void progressAll() {
for (Player player : instances.keySet()) {
instances.get(player).progress();
}
return true;
}
public static ArrayList<Player> getPlayers() {
ArrayList<Player> players = new ArrayList<Player>();
for (Player player : instances.keySet()) {
players.add(player);
for (Integer id : getInstances(StockAbilities.FireJet).keySet()) {
players.add(getInstances(StockAbilities.FireJet).get(id).getPlayer());
}
return players;
}
@ -128,4 +124,16 @@ public class FireJet {
this.factor = factor;
}
@Override
public void reloadVariables() {
defaultfactor = config.get().getDouble("Abilities.Fire.FireJet.Speed");
defaultduration = config.get().getLong("Abilities.Fire.FireJet.Duration");
isToggle = config.get().getBoolean("Abilities.Fire.FireJet.IsAvatarStateToggle");
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.FireJet;
}
}

View file

@ -136,12 +136,12 @@ public class FireMethods {
public static void stopBending() {
FireStream.removeAll();
Fireball.removeAll();
WallOfFire.instances.clear();
Lightning.instances.clear();
WallOfFire.removeAll();
Lightning.removeAll();
FireShield.removeAll();
FireBlast.removeAll();
FireBurst.removeAll();
FireJet.instances.clear();
FireJet.removeAll();
Cook.removeAll();
Illumination.removeAll();
FireCombo.removeAll();

View file

@ -1,7 +1,6 @@
package com.projectkorra.ProjectKorra.firebending;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -13,20 +12,19 @@ import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.BendingPlayer;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
public class FireShield {
public static ConcurrentHashMap<Player, FireShield> instances = new ConcurrentHashMap<Player, FireShield>();
public class FireShield extends CoreAbility {
private static long interval = 100;
private static long DURATION = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireShield.Duration");
private static double RADIUS = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireShield.Radius");
private static double DISC_RADIUS = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireShield.DiscRadius");
private static double fireticks = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireShield.FireTicks");
private static long DURATION = config.get().getLong("Abilities.Fire.FireShield.Duration");
private static double RADIUS = config.get().getDouble("Abilities.Fire.FireShield.Radius");
private static double DISC_RADIUS = config.get().getDouble("Abilities.Fire.FireShield.DiscRadius");
private static double fireticks = config.get().getDouble("Abilities.Fire.FireShield.FireTicks");
private static boolean ignite = true;
private Player player;
@ -42,45 +40,100 @@ public class FireShield {
}
public FireShield(Player player, boolean shield) {
this.player = player;
this.shield = shield;
if (instances.containsKey(player))
/* Initial Checks */
if (containsPlayer(player, FireShield.class))
return;
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("FireShield")) return;
/* End Initial Checks */
reloadVariables();
this.player = player;
this.shield = shield;
if (!player.getEyeLocation().getBlock().isLiquid()) {
time = System.currentTimeMillis();
starttime = time;
instances.put(player, this);
//instances.put(player, this);
putInstance(player, this);
if (!shield)
bPlayer.addCooldown("FireShield", GeneralMethods.getGlobalCooldown());
}
}
public static String getDescription() {
return "FireShield is a basic defensive ability. "
+ "Clicking with this ability selected will create a "
+ "small disc of fire in front of you, which will block most "
+ "attacks and bending. Alternatively, pressing and holding "
+ "sneak creates a very small shield of fire, blocking most attacks. "
+ "Creatures that contact this fire are ignited.";
}
public static boolean isWithinShield(Location loc) {
for (Integer id : getInstances(StockAbilities.FireShield).keySet()){
FireShield fshield = (FireShield) getInstances(StockAbilities.FireShield).get(id);
Location playerLoc = fshield.player.getLocation();
if(fshield.shield) {
if (!playerLoc.getWorld().equals(loc.getWorld()))
return false;
if(playerLoc.distance(loc) <= fshield.radius)
return true;
} else {
Location tempLoc = playerLoc.clone().add(playerLoc.multiply(fshield.discradius));
if (!tempLoc.getWorld().equals(loc.getWorld()))
return false;
if(tempLoc.distance(loc) <= fshield.discradius)
return true;
}
}
return false;
}
public static void shield(Player player) {
new FireShield(player, true);
}
private void remove() {
instances.remove(player);
public double getDiscradius() {
return discradius;
}
private void progress() {
public long getDuration() {
return duration;
}
public Player getPlayer() {
return player;
}
public double getRadius() {
return radius;
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.FireShield;
}
public boolean isShield() {
return shield;
}
@Override
public boolean progress() {
if (((!player.isSneaking()) && shield) || !GeneralMethods.canBend(player.getName(), "FireShield")) {
remove();
return;
return false;
}
if (!player.isOnline() || player.isDead()) {
remove();
return;
return false;
}
if (System.currentTimeMillis() > starttime + duration && !shield) {
remove();
return;
return false;
}
if (System.currentTimeMillis() > time + interval) {
@ -129,7 +182,6 @@ public class FireShield {
// FireStream.removeAroundPoint(location, radius);
} else {
ArrayList<Block> blocks = new ArrayList<Block>();
Location location = player.getEyeLocation().clone();
Vector direction = location.getDirection();
@ -137,7 +189,7 @@ public class FireShield {
if (GeneralMethods.isRegionProtectedFromBuild(player, "FireShield", location)) {
remove();
return;
return false;
}
for (double theta = 0; theta < 360; theta += 20) {
@ -179,80 +231,33 @@ public class FireShield {
}
}
}
return true;
}
public static boolean isWithinShield(Location loc) {
for (Player player : instances.keySet()){
FireShield fshield = instances.get(player);
Location playerLoc = fshield.player.getLocation();
if(fshield.shield) {
if (!playerLoc.getWorld().equals(loc.getWorld()))
return false;
if(playerLoc.distance(loc) <= fshield.radius)
return true;
} else {
Location tempLoc = playerLoc.clone().add(playerLoc.multiply(fshield.discradius));
if (!tempLoc.getWorld().equals(loc.getWorld()))
return false;
if(tempLoc.distance(loc) <= fshield.discradius)
return true;
}
}
return false;
@Override
public void reloadVariables() {
DURATION = config.get().getLong("Abilities.Fire.FireShield.Duration");
RADIUS = config.get().getDouble("Abilities.Fire.FireShield.Radius");
DISC_RADIUS = config.get().getDouble("Abilities.Fire.FireShield.DiscRadius");
fireticks = config.get().getDouble("Abilities.Fire.FireShield.FireTicks");
duration = DURATION;
radius = RADIUS;
discradius = DISC_RADIUS;
}
public static void progressAll() {
for (Player player : instances.keySet())
instances.get(player).progress();
}
public static String getDescription() {
return "FireShield is a basic defensive ability. "
+ "Clicking with this ability selected will create a "
+ "small disc of fire in front of you, which will block most "
+ "attacks and bending. Alternatively, pressing and holding "
+ "sneak creates a very small shield of fire, blocking most attacks. "
+ "Creatures that contact this fire are ignited.";
}
public static void removeAll() {
instances.clear();
}
public Player getPlayer() {
return player;
}
public boolean isShield() {
return shield;
}
public void setShield(boolean shield) {
this.shield = shield;
}
public long getDuration() {
return duration;
public void setDiscradius(double discradius) {
this.discradius = discradius;
}
public void setDuration(long duration) {
this.duration = duration;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double getDiscradius() {
return discradius;
}
public void setDiscradius(double discradius) {
this.discradius = discradius;
public void setShield(boolean shield) {
this.shield = shield;
}
}

View file

@ -11,23 +11,21 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AddonAbility;
import com.projectkorra.ProjectKorra.waterbending.Plantbending;
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
public class FireStream {
public class FireStream extends AddonAbility {
public static ConcurrentHashMap<Integer, FireStream> instances = new ConcurrentHashMap<Integer, FireStream>();
public static ConcurrentHashMap<Block, Player> ignitedblocks = new ConcurrentHashMap<Block, Player>();
public static ConcurrentHashMap<Block, Long> ignitedtimes = new ConcurrentHashMap<Block, Long>();
public static ConcurrentHashMap<LivingEntity, Player> ignitedentities = new ConcurrentHashMap<LivingEntity, Player>();
static final long soonesttime = ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown");
static long soonesttime = config.get().getLong("Properties.GlobalCooldown");
public static int firedamage = 3;
public static int tickdamage = 2;
private static int ID = Integer.MIN_VALUE;
private static double speed = 15;
private static long interval = (long) (1000. / speed);
private static long dissipateAfter = 400;
@ -36,7 +34,6 @@ public class FireStream {
private Location origin;
private Location location;
private Vector direction;
private int id;
private long time;
private double range;
@ -49,58 +46,28 @@ public class FireStream {
this.direction.setY(0);
this.direction = this.direction.clone().normalize();
this.location = this.location.clone().add(this.direction);
id = ID;
if (ID >= Integer.MAX_VALUE) {
ID = Integer.MIN_VALUE;
}
ID++;
time = System.currentTimeMillis();
instances.put(id, this);
//instances.put(id, this);
putInstance(player, this);
}
public static void progressAll() {
for (int ID : instances.keySet()) {
instances.get(ID).progress();
}
}
private boolean progress() {
if (System.currentTimeMillis() - time >= interval) {
location = location.clone().add(direction);
time = System.currentTimeMillis();
if (location.distance(origin) > range) {
remove();
return false;
public static void dissipateAll() {
if (dissipateAfter != 0)
for (Block block : ignitedtimes.keySet()) {
if (block.getType() != Material.FIRE) {
remove(block);
} else {
long time = ignitedtimes.get(block);
if (System.currentTimeMillis() > time + dissipateAfter) {
block.setType(Material.AIR);
remove(block);
}
}
}
Block block = location.getBlock();
if (isIgnitable(player, block)) {
ignite(block);
return true;
} else if (isIgnitable(player, block.getRelative(BlockFace.DOWN))) {
ignite(block.getRelative(BlockFace.DOWN));
location = block.getRelative(BlockFace.DOWN).getLocation();
return true;
} else if (isIgnitable(player, block.getRelative(BlockFace.UP))) {
ignite(block.getRelative(BlockFace.UP));
location = block.getRelative(BlockFace.UP).getLocation();
return true;
} else {
remove();
return false;
}
}
return false;
}
private void ignite(Block block) {
if (WaterMethods.isPlant(block)) {
new Plantbending(block);
}
block.setType(Material.FIRE);
ignitedblocks.put(block, this.player);
ignitedtimes.put(block, System.currentTimeMillis());
public static String getDescription() {
return "This ability no longer exists.";
}
public static boolean isIgnitable(Player player, Block block) {
@ -148,38 +115,6 @@ public class FireStream {
return false;
}
private void remove() {
instances.remove(id);
}
public static void removeAll() {
for (Block block : ignitedblocks.keySet())
remove(block);
}
public static void dissipateAll() {
if (dissipateAfter != 0)
for (Block block : ignitedtimes.keySet()) {
if (block.getType() != Material.FIRE) {
remove(block);
} else {
long time = ignitedtimes.get(block);
if (System.currentTimeMillis() > time + dissipateAfter) {
block.setType(Material.AIR);
remove(block);
}
}
}
}
public static boolean progress(int ID) {
return instances.get(ID).progress();
}
public static String getDescription() {
return "This ability no longer exists.";
}
public static void remove(Block block) {
if (ignitedblocks.containsKey(block)) {
ignitedblocks.remove(block);
@ -187,20 +122,29 @@ public class FireStream {
if (ignitedtimes.containsKey(block)) {
ignitedtimes.remove(block);
}
}
public static void removeAll() {
for (Block block : ignitedblocks.keySet())
remove(block);
AddonAbility.removeAll();
}
public static void removeAroundPoint(Location location, double radius) {
for (int id : instances.keySet()) {
FireStream stream = instances.get(id);
for (int id : getInstances(FireStream.class).keySet()) {
FireStream stream = (FireStream) getInstances(FireStream.class).get(id);
if (stream.location.getWorld().equals(location.getWorld()))
if (stream.location.distance(location) <= radius)
instances.remove(id);
stream.remove();
}
}
@Override
public InstanceType getInstanceType() {
return InstanceType.MULTIPLE;
}
public Player getPlayer() {
return player;
}
@ -209,6 +153,51 @@ public class FireStream {
return range;
}
private void ignite(Block block) {
if (WaterMethods.isPlant(block)) {
new Plantbending(block);
}
block.setType(Material.FIRE);
ignitedblocks.put(block, this.player);
ignitedtimes.put(block, System.currentTimeMillis());
}
@Override
public boolean progress() {
if (System.currentTimeMillis() - time >= interval) {
location = location.clone().add(direction);
time = System.currentTimeMillis();
if (location.distance(origin) > range) {
remove();
return false;
}
Block block = location.getBlock();
if (isIgnitable(player, block)) {
ignite(block);
return true;
} else if (isIgnitable(player, block.getRelative(BlockFace.DOWN))) {
ignite(block.getRelative(BlockFace.DOWN));
location = block.getRelative(BlockFace.DOWN).getLocation();
return true;
} else if (isIgnitable(player, block.getRelative(BlockFace.UP))) {
ignite(block.getRelative(BlockFace.UP));
location = block.getRelative(BlockFace.UP).getLocation();
return true;
} else {
remove();
return false;
}
}
return false;
}
@Override
public void reloadVariables() {
soonesttime = config.get().getLong("Properties.GlobalCooldown");
}
public void setRange(double range) {
this.range = range;
}

View file

@ -13,28 +13,28 @@ import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AddonAbility;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
import com.projectkorra.ProjectKorra.airbending.AirMethods;
public class Fireball {
/**
* Ability charged FireBlast
*/
public class Fireball extends AddonAbility {
public static ConcurrentHashMap<Integer, Fireball> instances = new ConcurrentHashMap<Integer, Fireball>();
private static ConcurrentHashMap<Entity, Fireball> explosions = new ConcurrentHashMap<Entity, Fireball>();
private static long defaultchargetime = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBlast.Charged.ChargeTime");
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 ID = Integer.MIN_VALUE;
private static double MAX_DAMAGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.Damage");
private static double DAMAGE_RADIUS = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.DamageRadius");
private static double RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.Range");
private static double POWER = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.Power");
private static double fireticks = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.FireTicks");
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");
private static double RANGE = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Range");
private static double POWER = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Power");
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 explosionradius = DAMAGE_RADIUS;
@ -47,16 +47,17 @@ public class Fireball {
private boolean launched = false;
private Player player;
private Location origin;
public Location location;
private Location location;
private Vector direction;
private TNTPrimed explosion = null;
public Fireball(Player player) {
reloadVariables();
this.player = player;
time = System.currentTimeMillis();
starttime = time;
if (FireMethods.isDay(player.getWorld())) {
chargetime = (long) (chargetime / ProjectKorra.plugin.getConfig().getDouble("Properties.Fire.DayFactor"));
chargetime = (long) (chargetime / config.get().getDouble("Properties.Fire.DayFactor"));
}
if (AvatarState.isAvatarState(player)) {
chargetime = 0;
@ -64,83 +65,29 @@ public class Fireball {
}
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
if (!player.getEyeLocation().getBlock().isLiquid()) {
id = ID;
instances.put(id, this);
if (ID == Integer.MAX_VALUE)
ID = Integer.MIN_VALUE;
ID++;
//instances.put(id, this);
putInstance(player, this);
}
}
private void progress() {
if (GeneralMethods.getBoundAbility(player) == null) {
remove();
return;
}
if (!GeneralMethods.canBend(player.getName(), "FireBlast") && !launched) {
remove();
return;
}
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") && !launched) {
remove();
return;
}
if (System.currentTimeMillis() > starttime + chargetime) {
charged = true;
}
if (!player.isSneaking() && !charged) {
new FireBlast(player);
remove();
return;
}
if (!player.isSneaking() && !launched) {
launched = true;
location = player.getEyeLocation();
origin = location.clone();
direction = location.getDirection().normalize().multiply(radius);
}
if (System.currentTimeMillis() > time + interval) {
if (launched) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze", location)) {
remove();
return;
public static boolean annihilateBlasts(Location location, double radius, Player source) {
boolean broke = false;
for (Integer id : getInstances(Fireball.class).keySet()) {
Fireball fireball = (Fireball) getInstances(Fireball.class).get(id);
if (!fireball.launched)
continue;
Location fireblastlocation = fireball.location;
if (location.getWorld() == fireblastlocation.getWorld()
&& !source.equals(fireball.player)) {
if (location.distance(fireblastlocation) <= radius) {
fireball.explode();
broke = true;
}
}
time = System.currentTimeMillis();
if (!launched && !charged)
return;
if (!launched) {
player.getWorld().playEffect(player.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 0, 3);
return;
}
location = location.clone().add(direction);
if (location.distance(origin) > range) {
remove();
return;
}
if (GeneralMethods.isSolid(location.getBlock())) {
explode();
return;
} else if (location.getBlock().isLiquid()) {
remove();
return;
}
fireball();
}
return broke;
}
public static Fireball getFireball(Entity entity) {
@ -149,6 +96,29 @@ public class Fireball {
return null;
}
public static boolean isCharging(Player player) {
for (Integer id : getInstances(Fireball.class).keySet()) {
Fireball fireball = (Fireball) getInstances(Fireball.class).get(id);
if (fireball.player == player && !fireball.launched)
return true;
}
return false;
}
public static void removeFireballsAroundPoint(Location location, double radius) {
for (Integer id : getInstances(Fireball.class).keySet()) {
Fireball fireball = (Fireball) getInstances(Fireball.class).get(id);
if (!fireball.launched)
continue;
Location fireblastlocation = fireball.location;
if (location.getWorld() == fireblastlocation.getWorld()) {
if (location.distance(fireblastlocation) <= radius)
fireball.remove();
}
}
}
public void dealDamage(Entity entity) {
if (explosion == null)
return;
@ -170,37 +140,6 @@ public class Fireball {
AirMethods.breakBreathbendingHold(entity);
}
private void fireball() {
for (Block block : GeneralMethods.getBlocksAroundPoint(location, radius)) {
ParticleEffect.FLAME.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 17);
ParticleEffect.SMOKE.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 17);
if (GeneralMethods.rand.nextInt(4) == 0) {
FireMethods.playFirebendingSound(location);
}
}
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2 * radius)) {
if (entity.getEntityId() == player.getEntityId())
continue;
entity.setFireTicks((int) (fireticks * 20));
if (entity instanceof LivingEntity) {
explode();
dealDamage(entity);
return;
}
}
}
public static boolean isCharging(Player player) {
for (int id : instances.keySet()) {
Fireball ball = instances.get(id);
if (ball.player == player && !ball.launched)
return true;
}
return false;
}
public void explode() {
// List<Block> blocks = Methods.getBlocksAroundPoint(location, 3);
// List<Block> blocks2 = new ArrayList<Block>();
@ -250,6 +189,61 @@ public class Fireball {
remove();
}
private void fireball() {
for (Block block : GeneralMethods.getBlocksAroundPoint(location, radius)) {
ParticleEffect.FLAME.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 17);
ParticleEffect.SMOKE.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 17);
if (GeneralMethods.rand.nextInt(4) == 0) {
FireMethods.playFirebendingSound(location);
}
}
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2 * radius)) {
if (entity.getEntityId() == player.getEntityId())
continue;
entity.setFireTicks((int) (fireticks * 20));
if (entity instanceof LivingEntity) {
explode();
dealDamage(entity);
return;
}
}
}
public long getChargetime() {
return chargetime;
}
public double getExplosionradius() {
return explosionradius;
}
public double getInnerradius() {
return innerradius;
}
@Override
public InstanceType getInstanceType() {
return InstanceType.MULTIPLE;
}
public double getMaxdamage() {
return maxdamage;
}
public Player getPlayer() {
return player;
}
public double getPower() {
return power;
}
public double getRange() {
return range;
}
private void ignite(Location location) {
for (Block block : GeneralMethods.getBlocksAroundPoint(location, FireBlast.AFFECTING_RADIUS)) {
if (FireStream.isIgnitable(player, block)) {
@ -262,103 +256,116 @@ public class Fireball {
}
}
public static void progressAll() {
for (int id : instances.keySet())
instances.get(id).progress();
}
private void remove() {
instances.remove(id);
}
public static void removeAll() {
for (int id : instances.keySet())
instances.get(id).remove();
}
public static void removeFireballsAroundPoint(Location location, double radius) {
for (int id : instances.keySet()) {
Fireball fireball = instances.get(id);
if (!fireball.launched)
continue;
Location fireblastlocation = fireball.location;
if (location.getWorld() == fireblastlocation.getWorld()) {
if (location.distance(fireblastlocation) <= radius)
instances.remove(id);
}
@Override
public boolean progress() {
if (GeneralMethods.getBoundAbility(player) == null) {
remove();
return false;
}
if (!GeneralMethods.canBend(player.getName(), "FireBlast") && !launched) {
remove();
return false;
}
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") && !launched) {
remove();
return false;
}
}
if (System.currentTimeMillis() > starttime + chargetime) {
charged = true;
}
public static boolean annihilateBlasts(Location location, double radius, Player source) {
boolean broke = false;
for (int id : instances.keySet()) {
Fireball fireball = instances.get(id);
if (!fireball.launched)
continue;
Location fireblastlocation = fireball.location;
if (location.getWorld() == fireblastlocation.getWorld()
&& !source.equals(fireball.player)) {
if (location.distance(fireblastlocation) <= radius) {
fireball.explode();
broke = true;
if (!player.isSneaking() && !charged) {
new FireBlast(player);
remove();
return false;
}
if (!player.isSneaking() && !launched) {
launched = true;
location = player.getEyeLocation();
origin = location.clone();
direction = location.getDirection().normalize().multiply(radius);
}
if (System.currentTimeMillis() > time + interval) {
if (launched) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze", location)) {
remove();
return false;
}
}
time = System.currentTimeMillis();
if (!launched && !charged)
return true;
if (!launched) {
player.getWorld().playEffect(player.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 0, 3);
return true;
}
location = location.clone().add(direction);
if (location.distance(origin) > range) {
remove();
return false;
}
if (GeneralMethods.isSolid(location.getBlock())) {
explode();
return false;
} else if (location.getBlock().isLiquid()) {
remove();
return false;
}
fireball();
}
return broke;
return true;
}
public double getMaxdamage() {
return maxdamage;
}
@Override
public void reloadVariables() {
defaultchargetime = config.get().getLong("Abilities.Fire.FireBlast.Charged.ChargeTime");
interval = 25;
radius = 1.5;
MAX_DAMAGE = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Damage");
DAMAGE_RADIUS = config.get().getDouble("Abilities.Fire.FireBlast.Charged.DamageRadius");
RANGE = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Range");
POWER = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Power");
fireticks = config.get().getDouble("Abilities.Fire.FireBlast.Charged.FireTicks");
public void setMaxdamage(double maxdamage) {
this.maxdamage = maxdamage;
}
public double getRange() {
return range;
}
public void setRange(double range) {
this.range = range;
}
public double getExplosionradius() {
return explosionradius;
}
public void setExplosionradius(double explosionradius) {
this.explosionradius = explosionradius;
}
public double getPower() {
return power;
}
public void setPower(double power) {
this.power = power;
}
public double getInnerradius() {
return innerradius;
}
public void setInnerradius(double innerradius) {
this.innerradius = innerradius;
}
public long getChargetime() {
return chargetime;
maxdamage = MAX_DAMAGE;
range = RANGE;
explosionradius = DAMAGE_RADIUS;
power = POWER;
chargetime = defaultchargetime;
}
public void setChargetime(long chargetime) {
this.chargetime = chargetime;
}
public Player getPlayer() {
return player;
public void setExplosionradius(double explosionradius) {
this.explosionradius = explosionradius;
}
public void setInnerradius(double innerradius) {
this.innerradius = innerradius;
}
public void setMaxdamage(double maxdamage) {
this.maxdamage = maxdamage;
}
public void setPower(double power) {
this.power = power;
}
public void setRange(double range) {
this.range = range;
}
}

View file

@ -1,6 +1,5 @@
package com.projectkorra.ProjectKorra.firebending;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -16,24 +15,24 @@ public class FirebendingManager implements Runnable {
public void run() {
FirePassive.handlePassive();
FireJet.progressAll();
Cook.progressAll();
Illumination.manage(Bukkit.getServer());
FireBlast.progressAll();
Fireball.progressAll();
FireBurst.progressAll();
FireShield.progressAll();
Lightning.progressAll();
WallOfFire.manage();
Combustion.progressAll();
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);
for (Block block : FireStream.ignitedblocks.keySet()) {
if (block.getType() != Material.FIRE) {
FireStream.ignitedblocks.remove(block);
}
}
HeatControl.progressAll();
HeatControl.progressAll(HeatControl.class);
FireStream.dissipateAll();
FireStream.progressAll();
FireStream.progressAll(FireStream.class);
FireCombo.progressAll();
}
}

View file

@ -2,7 +2,6 @@ package com.projectkorra.ProjectKorra.firebending;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.Material;
@ -12,24 +11,21 @@ import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.TempBlock;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
/**
* Created by Carbogen on 11/02/15.
* Ability HeatControl
*/
public class HeatControl
{
public static ConcurrentHashMap<Integer, HeatControl> instances = new ConcurrentHashMap<Integer, HeatControl>();
public final double RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.HeatControl.Solidify.Range");
public final int RADIUS = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.HeatControl.Solidify.Radius");
public final int REVERT_TIME = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.HeatControl.Solidify.RevertTime");
public static int ID = 1;
public class HeatControl extends CoreAbility {
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");
private Player player;
private int id;
private int currentRadius = 1;
private long delay = 50;
private long lastBlockTime = 0;
@ -41,33 +37,81 @@ public class HeatControl
public int radius = RADIUS;
public long revertTime = REVERT_TIME;
public HeatControl(Player player)
{
public HeatControl(Player player) {
/* Initial Checks */
if (!isEligible(player))
return;
if(EarthMethods.getLavaSourceBlock(player, getRange()) == null){
if (EarthMethods.getLavaSourceBlock(player, getRange()) == null) {
new Cook(player);
return;
}
/* End Initial Checks */
this.player = player;
if(ID == Integer.MAX_VALUE - 1)
ID = 0;
lastBlockTime = System.currentTimeMillis();
this.id = ID;
putInstance(player, this);
}
ID++;
@SuppressWarnings("deprecation")
public void freeze(List<Location> area) {
if (System.currentTimeMillis() < lastBlockTime + delay)
return;
List<Block> lava = new ArrayList<Block>();
for(Location l : area)
if(EarthMethods.isLava(l.getBlock()))
lava.add(l.getBlock());
lastBlockTime = System.currentTimeMillis();
instances.put(id, this);
if(lava.size() == 0) {
currentRadius ++;
return;
}
Block b = lava.get(GeneralMethods.rand.nextInt(lava.size()));
TempBlock tb;
if (TempBlock.isTempBlock(b)) {
tb = TempBlock.get(b);
tb.setType(Material.STONE);
}
else tb = new TempBlock(b, Material.STONE, b.getData());
if (!tblocks.contains(tb))
tblocks.add(tb);
}
public boolean isEligible(Player player){
public Player getPlayer() {
return player;
}
public int getRadius() {
return radius;
}
public double getRange() {
return range;
}
public long getRevertTime() {
return revertTime;
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.HeatControl;
}
public boolean isEligible(Player player) {
if (!GeneralMethods.canBend(player.getName(), "HeatControl"))
return false;
@ -80,84 +124,28 @@ public class HeatControl
return true;
}
@SuppressWarnings("deprecation")
public void freeze(List<Location> area)
{
if(System.currentTimeMillis() < lastBlockTime + delay)
return;
List<Block> lava = new ArrayList<Block>();
for(Location l : area)
if(EarthMethods.isLava(l.getBlock()))
lava.add(l.getBlock());
lastBlockTime = System.currentTimeMillis();
if(lava.size() == 0)
{
currentRadius ++;
return;
}
Block b = lava.get(GeneralMethods.rand.nextInt(lava.size()));
TempBlock tb;
if(TempBlock.isTempBlock(b))
{
tb = TempBlock.get(b);
tb.setType(Material.STONE);
}
else tb = new TempBlock(b, Material.STONE, b.getData());
if(!tblocks.contains(tb))
tblocks.add(tb);
}
public void particles(List<Location> area)
{
if(System.currentTimeMillis() < lastParticleTime + 300)
public void particles(List<Location> area) {
if (System.currentTimeMillis() < lastParticleTime + 300)
return;
lastParticleTime = System.currentTimeMillis();
for(Location l : area)
{
if(EarthMethods.isLava(l.getBlock()))
for (Location l : area) {
if (EarthMethods.isLava(l.getBlock()))
ParticleEffect.SMOKE.display(l, 0, 0, 0, 0.1f, 2);
}
}
public void resetLocation(Location loc)
{
if(center == null)
{
center = loc;
return;
@Override
public boolean progress() {
if (!player.isOnline() || player.isDead() || !isEligible(player) || !player.isSneaking()) {
remove();
return false;
}
if(!loc.equals(center))
{
currentRadius = 1;
center = loc;
}
}
public void progress()
{
if(!player.isOnline() || player.isDead() || !isEligible(player) || !player.isSneaking())
{
stop();
return;
}
if(currentRadius >= getRadius())
{
stop();
return;
if(currentRadius >= getRadius()) {
remove();
return false;
}
Location targetlocation = GeneralMethods.getTargetedLocation(player, range);
@ -168,72 +156,58 @@ public class HeatControl
particles(area);
freeze(area);
return true;
}
public static void progressAll()
{
for(Integer id : instances.keySet())
{
instances.get(id).progress();
}
@Override
public void reloadVariables() {
RANGE = config.get().getDouble("Abilities.Fire.HeatControl.Solidify.Range");
RADIUS = config.get().getInt("Abilities.Fire.HeatControl.Solidify.Radius");
REVERT_TIME = config.get().getInt("Abilities.Fire.HeatControl.Solidify.RevertTime");
range = RANGE;
radius = RADIUS;
revertTime = REVERT_TIME;
}
public void stop()
{
ProjectKorra.plugin.getServer().getScheduler().scheduleSyncDelayedTask(ProjectKorra.plugin, new Runnable()
{
public void run()
{
@Override
public void remove() {
final HeatControl ability = this;
ProjectKorra.plugin.getServer().getScheduler().scheduleSyncDelayedTask(ProjectKorra.plugin, new Runnable() {
public void run() {
revertAll();
if(instances.containsKey(id))
instances.remove(id);
ability.remove();
}
}, getRevertTime());
}
public void revertAll()
{
for(TempBlock tb : tblocks)
{
tb.revertBlock();
public void resetLocation(Location loc) {
if(center == null) {
center = loc;
return;
}
if(!loc.equals(center)) {
currentRadius = 1;
center = loc;
}
}
public void revertAll() {
for (TempBlock tb : tblocks) {
tb.revertBlock();
}
tblocks.clear();
}
public Player getPlayer()
{
return player;
}
public double getRange()
{
return range;
}
public int getRadius()
{
return radius;
}
public long getRevertTime()
{
return revertTime;
}
public void setRange(double value)
{
range = value;
}
public void setRadius(int value)
{
public void setRadius(int value) {
radius = value;
}
public void setRevertTime(long value)
{
public void setRange(double value) {
range = value;
}
public void setRevertTime(long value) {
revertTime = value;
}
}

View file

@ -6,16 +6,17 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.configuration.ConfigLoadable;
import com.projectkorra.ProjectKorra.waterbending.Melt;
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
public class HeatMelt {
public class HeatMelt implements ConfigLoadable {
private static final int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.HeatControl.Melt.Range");
private static final int radius = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.HeatControl.Melt.Radius");
private static int range = config.get().getInt("Abilities.Fire.HeatControl.Melt.Range");
private static int radius = config.get().getInt("Abilities.Fire.HeatControl.Melt.Radius");
public HeatMelt(Player player) {
reloadVariables();
Location location = GeneralMethods.getTargetedLocation(player,
(int) FireMethods.getFirebendingDayAugment(range, player.getWorld()));
for (Block block : GeneralMethods.getBlocksAroundPoint(location,
@ -39,4 +40,10 @@ public class HeatMelt {
private static boolean isHeatable(Block block) {
return false;
}
@Override
public void reloadVariables() {
config.get().getInt("Abilities.Fire.HeatControl.Melt.Range");
radius = config.get().getInt("Abilities.Fire.HeatControl.Melt.Radius");
}
}

View file

@ -3,21 +3,20 @@ package com.projectkorra.ProjectKorra.firebending;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.BendingPlayer;
import com.projectkorra.ProjectKorra.GeneralMethods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
public class Illumination {
public class Illumination extends CoreAbility {
public static ConcurrentHashMap<Player, Illumination> instances = new ConcurrentHashMap<Player, Illumination>();
public static ConcurrentHashMap<Block, Player> blocks = new ConcurrentHashMap<Block, Player>();
private static final int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.Illumination.Range");
private static int range = config.get().getInt("Abilities.Fire.Illumination.Range");
private Player player;
private Block block;
@ -25,21 +24,97 @@ public class Illumination {
private byte normaldata;
public Illumination(Player player) {
/* Initial Checks */
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("Illumination")) return;
if (instances.containsKey(player)) {
instances.get(player).revert();
instances.remove(player);
/* End Initial Checks */
if (containsPlayer(player, Illumination.class)) {
revert();
remove();
} else {
reloadVariables();
this.player = player;
set();
instances.put(player, this);
//instances.put(player, this);
putInstance(player, this);
bPlayer.addCooldown("Illumination", GeneralMethods.getGlobalCooldown());
}
}
public static String getDescription() {
return "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking "
+ "will create a torch that follows you around. The torch will only appear on objects that are "
+ "ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, "
+ "it will disappear, but will reappear when you get on another ignitable block. Clicking again "
+ "dismisses this torch.";
}
public static void revert(Block block) {
Player player = blocks.get(block);
((Illumination) getAbilityFromPlayer(player, Illumination.class)).revert();
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.Illumination;
}
// public static void manage(Server server) {
// for (Player player : server.getOnlinePlayers()) {
// if (instances.containsKey(player)) {
// if (!GeneralMethods.canBend(player.getName(), "Illumination")) {
// instances.get(player).revert();
// instances.remove(player);
// } else {
// instances.get(player).set();
// }
// }
// }
//
// for (Player player : instances.keySet()) {
// if (!player.isOnline() || player.isDead()) {
// instances.get(player).revert();
// instances.remove(player);
// }
// }
// }
@Override
public boolean progress() {
if (!player.isOnline() || player.isDead()) {
remove();
return false;
}
if (!GeneralMethods.canBend(player.getName(), "Illumination")) {
remove();
return false;
} else {
set();
}
return true;
}
@Override
public void reloadVariables() {
range = config.get().getInt("Abilities.Fire.Illumination.Range");
}
@Override
public void remove() {
revert();
super.remove();
}
@SuppressWarnings("deprecation")
private void revert() {
if (block != null) {
blocks.remove(block);
block.setType(normaltype);
block.setData(normaldata);
}
}
@SuppressWarnings("deprecation")
private void set() {
Block standingblock = player.getLocation().getBlock();
@ -75,54 +150,4 @@ public class Illumination {
}
}
@SuppressWarnings("deprecation")
private void revert() {
if (block != null) {
blocks.remove(block);
block.setType(normaltype);
block.setData(normaldata);
}
}
public static void revert(Block block) {
Player player = blocks.get(block);
instances.get(player).revert();
}
public static void manage(Server server) {
for (Player player : server.getOnlinePlayers()) {
if (instances.containsKey(player)) {
if (!GeneralMethods.canBend(player.getName(), "Illumination")) {
instances.get(player).revert();
instances.remove(player);
} else {
instances.get(player).set();
}
}
}
for (Player player : instances.keySet()) {
if (!player.isOnline() || player.isDead()) {
instances.get(player).revert();
instances.remove(player);
}
}
}
public static void removeAll() {
for (Player player : instances.keySet()) {
instances.get(player).revert();
instances.remove(player);
}
}
public static String getDescription() {
return "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking "
+ "will create a torch that follows you around. The torch will only appear on objects that are "
+ "ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, "
+ "it will disappear, but will reappear when you get on another ignitable block. Clicking again "
+ "dismisses this torch.";
}
}

View file

@ -18,34 +18,31 @@ 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.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
public class Lightning {
public static enum State {
START, STRIKE, MAINBOLT
}
public class Lightning extends CoreAbility {
public static boolean SELF_HIT_WATER = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitWater");
public static boolean SELF_HIT_CLOSE = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitClose");
public static boolean ARC_ON_ICE = config.get().getBoolean("Abilities.Fire.Lightning.ArcOnIce");
public static double RANGE = config.get().getDouble("Abilities.Fire.Lightning.Range");
public static double DAMAGE = config.get().getDouble("Abilities.Fire.Lightning.Damage");
public static double MAX_ARC_ANGLE = config.get().getDouble("Abilities.Fire.Lightning.MaxArcAngle");
public static double SUB_ARC_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.SubArcChance");
public static double CHAIN_ARC_RANGE = config.get().getDouble("Abilities.Fire.Lightning.ChainArcRange");
public static double CHAIN_ARC_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.ChainArcChance");
public static double WATER_ARC_RANGE = config.get().getDouble("Abilities.Fire.Lightning.WaterArcRange");
public static double STUN_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.StunChance");
public static double STUN_DURATION = config.get().getDouble("Abilities.Fire.Lightning.StunDuration");
public static int MAX_CHAIN_ARCS = (int) config.get().getDouble("Abilities.Fire.Lightning.MaxChainArcs");
public static int WATER_ARCS = (int) config.get().getDouble("Abilities.Fire.Lightning.WaterArcs");
public static long CHARGETIME = (long) config.get().getDouble("Abilities.Fire.Lightning.ChargeTime");
public static long COOLDOWN = (long) config.get().getDouble("Abilities.Fire.Lightning.Cooldown");
private static final int POINT_GENERATION = 5;
public static ArrayList<Lightning> instances = new ArrayList<Lightning>();
public static boolean SELF_HIT_WATER = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire.Lightning.SelfHitWater");
public static boolean SELF_HIT_CLOSE = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire.Lightning.SelfHitClose");
public static boolean ARC_ON_ICE = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire.Lightning.ArcOnIce");
public static double RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.Range");
public static double DAMAGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.Damage");
public static double MAX_ARC_ANGLE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.MaxArcAngle");
public static double SUB_ARC_CHANCE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.SubArcChance");
public static double CHAIN_ARC_RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.ChainArcRange");
public static double CHAIN_ARC_CHANCE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.ChainArcChance");
public static double WATER_ARC_RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.WaterArcRange");
public static double STUN_CHANCE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.StunChance");
public static double STUN_DURATION = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.StunDuration");
public static int MAX_CHAIN_ARCS = (int) ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.MaxChainArcs");
public static int WATER_ARCS = (int) ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.WaterArcs");
public static long CHARGETIME = (long) ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.ChargeTime");
public static long COOLDOWN = (long) ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Lightning.Cooldown");
private static final int POINT_GENERATION = 5;
private Player player;
private Player player;
private BendingPlayer bplayer;
private Location origin, destination;
private double range, chargeTime, cooldown, subArcChance, damage, chainArcs, chainRange, waterRange;
@ -58,8 +55,9 @@ public class Lightning {
private ArrayList<BukkitRunnable> tasks = new ArrayList<BukkitRunnable>();
private double i = 0.0D;
private double newY;
public Lightning(Player player) {
reloadVariables();
this.player = player;
bplayer = GeneralMethods.getBendingPlayer(player.getName());
charged = false;
@ -94,9 +92,186 @@ public class Lightning {
chargeTime = 0;
cooldown = 0;
}
instances.add(this);
//instances.add(this);
putInstance(player, this);
}
public static ArrayList<Arc> getAllArcs() {
ArrayList<Arc> a = new ArrayList<Arc>();
for (Integer id : getInstances(StockAbilities.Lightning).keySet()) {
Lightning light = (Lightning) getInstances(StockAbilities.Lightning).get(id);
for (Arc arcs : light.getArcs()) {
a.add(arcs);
}
}
return a;
}
/**
* Returns an instance of this ability if it was initialized by player
* @param player that created the instance
* @return the ability
*/
public static Lightning getLightning(Player player) {
for (Integer id : getInstances(StockAbilities.Lightning).keySet()) {
Lightning light = (Lightning) getInstances(StockAbilities.Lightning).get(id);
if (light.player == player)
return light;
}
return null;
}
/**
* Checks if a location contains an ice block
* @param loc the location to check
* @return true if it is ice
*/
public static boolean isIce(Location loc) {
Material mat = loc.getBlock().getType();
return mat == Material.ICE || mat == Material.PACKED_ICE;
}
/**
* Checks if a location contains a water block
* @param loc the location to check
* @return true if it is water
*/
public static boolean isWater(Location loc) {
Material mat = loc.getBlock().getType();
return mat == Material.WATER || mat == Material.STATIONARY_WATER;
}
/**
* Checks if a location is ice or water
* @param loc the location to check
* @return true if it is water or ice
*/
public static boolean isWaterOrIce(Location loc) {
return isIce(loc) || isWater(loc);
}
/**
* Damages an entity, and may cause paralysis depending on the config.
* @param lent: the LivingEntity that is being damaged
*/
public void electrocute(LivingEntity lent) {
lent.getWorld().playSound(lent.getLocation(), Sound.CREEPER_HISS, 1, 0);
player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, 1, 0);
GeneralMethods.damageEntity(player, lent, damage);
if(Math.random() < stunChance) {
final Location lentLoc = lent.getLocation();
final LivingEntity flent = lent;
new BukkitRunnable() {
int count = 0;
public void run() {
if(flent.isDead() || (flent instanceof Player && !((Player) flent).isOnline())) {
cancel();
return;
}
Location tempLoc = lentLoc.clone();
Vector tempVel = flent.getVelocity();
tempVel.setY(Math.min(0, tempVel.getY()));
tempLoc.setY(flent.getLocation().getY());
flent.teleport(tempLoc);
flent.setVelocity(tempVel);
count++;
if(count > stunDuration)
cancel();
}
}.runTaskTimer(ProjectKorra.plugin, 0, 1);
}
}
public ArrayList<Arc> getArcs() {
return this.arcs;
}
public double getChainArcChance() {
return chainArcChance;
}
public double getChainArcs() {
return chainArcs;
}
public double getChainRange() {
return chainRange;
}
public double getChargeTime() {
return chargeTime;
}
public double getCooldown() {
return cooldown;
}
public double getDamage() {
return damage;
}
/** Below are all of the accessor/mutator methods **/
public Player getPlayer() {
return player;
}
public double getRange() {
return range;
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.Lightning;
}
public double getStunChance() {
return stunChance;
}
public double getStunDuration() {
return stunDuration;
}
public double getSubArcChance() {
return subArcChance;
}
public double getWaterRange() {
return waterRange;
}
public boolean isCharged() {
return charged;
}
public boolean isHitIce() {
return hitIce;
}
public boolean isHitWater() {
return hitWater;
}
/**
* Checks if a block is transparent, also considers the ARC_ON_ICE config option.
* @param player the player that is viewing the block
* @param block the block
* @return true if the block is transparent
*/
@SuppressWarnings("deprecation")
public boolean isTransparent(Player player, Block block) {
if (Arrays.asList(EarthMethods.transparentToEarthbending).contains(block.getTypeId())) {
if(GeneralMethods.isRegionProtectedFromBuild(player, "Lightning", block.getLocation()))
return false;
else if(isIce(block.getLocation()))
return ARC_ON_ICE;
else
return true;
}
return false;
}
/** Progresses the instance of this ability by 1 tick.
* This is the heart of the ability, it checks if it needs to
* remove itself, and handles the initial Lightning Arc generation.
@ -104,19 +279,20 @@ public class Lightning {
* Once all of the arcs have been created then this ability instance
* gets removed, but the BukkitRunnables continue until they remove
* themselves. **/
private void progress() {
@Override
public boolean progress() {
if (player.isDead() || !player.isOnline()) {
removeWithTasks();
return;
return false;
}
else if (GeneralMethods.getBoundAbility(player) == null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Lightning")) {
remove();
return;
return false;
}
if(state == State.START) {
if(bplayer.isOnCooldown("Lightning")) {
remove();
return;
return false;
}
if (System.currentTimeMillis() - time > chargeTime)
charged = true;
@ -142,7 +318,7 @@ public class Lightning {
else{
if(!player.isSneaking()) {
remove();
return;
return false;
}
double d1 = 0.1570796326794897D;
double d2 = 0.06283185307179587D;
@ -197,61 +373,30 @@ public class Lightning {
}
if(tasks.size() == 0) {
remove();
return;
return false;
}
}
return true;
}
/**
* Checks if a block is transparent, also considers the ARC_ON_ICE config option.
* @param player the player that is viewing the block
* @param block the block
* @return true if the block is transparent
*/
@SuppressWarnings("deprecation")
public boolean isTransparent(Player player, Block block) {
if (Arrays.asList(EarthMethods.transparentToEarthbending).contains(block.getTypeId())) {
if(GeneralMethods.isRegionProtectedFromBuild(player, "Lightning", block.getLocation()))
return false;
else if(isIce(block.getLocation()))
return ARC_ON_ICE;
else
return true;
}
return false;
}
/**
* Damages an entity, and may cause paralysis depending on the config.
* @param lent: the LivingEntity that is being damaged
*/
public void electrocute(LivingEntity lent) {
lent.getWorld().playSound(lent.getLocation(), Sound.CREEPER_HISS, 1, 0);
player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, 1, 0);
GeneralMethods.damageEntity(player, lent, damage);
if(Math.random() < stunChance) {
final Location lentLoc = lent.getLocation();
final LivingEntity flent = lent;
new BukkitRunnable() {
int count = 0;
public void run() {
if(flent.isDead() || (flent instanceof Player && !((Player) flent).isOnline())) {
cancel();
return;
}
Location tempLoc = lentLoc.clone();
Vector tempVel = flent.getVelocity();
tempVel.setY(Math.min(0, tempVel.getY()));
tempLoc.setY(flent.getLocation().getY());
flent.teleport(tempLoc);
flent.setVelocity(tempVel);
count++;
if(count > stunDuration)
cancel();
}
}.runTaskTimer(ProjectKorra.plugin, 0, 1);
}
@Override
public void reloadVariables() {
SELF_HIT_WATER = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitWater");
SELF_HIT_CLOSE = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitClose");
ARC_ON_ICE = config.get().getBoolean("Abilities.Fire.Lightning.ArcOnIce");
RANGE = config.get().getDouble("Abilities.Fire.Lightning.Range");
DAMAGE = config.get().getDouble("Abilities.Fire.Lightning.Damage");
MAX_ARC_ANGLE = config.get().getDouble("Abilities.Fire.Lightning.MaxArcAngle");
SUB_ARC_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.SubArcChance");
CHAIN_ARC_RANGE = config.get().getDouble("Abilities.Fire.Lightning.ChainArcRange");
CHAIN_ARC_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.ChainArcChance");
WATER_ARC_RANGE = config.get().getDouble("Abilities.Fire.Lightning.WaterArcRange");
STUN_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.StunChance");
STUN_DURATION = config.get().getDouble("Abilities.Fire.Lightning.StunDuration");
MAX_CHAIN_ARCS = (int) config.get().getDouble("Abilities.Fire.Lightning.MaxChainArcs");
WATER_ARCS = (int) config.get().getDouble("Abilities.Fire.Lightning.WaterArcs");
CHARGETIME = (long) config.get().getDouble("Abilities.Fire.Lightning.ChargeTime");
COOLDOWN = (long) config.get().getDouble("Abilities.Fire.Lightning.Cooldown");
}
/**
@ -264,71 +409,97 @@ public class Lightning {
}
remove();
}
/**
* Removes this ability instance
*/ public void remove() {
instances.remove(this);
}
/**
* Removes every instance of this ability
*/
public static void removeAll() {
for (int i = 0; i < instances.size(); i++) {
instances.get(i).remove();
i--;
}
}
/**
* Progresses every instance of this ability by 1 tick
*/
public static void progressAll() {
for (int i = 0; i < instances.size(); i++)
instances.get(i).progress();
}
/**
* Returns an instance of this ability if it was initialized by player
* @param player that created the instance
* @return the ability
*/
public static Lightning getLightning(Player player) {
for(Lightning light : instances) {
if(light.player == player)
return light;
}
return null;
}
/**
* Checks if a location contains an ice block
* @param loc the location to check
* @return true if it is ice
*/
public static boolean isIce(Location loc) {
Material mat = loc.getBlock().getType();
return mat == Material.ICE || mat == Material.PACKED_ICE;
public void setChainArcChance(double chainArcChance) {
this.chainArcChance = chainArcChance;
}
/**
* Checks if a location contains a water block
* @param loc the location to check
* @return true if it is water
*/
public static boolean isWater(Location loc) {
Material mat = loc.getBlock().getType();
return mat == Material.WATER || mat == Material.STATIONARY_WATER;
public void setChainArcs(double chainArcs) {
this.chainArcs = chainArcs;
}
public void setChainRange(double chainRange) {
this.chainRange = chainRange;
}
public void setCharged(boolean charged) {
this.charged = charged;
}
public void setChargeTime(double chargeTime) {
this.chargeTime = chargeTime;
}
public void setCooldown(double cooldown) {
this.cooldown = cooldown;
if(player != null)
bplayer.addCooldown("Lightning", (long) cooldown);
}
public void setDamage(double damage) {
this.damage = damage;
}
public void setHitIce(boolean hitIce) {
this.hitIce = hitIce;
}
public void setHitWater(boolean hitWater) {
this.hitWater = hitWater;
}
public void setPlayer(Player player) {
this.player = player;
}
public void setRange(double range) {
this.range = range;
}
public void setStunChance(double stunChance) {
this.stunChance = stunChance;
}
public void setStunDuration(double stunDuration) {
this.stunDuration = stunDuration;
}
public void setSubArcChance(double subArcChance) {
this.subArcChance = subArcChance;
}
public void setWaterRange(double waterRange) {
this.waterRange = waterRange;
}
/**
* Checks if a location is ice or water
* @param loc the location to check
* @return true if it is water or ice
*/
public static boolean isWaterOrIce(Location loc) {
return isIce(loc) || isWater(loc);
/** Represents a Lightning Arc Point particle animation.
* This basically just holds a location and counts the
* amount of times that a particle has been animated.
* **/
public class AnimLocation {
private Location loc;
private int animCounter;
public AnimLocation(Location loc, int animCounter) {
this.loc = loc;
this.animCounter = animCounter;
}
public int getAnimCounter() {
return animCounter;
}
public Location getLoc() {
return loc;
}
public void setAnimCounter(int animCounter) {
this.animCounter = animCounter;
}
public void setLoc(Location loc) {
this.loc = loc;
}
}
/** An Arc represents a Lightning arc for the specific ability.
@ -354,6 +525,45 @@ public class Lightning {
animCounter = 0;
}
/**
* Stops this Arc from further animating or doing damage.
*/
public void cancel() {
for(int i = 0; i < particles.size(); i++) {
particles.get(i).cancel();
}
for(Arc subArc : subArcs) {
subArc.cancel();
}
}
/** Randomly generates subarcs off of this arc.
* @param chance - The chance that an arc will be generated
* for each specific point in the arc.
* Note: if you generate a lot of points then chance will need to be lowered.
* @param range: The length of each subarc.
* **/
public ArrayList<Arc> generateArcs(double chance, double range) {
ArrayList<Arc> arcs = new ArrayList<Arc>();
for(int i = 0; i < animLocs.size(); i++) {
if(Math.random() < chance) {
Location loc = animLocs.get(i).getLoc();
double angle = (Math.random() - 0.5) * MAX_ARC_ANGLE * 2;
Vector dir = GeneralMethods.rotateXZ(direction.clone(), angle);
double randRange = (Math.random() * range) + (range / 3.0);
Location loc2 = loc.clone().add(dir.normalize().multiply(randRange));
Arc arc = new Arc(loc, loc2);
subArcs.add(arc);
arc.setAnimCounter(animLocs.get(i).getAnimCounter());
arc.generatePoints(POINT_GENERATION);
arcs.add(arc);
arcs.addAll(arc.generateArcs(chance / 2.0, range / 2.0));
}
}
return arcs;
}
/** Runs an arc generation algorithm by first creating two points,
* the starting point and the ending point. Next, it creates a point
* in the middle that has an offset relative to the beginning and
@ -386,117 +596,48 @@ public class Lightning {
}
}
/** Randomly generates subarcs off of this arc.
* @param chance - The chance that an arc will be generated
* for each specific point in the arc.
* Note: if you generate a lot of points then chance will need to be lowered.
* @param range: The length of each subarc.
* **/
public ArrayList<Arc> generateArcs(double chance, double range) {
ArrayList<Arc> arcs = new ArrayList<Arc>();
for(int i = 0; i < animLocs.size(); i++) {
if(Math.random() < chance) {
Location loc = animLocs.get(i).getLoc();
double angle = (Math.random() - 0.5) * MAX_ARC_ANGLE * 2;
Vector dir = GeneralMethods.rotateXZ(direction.clone(), angle);
double randRange = (Math.random() * range) + (range / 3.0);
Location loc2 = loc.clone().add(dir.normalize().multiply(randRange));
Arc arc = new Arc(loc, loc2);
subArcs.add(arc);
arc.setAnimCounter(animLocs.get(i).getAnimCounter());
arc.generatePoints(POINT_GENERATION);
arcs.add(arc);
arcs.addAll(arc.generateArcs(chance / 2.0, range / 2.0));
}
}
return arcs;
public int getAnimCounter() {
return animCounter;
}
/**
* Stops this Arc from further animating or doing damage.
*/
public void cancel() {
for(int i = 0; i < particles.size(); i++) {
particles.get(i).cancel();
}
for(Arc subArc : subArcs) {
subArc.cancel();
}
}
public ArrayList<Location> getPoints() {
return points;
}
public void setPoints(ArrayList<Location> points) {
this.points = points;
public ArrayList<AnimLocation> getAnimLocs() {
return animLocs;
}
public Vector getDirection() {
return direction;
}
public void setDirection(Vector direction) {
this.direction = direction;
public ArrayList<LightningParticle> getParticles() {
return particles;
}
public int getAnimCounter() {
return animCounter;
public ArrayList<Location> getPoints() {
return points;
}
public void setAnimCounter(int animCounter) {
this.animCounter = animCounter;
}
public ArrayList<AnimLocation> getAnimLocs() {
return animLocs;
}
public void setAnimLocs(ArrayList<AnimLocation> animLocs) {
this.animLocs = animLocs;
}
public ArrayList<LightningParticle> getParticles() {
return particles;
public void setDirection(Vector direction) {
this.direction = direction;
}
public void setParticles(ArrayList<LightningParticle> particles) {
this.particles = particles;
}
public void setPoints(ArrayList<Location> points) {
this.points = points;
}
}
/** Represents a Lightning Arc Point particle animation.
* This basically just holds a location and counts the
* amount of times that a particle has been animated.
* **/
public class AnimLocation {
private Location loc;
private int animCounter;
public AnimLocation(Location loc, int animCounter) {
this.loc = loc;
this.animCounter = animCounter;
}
public Location getLoc() {
return loc;
}
public void setLoc(Location loc) {
this.loc = loc;
}
public int getAnimCounter() {
return animCounter;
}
public void setAnimCounter(int animCounter) {
this.animCounter = animCounter;
}
}
/** A Runnable Particle that continuously displays itself
* until it reaches a certain time limit.
*
@ -600,140 +741,7 @@ public class Lightning {
}
}
/** Below are all of the accessor/mutator methods **/
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
public double getRange() {
return range;
}
public void setRange(double range) {
this.range = range;
}
public double getChargeTime() {
return chargeTime;
}
public void setChargeTime(double chargeTime) {
this.chargeTime = chargeTime;
}
public double getCooldown() {
return cooldown;
}
public void setCooldown(double cooldown) {
this.cooldown = cooldown;
if(player != null)
bplayer.addCooldown("Lightning", (long) cooldown);
}
public double getSubArcChance() {
return subArcChance;
}
public void setSubArcChance(double subArcChance) {
this.subArcChance = subArcChance;
}
public double getDamage() {
return damage;
}
public void setDamage(double damage) {
this.damage = damage;
}
public double getChainArcs() {
return chainArcs;
}
public void setChainArcs(double chainArcs) {
this.chainArcs = chainArcs;
}
public double getChainRange() {
return chainRange;
}
public void setChainRange(double chainRange) {
this.chainRange = chainRange;
}
public double getWaterRange() {
return waterRange;
}
public void setWaterRange(double waterRange) {
this.waterRange = waterRange;
}
public double getChainArcChance() {
return chainArcChance;
}
public void setChainArcChance(double chainArcChance) {
this.chainArcChance = chainArcChance;
}
public double getStunChance() {
return stunChance;
}
public void setStunChance(double stunChance) {
this.stunChance = stunChance;
}
public double getStunDuration() {
return stunDuration;
}
public void setStunDuration(double stunDuration) {
this.stunDuration = stunDuration;
}
public boolean isCharged() {
return charged;
}
public void setCharged(boolean charged) {
this.charged = charged;
}
public boolean isHitWater() {
return hitWater;
}
public void setHitWater(boolean hitWater) {
this.hitWater = hitWater;
}
public boolean isHitIce() {
return hitIce;
}
public void setHitIce(boolean hitIce) {
this.hitIce = hitIce;
}
public ArrayList<Arc> getArcs() {
return this.arcs;
}
public static ArrayList<Arc> getAllArcs() {
ArrayList<Arc> a = new ArrayList<Arc>();
for(Lightning l : Lightning.instances) {
for(Arc arcs : l.getArcs()) {
a.add(arcs);
}
}
return a;
public static enum State {
START, STRIKE, MAINBOLT
}
}

View file

@ -6,17 +6,19 @@ import org.bukkit.util.Vector;
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 RingOfFire {
public class RingOfFire implements ConfigLoadable {
static final int defaultrange = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.Blaze.RingOfFire.Range");
static int defaultrange = config.get().getInt("Abilities.Fire.Blaze.RingOfFire.Range");
public RingOfFire(Player player) {
/* Initial Checks */
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("Blaze")) return;
/* End Initial Checks */
reloadVariables();
Location location = player.getLocation();
for (double degrees = 0; degrees < 360; degrees += 10) {
@ -49,4 +51,9 @@ public class RingOfFire {
+ "engulfing everything around you. Use with extreme caution.";
}
@Override
public void reloadVariables() {
defaultrange = config.get().getInt("Abilities.Fire.Blaze.RingOfFire.Range");
}
}

View file

@ -2,12 +2,10 @@ package com.projectkorra.ProjectKorra.firebending;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -15,28 +13,27 @@ import org.bukkit.util.Vector;
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.CoreAbility;
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
import com.projectkorra.ProjectKorra.airbending.AirMethods;
public class WallOfFire {
public class WallOfFire extends CoreAbility {
private Player player;
private static double maxangle = 50;
public static FileConfiguration config = ProjectKorra.plugin.getConfig();
private static int RANGE = config.getInt("Abilities.Fire.WallOfFire.Range");
private int HEIGHT = config.getInt("Abilities.Fire.WallOfFire.Height");
private int WIDTH = config.getInt("Abilities.Fire.WallOfFire.Width");
private long DURATION = config.getLong("Abilities.Fire.WallOfFire.Duration");
private int DAMAGE = config.getInt("Abilities.Fire.WallOfFire.Damage");
private static int RANGE = config.get().getInt("Abilities.Fire.WallOfFire.Range");
private static int HEIGHT = config.get().getInt("Abilities.Fire.WallOfFire.Height");
private static int WIDTH = config.get().getInt("Abilities.Fire.WallOfFire.Width");
private static long DURATION = config.get().getLong("Abilities.Fire.WallOfFire.Duration");
private static int DAMAGE = config.get().getInt("Abilities.Fire.WallOfFire.Damage");
private static long interval = 250;
private static long COOLDOWN = config.getLong("Abilities.Fire.WallOfFire.Cooldown");
public static ConcurrentHashMap<Player, WallOfFire> instances = new ConcurrentHashMap<Player, WallOfFire>();
private static long DAMAGE_INTERVAL = config.getLong("Abilities.Fire.WallOfFire.Interval");
private static double fireticks = config.getDouble("Abilities.Fire.WallOfFire.FireTicks");
private static long COOLDOWN = config.get().getLong("Abilities.Fire.WallOfFire.Cooldown");
private static long DAMAGE_INTERVAL = config.get().getLong("Abilities.Fire.WallOfFire.Interval");
private static double FIRETICKS = config.get().getDouble("Abilities.Fire.WallOfFire.FireTicks");
private Location origin;
private long time, starttime;
@ -52,13 +49,13 @@ public class WallOfFire {
private List<Block> blocks = new ArrayList<Block>();
public WallOfFire(Player player) {
if (instances.containsKey(player) && !AvatarState.isAvatarState(player)) {
/* Initial Checks */
if (containsPlayer(player, WallOfFire.class) && !AvatarState.isAvatarState(player)) {
return;
}
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
if (bPlayer.isOnCooldown("WallOfFire")) return;
/* End Initial Checks */
this.player = player;
@ -93,24 +90,26 @@ public class WallOfFire {
initializeBlocks();
instances.put(player, this);
//instances.put(player, this);
putInstance(player, this);
bPlayer.addCooldown("WallOfFire", cooldown);
}
private void progress() {
@Override
public boolean progress() {
time = System.currentTimeMillis();
if (time - starttime > cooldown) {
instances.remove(player);
return;
remove();
return false;
}
if (!active)
return;
return false;
if (time - starttime > duration) {
active = false;
return;
return false;
}
if (time - starttime > intervaltick * interval) {
@ -122,7 +121,7 @@ public class WallOfFire {
damagetick++;
damage();
}
return true;
}
private void initializeBlocks() {
@ -187,7 +186,7 @@ public class WallOfFire {
}
private void affect(Entity entity) {
entity.setFireTicks((int) (fireticks * 20));
entity.setFireTicks((int) (FIRETICKS * 20));
GeneralMethods.setVelocity(entity, new Vector(0, 0, 0));
if (entity instanceof LivingEntity) {
GeneralMethods.damageEntity(player, entity, damage);
@ -196,12 +195,6 @@ public class WallOfFire {
}
}
public static void manage() {
for (Player player : instances.keySet()) {
instances.get(player).progress();
}
}
public Player getPlayer() {
return player;
}
@ -252,7 +245,7 @@ public class WallOfFire {
public void setCooldown(long cooldown) {
this.cooldown = cooldown;
if(player != null)
if (player != null)
GeneralMethods.getBendingPlayer(player.getName()).addCooldown("WallOfFire", cooldown);
}
@ -263,4 +256,28 @@ public class WallOfFire {
public void setDamageinterval(long damageinterval) {
this.damageinterval = damageinterval;
}
@Override
public void reloadVariables() {
RANGE = config.get().getInt("Abilities.Fire.WallOfFire.Range");
HEIGHT = config.get().getInt("Abilities.Fire.WallOfFire.Height");
WIDTH = config.get().getInt("Abilities.Fire.WallOfFire.Width");
DURATION = config.get().getLong("Abilities.Fire.WallOfFire.Duration");
DAMAGE = config.get().getInt("Abilities.Fire.WallOfFire.Damage");
COOLDOWN = config.get().getLong("Abilities.Fire.WallOfFire.Cooldown");
DAMAGE_INTERVAL = config.get().getLong("Abilities.Fire.WallOfFire.Interval");
FIRETICKS = config.get().getDouble("Abilities.Fire.WallOfFire.FireTicks");
range = RANGE;
height = HEIGHT;
width = WIDTH;
duration = DURATION;
damage = DAMAGE;
cooldown = COOLDOWN;
damageinterval = DAMAGE_INTERVAL;
}
@Override
public StockAbilities getStockAbility() {
return StockAbilities.WallOfFire;
}
}

View file

@ -377,8 +377,8 @@ public class WaterArms {
}
private void checkIfZapped() {
for (int i = 0; i < Lightning.instances.size(); i++) {
Lightning l = Lightning.instances.get(i);
for (Integer id : Lightning.getInstances(Lightning.class).keySet()) {
Lightning l = (Lightning) Lightning.getInstances(Lightning.class).get(id);
for (Lightning.Arc arc : l.getArcs()) {
for (Block arm : revert.keySet()) {
for (Location loc : arc.getPoints()) {
@ -388,11 +388,9 @@ public class WaterArms {
arm.getLocation(), 1.25))
FireMethods.playLightningbendingParticle(l1);
if (lightningKill)
GeneralMethods.damageEntity(Lightning.instances
.get(i).getPlayer(), player, 60D);
GeneralMethods.damageEntity(l.getPlayer(), player, 60D);
else
GeneralMethods.damageEntity(Lightning.instances
.get(i).getPlayer(), player,
GeneralMethods.damageEntity(l.getPlayer(), player,
lightningDamage);
}
}