mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-07-02 10:44:00 +00:00
New system
This commit is contained in:
parent
f4a21e7646
commit
608b3ccc36
14
src/com/projectkorra/ProjectKorra/Ability/AddonAbility.java
Normal file
14
src/com/projectkorra/ProjectKorra/Ability/AddonAbility.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
326
src/com/projectkorra/ProjectKorra/Ability/CoreAbility.java
Normal file
326
src/com/projectkorra/ProjectKorra/Ability/CoreAbility.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,11 +25,11 @@ import com.projectkorra.ProjectKorra.Flight;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Ability.StockAbilities;
|
||||||
import com.projectkorra.ProjectKorra.Objects.HorizontalVelocityTracker;
|
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>();
|
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 affectingradius = config.get().getDouble("Abilities.Air.AirBlast.Radius");
|
||||||
public static double defaultpushfactor = config.get().getDouble("Abilities.Air.AirBlast.Push");
|
public static double defaultpushfactor = config.get().getDouble("Abilities.Air.AirBlast.Push");
|
||||||
private static double originselectrange = 10;
|
private static double originselectrange = 10;
|
||||||
|
private static final int maxticks = 10000;
|
||||||
/* Package visible variables */
|
/* Package visible variables */
|
||||||
static final int maxticks = 10000;
|
|
||||||
static double maxspeed = 1. / defaultpushfactor;
|
static double maxspeed = 1. / defaultpushfactor;
|
||||||
/* End Package visible variables */
|
/* End Package visible variables */
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class AirBlast extends BaseAbility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll() {
|
public static void progressAll() {
|
||||||
BaseAbility.progressAll(StockAbilities.AirBlast);
|
CoreAbility.progressAll(StockAbilities.AirBlast);
|
||||||
for (Player player : origins.keySet()) {
|
for (Player player : origins.keySet()) {
|
||||||
playOriginEffect(player);
|
playOriginEffect(player);
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,7 @@ public class AirBlast extends BaseAbility {
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean progress() {
|
public boolean progress() {
|
||||||
|
//ProjectKorra.log.info("FireBlast id: " + getID());
|
||||||
if (player.isDead() || !player.isOnline()) {
|
if (player.isDead() || !player.isOnline()) {
|
||||||
remove();
|
remove();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -11,12 +11,12 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Element;
|
import com.projectkorra.ProjectKorra.Element;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
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.Ability.StockAbilities;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
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_AIR_RADIUS = config.get().getDouble("Abilities.Air.AirBubble.Radius");
|
||||||
private static double DEFAULT_WATER_RADIUS = config.get().getDouble("Abilities.Water.WaterBubble.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) {
|
public static boolean canFlowTo(Block block) {
|
||||||
for (Object uuid : getInstance(StockAbilities.AirBubble).keySet()) {
|
for (Integer id : getInstances(StockAbilities.AirBubble).keySet()) {
|
||||||
if (((AirBubble) getInstance(StockAbilities.AirBubble).get(uuid)).blockInBubble(block)) {
|
if (((AirBubble) getInstances(StockAbilities.AirBubble).get(id)).blockInBubble(block)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,14 +54,14 @@ public class AirBubble extends BaseAbility {
|
||||||
for (Player player : server.getOnlinePlayers()) {
|
for (Player player : server.getOnlinePlayers()) {
|
||||||
if (GeneralMethods.getBoundAbility(player) != null) {
|
if (GeneralMethods.getBoundAbility(player) != null) {
|
||||||
if (GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirBubble") || GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterBubble")) {
|
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);
|
new AirBubble(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseAbility.progressAll(StockAbilities.AirBubble);
|
CoreAbility.progressAll(StockAbilities.AirBubble);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean blockInBubble(Block block) {
|
public boolean blockInBubble(Block block) {
|
||||||
|
|
|
@ -12,10 +12,10 @@ import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Ability.StockAbilities;
|
||||||
|
|
||||||
public class AirBurst extends BaseAbility {
|
public class AirBurst extends CoreAbility {
|
||||||
|
|
||||||
private static double PARTICLES_PERCENTAGE = 50;
|
private static double PARTICLES_PERCENTAGE = 50;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class AirBurst extends BaseAbility {
|
||||||
private long starttime;
|
private long starttime;
|
||||||
private long chargetime = config.get().getLong("Abilities.Air.AirBurst.ChargeTime");
|
private long chargetime = config.get().getLong("Abilities.Air.AirBurst.ChargeTime");
|
||||||
private boolean charged = false;
|
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>();
|
private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
|
||||||
|
|
||||||
public AirBurst() {
|
public AirBurst() {
|
||||||
|
@ -41,7 +41,7 @@ public class AirBurst extends BaseAbility {
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
if (bPlayer.isOnCooldown("AirBurst"))
|
if (bPlayer.isOnCooldown("AirBurst"))
|
||||||
return;
|
return;
|
||||||
if (getInstance(StockAbilities.AirBurst).containsKey(player.getUniqueId()))
|
if (containsPlayer(player, AirBurst.class))
|
||||||
return;
|
return;
|
||||||
/* End Initial Checks */
|
/* End Initial Checks */
|
||||||
reloadVariables();
|
reloadVariables();
|
||||||
|
@ -54,8 +54,9 @@ public class AirBurst extends BaseAbility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void coneBurst(Player player) {
|
public static void coneBurst(Player player) {
|
||||||
if (getInstance(StockAbilities.AirBurst).containsKey(player.getUniqueId()))
|
if (containsPlayer(player, AirBurst.class)) {
|
||||||
((AirBurst) getInstance(StockAbilities.AirBurst).get(player.getUniqueId())).coneBurst();
|
((AirBurst) getAbilityFromPlayer(player, AirBurst.class)).coneBurst();;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fallBurst(Player player) {
|
public static void fallBurst(Player player) {
|
||||||
|
@ -68,7 +69,7 @@ public class AirBurst extends BaseAbility {
|
||||||
if (GeneralMethods.getBoundAbility(player) == null) {
|
if (GeneralMethods.getBoundAbility(player) == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getInstance(StockAbilities.AirBurst).containsKey(player.getUniqueId())) {
|
if (containsPlayer(player, AirBurst.class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirBurst")) {
|
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirBurst")) {
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.projectkorra.ProjectKorra.airbending;
|
package com.projectkorra.ProjectKorra.airbending;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
@ -13,10 +11,10 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Flight;
|
import com.projectkorra.ProjectKorra.Flight;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
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.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 double speed = config.get().getDouble("Abilities.Air.AirScooter.Speed");
|
||||||
private static final long interval = 100;
|
private static final long interval = 100;
|
||||||
|
@ -29,8 +27,7 @@ public class AirScooter extends BaseAbility {
|
||||||
|
|
||||||
public AirScooter(Player player) {
|
public AirScooter(Player player) {
|
||||||
/* Initial Check */
|
/* Initial Check */
|
||||||
if (getInstance(StockAbilities.AirScooter).containsKey(player.getUniqueId())) {
|
if (check(player)) {
|
||||||
getInstance(StockAbilities.AirScooter).get(player.getUniqueId()).remove();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!player.isSprinting()
|
if (!player.isSprinting()
|
||||||
|
@ -57,16 +54,25 @@ public class AirScooter extends BaseAbility {
|
||||||
progress();
|
progress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void check(Player player) {
|
/**
|
||||||
if (getInstance(StockAbilities.AirScooter).containsKey(player.getUniqueId())) {
|
* Checks if player has an instance already and removes
|
||||||
getInstance(StockAbilities.AirScooter).get(player.getUniqueId()).remove();
|
* 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() {
|
public static ArrayList<Player> getPlayers() {
|
||||||
ArrayList<Player> players = new ArrayList<Player>();
|
ArrayList<Player> players = new ArrayList<Player>();
|
||||||
for (Object uuid : getInstance(StockAbilities.AirScooter).keySet()) {
|
for (Integer id : getInstances(StockAbilities.AirScooter).keySet()) {
|
||||||
players.add(Bukkit.getPlayer((UUID) uuid));
|
players.add(getInstances(StockAbilities.AirScooter).get(id).getPlayer());
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,14 @@ import org.bukkit.util.Vector;
|
||||||
import com.projectkorra.ProjectKorra.Commands;
|
import com.projectkorra.ProjectKorra.Commands;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Ability.StockAbilities;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
||||||
import com.projectkorra.ProjectKorra.firebending.Combustion;
|
import com.projectkorra.ProjectKorra.firebending.Combustion;
|
||||||
import com.projectkorra.ProjectKorra.firebending.FireBlast;
|
import com.projectkorra.ProjectKorra.firebending.FireBlast;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
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 double MAX_RADIUS = config.get().getDouble("Abilities.Air.AirShield.Radius");
|
||||||
private static boolean isToggle = config.get().getBoolean("Abilities.Air.AirShield.IsAvatarStateToggle");
|
private static boolean isToggle = config.get().getBoolean("Abilities.Air.AirShield.IsAvatarStateToggle");
|
||||||
|
@ -33,8 +33,7 @@ public class AirShield extends BaseAbility {
|
||||||
|
|
||||||
public AirShield(Player player) {
|
public AirShield(Player player) {
|
||||||
/* Initial Check */
|
/* Initial Check */
|
||||||
if (AvatarState.isAvatarState(player)
|
if (AvatarState.isAvatarState(player) && containsPlayer(player, AirShield.class) && isToggle) {
|
||||||
&& getInstance(StockAbilities.AirShield).containsKey(player.getUniqueId()) && isToggle) {
|
|
||||||
//instances.remove(player.getUniqueId());
|
//instances.remove(player.getUniqueId());
|
||||||
super.remove();
|
super.remove();
|
||||||
return;
|
return;
|
||||||
|
@ -65,8 +64,8 @@ public class AirShield extends BaseAbility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWithinShield(Location loc){
|
public static boolean isWithinShield(Location loc){
|
||||||
for (Object uuid : getInstance(StockAbilities.AirShield).keySet()) {
|
for (Integer id : getInstances(StockAbilities.AirShield).keySet()) {
|
||||||
AirShield ashield = (AirShield) getInstance(StockAbilities.AirShield).get(uuid);
|
AirShield ashield = (AirShield) getInstances(StockAbilities.AirShield).get(id);
|
||||||
if (ashield.player.getLocation().getWorld() != loc.getWorld())
|
if (ashield.player.getLocation().getWorld() != loc.getWorld())
|
||||||
return false;
|
return false;
|
||||||
if(ashield.player.getLocation().distance(loc) <= ashield.radius)
|
if(ashield.player.getLocation().distance(loc) <= ashield.radius)
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.projectkorra.ProjectKorra.airbending;
|
package com.projectkorra.ProjectKorra.airbending;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
@ -11,10 +9,10 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Flight;
|
import com.projectkorra.ProjectKorra.Flight;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
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.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 double HEIGHT = config.get().getDouble("Abilities.Air.AirSpout.Height");
|
||||||
private static final long interval = 100;
|
private static final long interval = 100;
|
||||||
|
@ -26,8 +24,8 @@ public class AirSpout extends BaseAbility {
|
||||||
|
|
||||||
public AirSpout(Player player) {
|
public AirSpout(Player player) {
|
||||||
/* Initial Check */
|
/* Initial Check */
|
||||||
if (getInstance(StockAbilities.AirSpout).containsKey(player.getUniqueId())) {
|
if (containsPlayer(player, AirSpout.class)) {
|
||||||
getInstance(StockAbilities.AirSpout).get(player.getUniqueId()).remove();
|
getAbilityFromPlayer(player, AirSpout.class).remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* End Initial Check */
|
/* End Initial Check */
|
||||||
|
@ -42,8 +40,8 @@ public class AirSpout extends BaseAbility {
|
||||||
|
|
||||||
public static ArrayList<Player> getPlayers() {
|
public static ArrayList<Player> getPlayers() {
|
||||||
ArrayList<Player> players = new ArrayList<Player>();
|
ArrayList<Player> players = new ArrayList<Player>();
|
||||||
for (Object uuid: getInstance(StockAbilities.AirSpout).keySet()) {
|
for (Integer id: getInstances(StockAbilities.AirSpout).keySet()) {
|
||||||
players.add(Bukkit.getPlayer((UUID) uuid));
|
players.add(getInstances(StockAbilities.AirSpout).get(id).getPlayer());
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
@ -51,8 +49,8 @@ public class AirSpout extends BaseAbility {
|
||||||
public static boolean removeSpouts(Location loc0, double radius,
|
public static boolean removeSpouts(Location loc0, double radius,
|
||||||
Player sourceplayer) {
|
Player sourceplayer) {
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
for (Object uuid : getInstance(StockAbilities.AirSpout).keySet()) {
|
for (Integer id : getInstances(StockAbilities.AirSpout).keySet()) {
|
||||||
Player player = Bukkit.getPlayer((UUID) uuid);
|
Player player = getInstances(StockAbilities.AirSpout).get(id).getPlayer();
|
||||||
if (!player.equals(sourceplayer)) {
|
if (!player.equals(sourceplayer)) {
|
||||||
Location loc1 = player.getLocation().getBlock().getLocation();
|
Location loc1 = player.getLocation().getBlock().getLocation();
|
||||||
loc0 = loc0.getBlock().getLocation();
|
loc0 = loc0.getBlock().getLocation();
|
||||||
|
@ -63,7 +61,7 @@ public class AirSpout extends BaseAbility {
|
||||||
double distance = Math.sqrt(dx * dx + dz * dz);
|
double distance = Math.sqrt(dx * dx + dz * dz);
|
||||||
|
|
||||||
if (distance <= radius && dy > 0 && dy < HEIGHT){
|
if (distance <= radius && dy > 0 && dy < HEIGHT){
|
||||||
getInstance(StockAbilities.AirSpout).get(uuid).remove();
|
getInstances(StockAbilities.AirSpout).get(id).remove();
|
||||||
removed = true;
|
removed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,18 +15,17 @@ import com.projectkorra.ProjectKorra.Flight;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Ability.StockAbilities;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
|
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
|
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>();
|
private static ConcurrentHashMap<Player, Location> origins = new ConcurrentHashMap<Player, Location>();
|
||||||
|
|
||||||
static final double maxspeed = AirBlast.maxspeed;
|
private static final double maxspeed = AirBlast.maxspeed;
|
||||||
|
private static final int maxticks = 10000;
|
||||||
private static final int maxticks = AirBlast.maxticks;
|
|
||||||
|
|
||||||
//private static long soonesttime = config.get().getLong("Properties.GlobalCooldown");
|
//private static long soonesttime = config.get().getLong("Properties.GlobalCooldown");
|
||||||
private static double SPEED = config.get().getDouble("Abilities.Air.AirSuction.Speed");
|
private static double SPEED = config.get().getDouble("Abilities.Air.AirSuction.Speed");
|
||||||
|
@ -131,7 +130,7 @@ public class AirSuction extends BaseAbility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll() {
|
public static void progressAll() {
|
||||||
BaseAbility.progressAll(StockAbilities.AirSuction);
|
CoreAbility.progressAll(StockAbilities.AirSuction);
|
||||||
for (Player player : origins.keySet()) {
|
for (Player player : origins.keySet()) {
|
||||||
playOriginEffect(player);
|
playOriginEffect(player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import com.projectkorra.ProjectKorra.Flight;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Ability.StockAbilities;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
||||||
import com.projectkorra.ProjectKorra.firebending.Combustion;
|
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.WaterManipulation;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
||||||
|
|
||||||
public class AirSwipe extends BaseAbility {
|
public class AirSwipe extends CoreAbility {
|
||||||
|
|
||||||
private static int stepsize = 4;
|
private static int stepsize = 4;
|
||||||
|
|
||||||
|
@ -97,15 +97,15 @@ public class AirSwipe extends BaseAbility {
|
||||||
|
|
||||||
public static boolean removeSwipesAroundPoint(Location loc, double radius) {
|
public static boolean removeSwipesAroundPoint(Location loc, double radius) {
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
for (Object id : getInstance(StockAbilities.AirSwipe).keySet()) {
|
for (Integer id : getInstances(StockAbilities.AirSwipe).keySet()) {
|
||||||
AirSwipe aswipe = (AirSwipe) getInstance(StockAbilities.AirSwipe).get(id);
|
AirSwipe aswipe = (AirSwipe) getInstances(StockAbilities.AirSwipe).get(id);
|
||||||
|
|
||||||
for (Vector vec : aswipe.elements.keySet()) {
|
for (Vector vec : aswipe.elements.keySet()) {
|
||||||
Location vectorLoc = aswipe.elements.get(vec);
|
Location vectorLoc = aswipe.elements.get(vec);
|
||||||
if (vectorLoc != null && vectorLoc.getWorld().equals(loc.getWorld())) {
|
if (vectorLoc != null && vectorLoc.getWorld().equals(loc.getWorld())) {
|
||||||
if (vectorLoc.distance(loc) <= radius) {
|
if (vectorLoc.distance(loc) <= radius) {
|
||||||
//instances.remove(aswipe.uuid);
|
//instances.remove(aswipe.uuid);
|
||||||
getInstance(StockAbilities.AirSwipe).remove(id); //TODO: Check if this works
|
aswipe.remove();
|
||||||
removed = true;
|
removed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Flight;
|
import com.projectkorra.ProjectKorra.Flight;
|
||||||
import com.projectkorra.ProjectKorra.Ability.BaseAbility;
|
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
|
||||||
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
|
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, Integer> hits = new ConcurrentHashMap<String, Integer>();
|
||||||
private static ConcurrentHashMap<String, Boolean> hovering = new ConcurrentHashMap<String, Boolean>();
|
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) {
|
public static boolean contains(Player player) {
|
||||||
return getInstance(StockAbilities.Flight).containsKey(player.getUniqueId());
|
return containsPlayer(player, FlightAbility.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isHovering(Player player) {
|
public static boolean isHovering(Player player) {
|
||||||
|
@ -49,11 +49,11 @@ public class FlightAbility extends BaseAbility {
|
||||||
|
|
||||||
public static void remove(Player player) {
|
public static void remove(Player player) {
|
||||||
if (contains(player))
|
if (contains(player))
|
||||||
getInstance(StockAbilities.Flight).get(player.getUniqueId()).remove();
|
getAbilityFromPlayer(player, FlightAbility.class).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAll() {
|
public static void removeAll() {
|
||||||
BaseAbility.removeAll(StockAbilities.Flight);
|
CoreAbility.removeAll(StockAbilities.Flight);
|
||||||
hits.clear();
|
hits.clear();
|
||||||
hovering.clear();
|
hovering.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Ability.StockAbilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,7 @@ import com.projectkorra.ProjectKorra.Ability.StockAbilities;
|
||||||
* be used on multiple entities within a large radius.
|
* be used on multiple entities within a large radius.
|
||||||
* If the user is damaged while performing this ability then the ability is removed.
|
* 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 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 boolean REQUIRE_CONSTANT_AIM = config.get().getBoolean("Abilities.Air.Suffocate.RequireConstantAim");
|
||||||
private static double ANIM_RADIUS = config.get().getDouble("Abilities.Air.Suffocate.AnimationRadius");
|
private static double ANIM_RADIUS = config.get().getDouble("Abilities.Air.Suffocate.AnimationRadius");
|
||||||
|
@ -96,7 +96,7 @@ public class Suffocate extends BaseAbility {
|
||||||
blindDelay = BLIND_DELAY;
|
blindDelay = BLIND_DELAY;
|
||||||
blindRepeat = BLIND_INTERVAL;
|
blindRepeat = BLIND_INTERVAL;
|
||||||
|
|
||||||
if (getInstances().containsKey(player.getUniqueId()))
|
if (containsPlayer(player, Suffocate.class))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (AvatarState.isAvatarState(player)) {
|
if (AvatarState.isAvatarState(player)) {
|
||||||
|
@ -146,22 +146,22 @@ public class Suffocate extends BaseAbility {
|
||||||
|
|
||||||
/** Stops an entity from being suffocated **/
|
/** Stops an entity from being suffocated **/
|
||||||
public static void breakSuffocate(Entity entity) {
|
public static void breakSuffocate(Entity entity) {
|
||||||
for (Object uuid : getInstances().keySet()) {
|
for (Integer id : getInstances().keySet()) {
|
||||||
Suffocate suffocate = (Suffocate) getInstances().get(uuid);
|
Suffocate suffocate = (Suffocate) getInstances().get(id);
|
||||||
if (suffocate.targets.contains(entity)) {
|
if (suffocate.targets.contains(entity)) {
|
||||||
suffocate.breakSuffocateLocal(entity);
|
suffocate.breakSuffocateLocal(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConcurrentHashMap<Object, ? extends BaseAbility> getInstances() {
|
public static ConcurrentHashMap<Integer, CoreAbility> getInstances() {
|
||||||
return getInstance(StockAbilities.Suffocate);
|
return getInstances(StockAbilities.Suffocate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks if an entity is being suffocated **/
|
/** Checks if an entity is being suffocated **/
|
||||||
public static boolean isBreathbent(Entity entity) {
|
public static boolean isBreathbent(Entity entity) {
|
||||||
for (Object uuid : getInstances().keySet()) {
|
for (Integer id : getInstances().keySet()) {
|
||||||
Suffocate suffocate = (Suffocate) getInstances().get(uuid);
|
Suffocate suffocate = (Suffocate) getInstances().get(id);
|
||||||
if (suffocate.targets.contains(entity)) {
|
if (suffocate.targets.contains(entity)) {
|
||||||
return suffocate.started;
|
return suffocate.started;
|
||||||
}
|
}
|
||||||
|
@ -171,14 +171,14 @@ public class Suffocate extends BaseAbility {
|
||||||
|
|
||||||
/** Determines if a player is Suffocating entities **/
|
/** Determines if a player is Suffocating entities **/
|
||||||
public static boolean isChannelingSphere(Player player) {
|
public static boolean isChannelingSphere(Player player) {
|
||||||
if (getInstances().containsKey(player.getUniqueId())) return true;
|
if (containsPlayer(player, Suffocate.class)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Removes an instance of Suffocate if player is the one suffocating entities **/
|
/** Removes an instance of Suffocate if player is the one suffocating entities **/
|
||||||
public static void remove(Player player) {
|
public static void remove(Player player) {
|
||||||
if (getInstances().containsKey(player.getUniqueId()))
|
if (containsPlayer(player, Suffocate.class))
|
||||||
getInstances().get(player.getUniqueId()).remove();
|
getAbilityFromPlayer(player, Suffocate.class).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Removes all instances of Suffocate at loc within the radius threshold.
|
/** 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
|
* @param causer: the player causing this instance to be removed
|
||||||
* **/
|
* **/
|
||||||
public static boolean removeAtLocation(Player causer, Location loc, double radius) {
|
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()) {
|
while (it.hasNext()) {
|
||||||
Object key = it.next();
|
Integer key = it.next();
|
||||||
Suffocate val = (Suffocate) getInstances().get(key);
|
Suffocate val = (Suffocate) getInstances().get(key);
|
||||||
|
|
||||||
if (causer == null || !key.equals(causer)) {
|
if (causer == null || !key.equals(causer)) {
|
||||||
|
|
|
@ -2,10 +2,8 @@ package com.projectkorra.ProjectKorra.airbending;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
@ -15,10 +13,10 @@ import org.bukkit.util.Vector;
|
||||||
import com.projectkorra.ProjectKorra.Commands;
|
import com.projectkorra.ProjectKorra.Commands;
|
||||||
import com.projectkorra.ProjectKorra.Flight;
|
import com.projectkorra.ProjectKorra.Flight;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
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.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 MAX_HEIGHT = config.get().getDouble("Abilities.Air.Tornado.Height");
|
||||||
private static double PLAYER_PUSH_FACTOR = config.get().getDouble("Abilities.Air.Tornado.PlayerPushFactor");
|
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() {
|
public static ArrayList<Player> getPlayers() {
|
||||||
ArrayList<Player> players = new ArrayList<Player>();
|
ArrayList<Player> players = new ArrayList<Player>();
|
||||||
for (Object uuid : getInstance(StockAbilities.Tornado).keySet()) {
|
for (Integer id : getInstances(StockAbilities.Tornado).keySet()) {
|
||||||
players.add(Bukkit.getPlayer((UUID) uuid));
|
players.add(getInstances(StockAbilities.Tornado).get(id).getPlayer());
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll() {
|
|
||||||
for (Object uuid : getInstance(StockAbilities.Tornado).keySet()) {
|
|
||||||
((Tornado) getInstance(StockAbilities.Tornado).get(uuid)).progress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getMaxheight() {
|
public double getMaxheight() {
|
||||||
return maxheight;
|
return maxheight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,25 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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 defaultarc = config.get().getInt("Abilities.Fire.Blaze.ArcOfFire.Arc");
|
||||||
private static int defaultrange = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.Blaze.ArcOfFire.Range");
|
private static int defaultrange = config.get().getInt("Abilities.Fire.Blaze.ArcOfFire.Range");
|
||||||
private static int stepsize = 2;
|
private static int stepsize = 2;
|
||||||
|
|
||||||
public ArcOfFire(Player player) {
|
public ArcOfFire(Player player) {
|
||||||
|
/* Initial Checks */
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
|
||||||
if (bPlayer.isOnCooldown("Blaze")) return;
|
if (bPlayer.isOnCooldown("Blaze")) return;
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
|
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
|
|
||||||
int arc = (int) FireMethods.getFirebendingDayAugment(defaultarc,
|
int arc = (int) FireMethods.getFirebendingDayAugment(defaultarc,
|
||||||
|
@ -56,4 +62,10 @@ public class ArcOfFire {
|
||||||
+ "in roaring flames.";
|
+ "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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,11 +1,8 @@
|
||||||
package com.projectkorra.ProjectKorra.firebending;
|
package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -15,47 +12,46 @@ import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Utilities.ParticleEffect;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirMethods;
|
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 double speed = config.get().getDouble("Abilities.Fire.Combustion.Speed");
|
||||||
public static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.Combustion.Cooldown");
|
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");
|
private Location location;
|
||||||
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 origin;
|
private Location origin;
|
||||||
|
private Player player;
|
||||||
private Vector direction;
|
private Vector direction;
|
||||||
private double range = defaultrange;
|
private double range = defaultrange;
|
||||||
private double speedfactor;
|
private double speedfactor;
|
||||||
static final int maxticks = 10000;
|
|
||||||
private int ticks = 0;
|
private int ticks = 0;
|
||||||
private float power;
|
private float power;
|
||||||
private double damage;
|
private double damage;
|
||||||
|
|
||||||
public Player player;
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private long starttime;
|
private long starttime;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private boolean charged = false;
|
private boolean charged = false;
|
||||||
public static ConcurrentHashMap<Player, Combustion> instances = new ConcurrentHashMap<Player, Combustion>();
|
|
||||||
|
|
||||||
public Combustion(Player player) {
|
public Combustion(Player player) {
|
||||||
|
/* Initial Checks */
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
if (containsPlayer(player, Combustion.class)) return;
|
||||||
if (instances.containsKey(player)) return;
|
|
||||||
if (bPlayer.isOnCooldown("Combustion")) return;
|
if (bPlayer.isOnCooldown("Combustion")) return;
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
starttime = System.currentTimeMillis();
|
starttime = System.currentTimeMillis();
|
||||||
origin = player.getEyeLocation();
|
origin = player.getEyeLocation();
|
||||||
|
@ -76,46 +72,97 @@ public class Combustion {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
instances.put(player, this);
|
//instances.put(player, this);
|
||||||
|
putInstance(player, this);
|
||||||
bPlayer.addCooldown("Combustion", cooldown);
|
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)) {
|
public static boolean removeAroundPoint(Location loc, double radius) {
|
||||||
return;
|
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()) {
|
if (player.isDead() || !player.isOnline()) {
|
||||||
instances.remove(player);
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GeneralMethods.canBend(player.getName(), "Combustion")) {
|
if (!GeneralMethods.canBend(player.getName(), "Combustion")) {
|
||||||
instances.remove(player);
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GeneralMethods.getBoundAbility(player) == null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Combustion")) {
|
if (GeneralMethods.getBoundAbility(player) == null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Combustion")) {
|
||||||
instances.remove(player);
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "Combustion", location)) {
|
if (GeneralMethods.isRegionProtectedFromBuild(player, "Combustion", location)) {
|
||||||
instances.remove(player);
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
speedfactor = speed * (ProjectKorra.time_step / 1000.);
|
speedfactor = speed * (ProjectKorra.time_step / 1000.);
|
||||||
ticks++;
|
ticks++;
|
||||||
if (ticks > maxticks) {
|
if (ticks > maxticks) {
|
||||||
instances.remove(player);
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.distance(origin) > range) {
|
if (location.distance(origin) > range) {
|
||||||
instances.remove(player);
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
|
@ -133,59 +180,21 @@ public class Combustion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
advanceLocation();
|
advanceLocation();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createExplosion(Location block, float power, boolean breakblocks) {
|
@Override
|
||||||
block.getWorld().createExplosion(block.getX(), block.getY(), block.getZ(), (float) defaultpower, true, breakblocks);
|
public void reloadVariables() {
|
||||||
for (Entity entity: block.getWorld().getEntities()) {
|
chargeTime = config.get().getLong("Abilities.Fire.Combustion.ChargeTime");
|
||||||
if (entity instanceof LivingEntity) {
|
cooldown = config.get().getLong("Abilities.Fire.Combustion.Cooldown");
|
||||||
if (entity.getLocation().distance(block) < radius) { // They are close enough to the explosion.
|
|
||||||
GeneralMethods.damageEntity(player, entity, damage);
|
|
||||||
AirMethods.breakBreathbendingHold(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
instances.remove(player);
|
|
||||||
|
|
||||||
}
|
speed = config.get().getDouble("Abilities.Fire.Combustion.Speed");
|
||||||
|
defaultrange = config.get().getDouble("Abilities.Fire.Combustion.Range");
|
||||||
public static void explode(Player player) {
|
defaultpower = config.get().getDouble("Abilities.Fire.Combustion.Power");
|
||||||
if (instances.containsKey(player)) {
|
breakblocks = config.get().getBoolean("Abilities.Fire.Combustion.BreakBlocks");
|
||||||
Combustion combustion = instances.get(player);
|
radius = config.get().getDouble("Abilities.Fire.Combustion.Radius");
|
||||||
combustion.createExplosion(combustion.location, combustion.power, breakblocks);
|
defaultdamage = config.get().getDouble("Abilities.Fire.Combustion.Damage");
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void launchFireball() {
|
// private void launchFireball() {
|
||||||
|
|
|
@ -2,18 +2,19 @@ package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
|
import com.projectkorra.ProjectKorra.Ability.AddonAbility;
|
||||||
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
|
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
|
||||||
|
|
||||||
public class Cook {
|
/**
|
||||||
|
* Used in {@link HeatControl}.
|
||||||
public static ConcurrentHashMap<Player, Cook> instances = new ConcurrentHashMap<Player, Cook>();
|
*/
|
||||||
|
public class Cook extends AddonAbility {
|
||||||
|
|
||||||
private static final long COOK_TIME = 2000;
|
private static final long COOK_TIME = 2000;
|
||||||
private static final Material[] cookables = { Material.RAW_BEEF,
|
private static final Material[] cookables = { Material.RAW_BEEF,
|
||||||
|
@ -26,27 +27,30 @@ public class Cook {
|
||||||
private long cooktime = COOK_TIME;
|
private long cooktime = COOK_TIME;
|
||||||
|
|
||||||
public Cook(Player player) {
|
public Cook(Player player) {
|
||||||
|
reloadVariables();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
items = player.getItemInHand();
|
items = player.getItemInHand();
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
if (isCookable(items.getType())) {
|
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()) {
|
if (player.isDead() || !player.isOnline()) {
|
||||||
cancel();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GeneralMethods.getBoundAbility(player) == null) {
|
if (GeneralMethods.getBoundAbility(player) == null) {
|
||||||
cancel();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (!player.isSneaking() || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) {
|
if (!player.isSneaking() || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) {
|
||||||
cancel();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!items.equals(player.getItemInHand())) {
|
if (!items.equals(player.getItemInHand())) {
|
||||||
|
@ -55,8 +59,8 @@ public class Cook {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCookable(items.getType())) {
|
if (!isCookable(items.getType())) {
|
||||||
cancel();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.currentTimeMillis() > time + cooktime) {
|
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.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);
|
ParticleEffect.SMOKE.display(player.getEyeLocation(), 0.6F, 0.6F, 0.6F, 0, 6);
|
||||||
}
|
return true;
|
||||||
|
|
||||||
private void cancel() {
|
|
||||||
instances.remove(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isCookable(Material material) {
|
private static boolean isCookable(Material material) {
|
||||||
|
@ -99,9 +100,9 @@ public class Cook {
|
||||||
break;
|
break;
|
||||||
case RAW_FISH:
|
case RAW_FISH:
|
||||||
ItemStack salmon = new ItemStack(Material.RAW_FISH, 1, (short) 1);
|
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);
|
cooked = new ItemStack(Material.COOKED_FISH, 1, (short) 1);
|
||||||
}else{
|
} else {
|
||||||
cooked = new ItemStack(Material.COOKED_FISH, 1);
|
cooked = new ItemStack(Material.COOKED_FISH, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -126,16 +127,6 @@ public class Cook {
|
||||||
return cooked;
|
return cooked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll() {
|
|
||||||
for (Player player : instances.keySet()) {
|
|
||||||
instances.get(player).progress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeAll() {
|
|
||||||
instances.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
@ -156,4 +147,7 @@ public class Cook {
|
||||||
this.cooktime = cooktime;
|
this.cooktime = cooktime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reloadVariables() {}
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,23 +10,28 @@ import org.bukkit.entity.Player;
|
||||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.Element;
|
import com.projectkorra.ProjectKorra.Element;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirBlast;
|
import com.projectkorra.ProjectKorra.airbending.AirBlast;
|
||||||
|
import com.projectkorra.ProjectKorra.configuration.ConfigLoadable;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
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 defaultrange = config.get().getDouble("Abilities.Fire.HeatControl.Extinguish.Range");
|
||||||
private static double defaultradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.HeatControl.Extinguish.Radius");
|
private static double defaultradius = config.get().getDouble("Abilities.Fire.HeatControl.Extinguish.Radius");
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static byte full = AirBlast.full;
|
private static byte full = AirBlast.full;
|
||||||
|
|
||||||
public Extinguish(Player player) {
|
public Extinguish(Player player) {
|
||||||
|
/* Initial Checks */
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
|
||||||
if (bPlayer.isOnCooldown("HeatControl")) return;
|
if (bPlayer.isOnCooldown("HeatControl")) return;
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
|
|
||||||
double range = FireMethods.getFirebendingDayAugment(defaultrange, player.getWorld());
|
double range = FireMethods.getFirebendingDayAugment(defaultrange, player.getWorld());
|
||||||
if (WaterMethods.isMeltable(player.getTargetBlock((HashSet<Material>) null, (int) range))) {
|
if (WaterMethods.isMeltable(player.getTargetBlock((HashSet<Material>) null, (int) range))) {
|
||||||
new HeatMelt(player);
|
new HeatMelt(player);
|
||||||
|
@ -37,12 +42,11 @@ public class Extinguish {
|
||||||
player.getTargetBlock((HashSet<Material>) null, (int) range).getLocation(), radius)) {
|
player.getTargetBlock((HashSet<Material>) null, (int) range).getLocation(), radius)) {
|
||||||
|
|
||||||
Material mat = block.getType();
|
Material mat = block.getType();
|
||||||
if(mat != Material.FIRE
|
if (mat != Material.FIRE
|
||||||
/*&& mat != Material.STATIONARY_LAVA
|
/*&& mat != Material.STATIONARY_LAVA
|
||||||
&& mat != Material.LAVA*/)
|
&& mat != Material.LAVA*/)
|
||||||
continue;
|
continue;
|
||||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze",
|
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze", block.getLocation()))
|
||||||
block.getLocation()))
|
|
||||||
continue;
|
continue;
|
||||||
if (block.getType() == Material.FIRE) {
|
if (block.getType() == Material.FIRE) {
|
||||||
block.setType(Material.AIR);
|
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"
|
+ "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.";
|
+ " 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");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@ package com.projectkorra.ProjectKorra.firebending;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -19,6 +18,8 @@ import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Utilities.ParticleEffect;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirMethods;
|
import com.projectkorra.ProjectKorra.airbending.AirMethods;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
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.WaterManipulation;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
||||||
|
|
||||||
public class FireBlast {
|
public class FireBlast extends CoreAbility {
|
||||||
|
|
||||||
Random rand = new Random();
|
private static double SPEED = config.get().getDouble("Abilities.Fire.FireBlast.Speed");
|
||||||
|
private static double PUSH_FACTOR = config.get().getDouble("Abilities.Fire.FireBlast.Push");
|
||||||
public static ConcurrentHashMap<Integer, FireBlast> instances = new ConcurrentHashMap<Integer, FireBlast>();
|
private static double RANGE = config.get().getDouble("Abilities.Fire.FireBlast.Range");
|
||||||
private static double SPEED = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Speed");
|
private static int DAMAGE = config.get().getInt("Abilities.Fire.FireBlast.Damage");
|
||||||
private static double PUSH_FACTOR = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Push");
|
private static double fireticks = config.get().getDouble("Abilities.Fire.FireBlast.FireTicks");
|
||||||
private static double RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Range");
|
/* Package visible variables */
|
||||||
static boolean dissipate = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire.FireBlast.Dissipate");
|
static boolean dissipate = config.get().getBoolean("Abilities.Fire.FireBlast.Dissipate");
|
||||||
private static int DAMAGE = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.FireBlast.Damage");
|
/* End Package visible variables */
|
||||||
private static double fireticks = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.FireTicks");
|
|
||||||
|
|
||||||
long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBlast.Cooldown");
|
|
||||||
|
|
||||||
public static double AFFECTING_RADIUS = 2;
|
public static double AFFECTING_RADIUS = 2;
|
||||||
|
|
||||||
// public static long interval = 2000;
|
// public static long interval = 2000;
|
||||||
public static byte full = 0x0;
|
public static byte full = 0x0;
|
||||||
private static int ID = Integer.MIN_VALUE;
|
|
||||||
private static boolean canPowerFurnace = true;
|
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 List<Block> safe = new ArrayList<Block>();
|
||||||
private Location origin;
|
private Location origin;
|
||||||
private Vector direction;
|
private Vector direction;
|
||||||
private Player player;
|
private Player player;
|
||||||
private int id;
|
|
||||||
private double speedfactor;
|
private double speedfactor;
|
||||||
private int ticks = 0;
|
private int ticks = 0;
|
||||||
private double range = RANGE;
|
private double range = RANGE;
|
||||||
|
@ -61,35 +59,15 @@ public class FireBlast {
|
||||||
private double pushfactor = PUSH_FACTOR;
|
private double pushfactor = PUSH_FACTOR;
|
||||||
private double affectingradius = AFFECTING_RADIUS;
|
private double affectingradius = AFFECTING_RADIUS;
|
||||||
private boolean showParticles = true;
|
private boolean showParticles = true;
|
||||||
|
private Random rand = new Random();
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
public FireBlast(Location location, Vector direction, Player player, int damage, List<Block> safeblocks) {
|
public FireBlast(Location location, Vector direction, Player player, int damage, List<Block> safeblocks) {
|
||||||
|
/* Initial Checks */
|
||||||
if (location.getBlock().isLiquid()) {
|
if (location.getBlock().isLiquid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
safe = safeblocks;
|
safe = safeblocks;
|
||||||
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
|
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
|
||||||
// timers.put(player, System.currentTimeMillis());
|
// timers.put(player, System.currentTimeMillis());
|
||||||
|
@ -98,21 +76,175 @@ public class FireBlast {
|
||||||
origin = location.clone();
|
origin = location.clone();
|
||||||
this.direction = direction.clone().normalize();
|
this.direction = direction.clone().normalize();
|
||||||
this.damage *= 1.5;
|
this.damage *= 1.5;
|
||||||
id = ID;
|
//instances.put(id, this);
|
||||||
instances.put(id, this);
|
putInstance(player, this);
|
||||||
if (ID == Integer.MAX_VALUE)
|
|
||||||
ID = Integer.MIN_VALUE;
|
|
||||||
ID++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
public boolean progress() {
|
||||||
|
ProjectKorra.log.info("FireBlast id: " + getID());
|
||||||
if (player.isDead() || !player.isOnline()) {
|
if (player.isDead() || !player.isOnline()) {
|
||||||
instances.remove(id);
|
remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze", location)) {
|
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze", location)) {
|
||||||
instances.remove(id);
|
remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +253,7 @@ public class FireBlast {
|
||||||
ticks++;
|
ticks++;
|
||||||
|
|
||||||
if (ticks > maxticks) {
|
if (ticks > maxticks) {
|
||||||
instances.remove(id);
|
remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,12 +268,12 @@ public class FireBlast {
|
||||||
} else if (FireStream.isIgnitable(player, block.getRelative(BlockFace.UP))) {
|
} else if (FireStream.isIgnitable(player, block.getRelative(BlockFace.UP))) {
|
||||||
ignite(location);
|
ignite(location);
|
||||||
}
|
}
|
||||||
instances.remove(id);
|
remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.distance(origin) > range) {
|
if (location.distance(origin) > range) {
|
||||||
instances.remove(id);
|
remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +285,7 @@ public class FireBlast {
|
||||||
if (EarthBlast.annihilateBlasts(location, radius, source)
|
if (EarthBlast.annihilateBlasts(location, radius, source)
|
||||||
|| WaterManipulation.annihilateBlasts(location, radius, source)
|
|| WaterManipulation.annihilateBlasts(location, radius, source)
|
||||||
|| FireBlast.annihilateBlasts(location, radius, source)) {
|
|| FireBlast.annihilateBlasts(location, radius, source)) {
|
||||||
instances.remove(id);
|
remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,131 +311,24 @@ public class FireBlast {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void advanceLocation() {
|
@Override
|
||||||
if (showParticles) {
|
public void reloadVariables() {
|
||||||
//ParticleEffect.RED_DUST.display((float) 16, (float) 111, (float) 227, 0.01F, 0, location, 256D);
|
SPEED = config.get().getDouble("Abilities.Fire.FireBlast.Speed");
|
||||||
ParticleEffect.FLAME.display(location, 0.6F, 0.6F, 0.6F, 0, 20);
|
PUSH_FACTOR = config.get().getDouble("Abilities.Fire.FireBlast.Push");
|
||||||
ParticleEffect.SMOKE.display(location, 0.6F, 0.6F, 0.6F, 0, 20);
|
RANGE = config.get().getDouble("Abilities.Fire.FireBlast.Range");
|
||||||
}
|
DAMAGE = config.get().getInt("Abilities.Fire.FireBlast.Damage");
|
||||||
location = location.add(direction.clone().multiply(speedfactor));
|
fireticks = config.get().getDouble("Abilities.Fire.FireBlast.FireTicks");
|
||||||
if (rand.nextInt(4) == 0) {
|
dissipate = config.get().getBoolean("Abilities.Fire.FireBlast.Dissipate");
|
||||||
FireMethods.playFirebendingSound(location);
|
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) {
|
public void setAffectingradius(double affectingradius) {
|
||||||
for (Block block : GeneralMethods.getBlocksAroundPoint(location, affectingradius)) {
|
this.affectingradius = 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 setCooldown(long cooldown) {
|
public void setCooldown(long cooldown) {
|
||||||
|
@ -312,40 +337,24 @@ public class FireBlast {
|
||||||
GeneralMethods.getBendingPlayer(player.getName()).addCooldown("FireBlast", cooldown);
|
GeneralMethods.getBendingPlayer(player.getName()).addCooldown("FireBlast", cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public void setDamage(double dmg) {
|
||||||
return player;
|
this.damage = dmg;
|
||||||
}
|
|
||||||
|
|
||||||
public double getSpeed() {
|
|
||||||
return speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSpeed(double speed) {
|
|
||||||
this.speed = speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPushfactor() {
|
|
||||||
return pushfactor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPushfactor(double pushfactor) {
|
public void setPushfactor(double pushfactor) {
|
||||||
this.pushfactor = pushfactor;
|
this.pushfactor = pushfactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getAffectingradius() {
|
public void setRange(double range) {
|
||||||
return affectingradius;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAffectingradius(double affectingradius) {
|
public void setShowParticles(boolean show) {
|
||||||
this.affectingradius = affectingradius;
|
this.showParticles = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRange() {
|
public void setSpeed(double speed) {
|
||||||
return range;
|
this.speed = speed;
|
||||||
}
|
|
||||||
|
|
||||||
public double getDamage() {
|
|
||||||
return damage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -16,44 +15,55 @@ import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
|
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
|
||||||
|
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
|
||||||
|
|
||||||
public class FireBurst {
|
public class FireBurst extends CoreAbility {
|
||||||
private static ConcurrentHashMap<Player, FireBurst> instances = new ConcurrentHashMap<Player, FireBurst>();
|
|
||||||
private static double PARTICLES_PERCENTAGE = 5;
|
private static double PARTICLES_PERCENTAGE = 5;
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private long starttime;
|
private long starttime;
|
||||||
private int damage = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.FireBurst.Damage");
|
private int damage = config.get().getInt("Abilities.Fire.FireBurst.Damage");
|
||||||
private long chargetime = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBurst.ChargeTime");
|
private long chargetime = config.get().getLong("Abilities.Fire.FireBurst.ChargeTime");
|
||||||
private long range = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBurst.Range");
|
private long range = config.get().getLong("Abilities.Fire.FireBurst.Range");
|
||||||
private double deltheta = 10;
|
private double deltheta = 10;
|
||||||
private double delphi = 10;
|
private double delphi = 10;
|
||||||
private boolean charged = false;
|
private boolean charged = false;
|
||||||
private ArrayList<FireBlast> blasts = new ArrayList<FireBlast>();
|
private ArrayList<FireBlast> blasts = new ArrayList<FireBlast>();
|
||||||
|
|
||||||
public FireBurst(Player player) {
|
public FireBurst(Player player) {
|
||||||
|
/* Initial Checks */
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
|
||||||
if (bPlayer.isOnCooldown("FireBurst")) return;
|
if (bPlayer.isOnCooldown("FireBurst")) return;
|
||||||
|
if (containsPlayer(player, FireBurst.class))
|
||||||
if (instances.containsKey(player))
|
|
||||||
return;
|
return;
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
|
|
||||||
starttime = System.currentTimeMillis();
|
starttime = System.currentTimeMillis();
|
||||||
if (FireMethods.isDay(player.getWorld())) {
|
if (FireMethods.isDay(player.getWorld())) {
|
||||||
chargetime /= ProjectKorra.plugin.getConfig().getDouble("Properties.Fire.DayFactor");
|
chargetime /= config.get().getDouble("Properties.Fire.DayFactor");
|
||||||
}
|
}
|
||||||
if (AvatarState.isAvatarState(player))
|
if (AvatarState.isAvatarState(player))
|
||||||
chargetime = 0;
|
chargetime = 0;
|
||||||
if (BendingManager.events.containsKey(player.getWorld())) {
|
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;
|
this.player = player;
|
||||||
instances.put(player, this);
|
//instances.put(player, this);
|
||||||
|
putInstance(player, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void coneBurst(Player player) {
|
public static void coneBurst(Player player) {
|
||||||
if (instances.containsKey(player))
|
if (containsPlayer(player, FireBurst.class))
|
||||||
instances.get(player).coneBurst();
|
((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() {
|
private void coneBurst() {
|
||||||
|
@ -84,7 +94,97 @@ public class FireBurst {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Methods.verbose("--" + AirBlast.instances.size() + "--");
|
// 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() {
|
private void sphereBurst() {
|
||||||
|
@ -110,101 +210,7 @@ public class FireBurst {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Methods.verbose("--" + AirBlast.instances.size() + "--");
|
// Methods.verbose("--" + AirBlast.instances.size() + "--");
|
||||||
instances.remove(player);
|
remove();
|
||||||
handleSmoothParticles();
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -24,12 +24,10 @@ import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
import com.projectkorra.ProjectKorra.Utilities.ClickType;
|
import com.projectkorra.ProjectKorra.Utilities.ClickType;
|
||||||
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
|
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirMethods;
|
import com.projectkorra.ProjectKorra.airbending.AirMethods;
|
||||||
import com.projectkorra.ProjectKorra.chiblocking.ChiMethods;
|
import com.projectkorra.ProjectKorra.configuration.ConfigLoadable;
|
||||||
import com.projectkorra.ProjectKorra.chiblocking.Paralyze;
|
|
||||||
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
|
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
||||||
|
|
||||||
public class FireCombo {
|
public class FireCombo implements ConfigLoadable {
|
||||||
public static final List<String> abilitiesToBlock = new ArrayList<String>() {
|
public static final List<String> abilitiesToBlock = new ArrayList<String>() {
|
||||||
private static final long serialVersionUID = 5395690551860441647L;
|
private static final long serialVersionUID = 5395690551860441647L;
|
||||||
{
|
{
|
||||||
|
@ -45,46 +43,46 @@ public class FireCombo {
|
||||||
add("AirSweep");
|
add("AirSweep");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static boolean enabled = ProjectKorra.plugin.getConfig()
|
private static boolean enabled = config.get()
|
||||||
.getBoolean("Abilities.Fire.FireCombo.Enabled");
|
.getBoolean("Abilities.Fire.FireCombo.Enabled");
|
||||||
private static final double FIRE_WHEEL_STARTING_HEIGHT = 2;
|
private static final double FIRE_WHEEL_STARTING_HEIGHT = 2;
|
||||||
private static final double FIRE_WHEEL_RADIUS = 1;
|
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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.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");
|
.getLong("Abilities.Fire.FireCombo.JetBlaze.Cooldown");
|
||||||
|
|
||||||
public static ArrayList<FireCombo> instances = new ArrayList<FireCombo>();
|
public static ArrayList<FireCombo> instances = new ArrayList<FireCombo>();
|
||||||
|
@ -108,6 +106,7 @@ public class FireCombo {
|
||||||
|
|
||||||
public FireCombo(Player player, String ability) {
|
public FireCombo(Player player, String ability) {
|
||||||
// Dont' call Methods.canBind directly, it doesn't let you combo as fast
|
// Dont' call Methods.canBind directly, it doesn't let you combo as fast
|
||||||
|
/* Initial Checks */
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
return;
|
return;
|
||||||
if(!GeneralMethods.getBendingPlayer(player.getName()).hasElement(Element.Fire))
|
if(!GeneralMethods.getBendingPlayer(player.getName()).hasElement(Element.Fire))
|
||||||
|
@ -119,15 +118,16 @@ public class FireCombo {
|
||||||
return;
|
return;
|
||||||
if (!GeneralMethods.getBendingPlayer(player.getName()).isToggled())
|
if (!GeneralMethods.getBendingPlayer(player.getName()).isToggled())
|
||||||
return;
|
return;
|
||||||
|
if (GeneralMethods.canBend(player.getDisplayName(), ability)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.ability = ability;
|
this.ability = ability;
|
||||||
this.bplayer = GeneralMethods.getBendingPlayer(player.getName());
|
this.bplayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
|
||||||
if (GeneralMethods.canBend(player.getDisplayName(), ability)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ability.equalsIgnoreCase("FireKick")) {
|
if (ability.equalsIgnoreCase("FireKick")) {
|
||||||
damage = FIRE_KICK_DAMAGE;
|
damage = FIRE_KICK_DAMAGE;
|
||||||
range = FIRE_KICK_RANGE;
|
range = FIRE_KICK_RANGE;
|
||||||
|
@ -159,6 +159,131 @@ public class FireCombo {
|
||||||
instances.add(this);
|
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() {
|
public void progress() {
|
||||||
progressCounter++;
|
progressCounter++;
|
||||||
for (int i = 0; i < tasks.size(); i++) {
|
for (int i = 0; i < tasks.size(); i++) {
|
||||||
|
@ -259,7 +384,7 @@ public class FireCombo {
|
||||||
if (System.currentTimeMillis() - time > 5000) {
|
if (System.currentTimeMillis() - time > 5000) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
} else if (FireJet.instances.containsKey(player)) {
|
} else if (FireJet.checkTemporaryImmunity(player)) {
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
if (bplayer.isOnCooldown("JetBlast")
|
if (bplayer.isOnCooldown("JetBlast")
|
||||||
&& !AvatarState.isAvatarState(player)) {
|
&& !AvatarState.isAvatarState(player)) {
|
||||||
|
@ -301,7 +426,7 @@ public class FireCombo {
|
||||||
} else if (System.currentTimeMillis() - time > 5000) {
|
} else if (System.currentTimeMillis() - time > 5000) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
} else if (FireJet.instances.containsKey(player)) {
|
} else if (FireJet.checkTemporaryImmunity(player)) {
|
||||||
direction = player.getVelocity().clone().multiply(-1);
|
direction = player.getVelocity().clone().multiply(-1);
|
||||||
player.setVelocity(player.getVelocity().normalize()
|
player.setVelocity(player.getVelocity().normalize()
|
||||||
.multiply(speed));
|
.multiply(speed));
|
||||||
|
@ -389,141 +514,59 @@ public class FireCombo {
|
||||||
checkSafeZone();
|
checkSafeZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkSafeZone() {
|
@Override
|
||||||
if (currentLoc != null
|
public void reloadVariables() {
|
||||||
&& GeneralMethods.isRegionProtectedFromBuild(player, "Blaze",
|
enabled = config.get()
|
||||||
currentLoc))
|
.getBoolean("Abilities.Fire.FireCombo.Enabled");
|
||||||
remove();
|
fireticksFireWheel = config.get()
|
||||||
}
|
.getDouble("Abilities.Fire.FireCombo.FireWheel.FireTicks");
|
||||||
|
fireticksJetBlaze = config.get()
|
||||||
public void collision(LivingEntity entity, Vector direction,
|
.getDouble("Abilities.Fire.FireCombo.JetBlaze.FireTicks");
|
||||||
FireComboStream fstream) {
|
FIRE_KICK_RANGE = config.get()
|
||||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "Blaze",
|
.getDouble("Abilities.Fire.FireCombo.FireKick.Range");
|
||||||
entity.getLocation()))
|
FIRE_KICK_DAMAGE = config.get()
|
||||||
return;
|
.getDouble("Abilities.Fire.FireCombo.FireKick.Damage");
|
||||||
entity.getLocation()
|
FIRE_SPIN_RANGE = config.get()
|
||||||
.getWorld()
|
.getDouble("Abilities.Fire.FireCombo.FireSpin.Range");
|
||||||
.playSound(entity.getLocation(), Sound.VILLAGER_HIT, 0.3f, 0.3f);
|
FIRE_SPIN_DAMAGE = config.get()
|
||||||
|
.getDouble("Abilities.Fire.FireCombo.FireSpin.Damage");
|
||||||
if (ability.equalsIgnoreCase("FireKick")) {
|
FIRE_SPIN_KNOCKBACK = config.get()
|
||||||
GeneralMethods.damageEntity(player, entity, damage);
|
.getDouble("Abilities.Fire.FireCombo.FireSpin.Knockback");
|
||||||
fstream.remove();
|
FIRE_WHEEL_DAMAGE = config.get()
|
||||||
} else if (ability.equalsIgnoreCase("FireSpin")) {
|
.getDouble("Abilities.Fire.FireCombo.FireWheel.Damage");
|
||||||
double knockback = AvatarState.isAvatarState(player) ? FIRE_SPIN_KNOCKBACK + 0.5
|
FIRE_WHEEL_RANGE = config.get()
|
||||||
: FIRE_SPIN_KNOCKBACK;
|
.getDouble("Abilities.Fire.FireCombo.FireWheel.Range");
|
||||||
GeneralMethods.damageEntity(player, entity, damage);
|
FIRE_WHEEL_SPEED = config.get()
|
||||||
entity.setVelocity(direction.normalize().multiply(knockback));
|
.getDouble("Abilities.Fire.FireCombo.FireWheel.Speed");
|
||||||
fstream.remove();
|
JET_BLAST_SPEED = config.get()
|
||||||
} else if (ability.equalsIgnoreCase("JetBlaze")) {
|
.getDouble("Abilities.Fire.FireCombo.JetBlast.Speed");
|
||||||
if (!affectedEntities.contains(entity)) {
|
JET_BLAZE_SPEED = config.get()
|
||||||
affectedEntities.add(entity);
|
.getDouble("Abilities.Fire.FireCombo.JetBlaze.Speed");
|
||||||
GeneralMethods.damageEntity(player, entity, damage);
|
JET_BLAZE_DAMAGE = config.get()
|
||||||
entity.setFireTicks((int) (fireticksJetBlaze * 20));
|
.getDouble("Abilities.Fire.FireCombo.JetBlaze.Damage");
|
||||||
}
|
|
||||||
} else if (ability.equalsIgnoreCase("FireWheel")) {
|
FIRE_KICK_COOLDOWN = config.get()
|
||||||
if (!affectedEntities.contains(entity)) {
|
.getLong("Abilities.Fire.FireCombo.FireKick.Cooldown");
|
||||||
affectedEntities.add(entity);
|
FIRE_SPIN_COOLDOWN = config.get()
|
||||||
GeneralMethods.damageEntity(player, entity, damage);
|
.getLong("Abilities.Fire.FireCombo.FireSpin.Cooldown");
|
||||||
entity.setFireTicks((int) (fireticksFireWheel * 20));
|
FIRE_WHEEL_COOLDOWN = config.get()
|
||||||
this.remove();
|
.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() {
|
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);
|
instances.remove(this);
|
||||||
for (BukkitRunnable task : tasks)
|
for (BukkitRunnable task : tasks)
|
||||||
task.cancel();
|
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 {
|
public static class FireComboStream extends BukkitRunnable {
|
||||||
private Vector direction;
|
private Vector direction;
|
||||||
private double speed;
|
private double speed;
|
||||||
|
@ -552,6 +595,27 @@ public class FireCombo {
|
||||||
this.distance = distance;
|
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() {
|
public void run() {
|
||||||
Block block = currentLoc.getBlock();
|
Block block = currentLoc.getBlock();
|
||||||
if (block.getRelative(BlockFace.UP).getType() != Material.AIR
|
if (block.getRelative(BlockFace.UP).getType() != Material.AIR
|
||||||
|
@ -587,41 +651,8 @@ public class FireCombo {
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void setCheckCollisionDelay(int delay) {
|
||||||
remove();
|
this.checkCollisionDelay = delay;
|
||||||
}
|
|
||||||
|
|
||||||
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 setCollides(boolean b) {
|
public void setCollides(boolean b) {
|
||||||
|
@ -632,12 +663,24 @@ public class FireCombo {
|
||||||
this.collisionRadius = radius;
|
this.collisionRadius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDensity(int density) {
|
||||||
|
this.density = density;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParticleEffect(ParticleEffect effect) {
|
||||||
|
this.particleEffect = effect;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSinglePoint(boolean b) {
|
public void setSinglePoint(boolean b) {
|
||||||
this.singlePoint = b;
|
this.singlePoint = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCheckCollisionDelay(int delay) {
|
public void setSpread(float spread) {
|
||||||
this.checkCollisionDelay = delay;
|
this.spread = spread;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseNewParticles(boolean b) {
|
||||||
|
useNewParticles = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.projectkorra.ProjectKorra.firebending;
|
package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -11,19 +10,17 @@ import org.bukkit.util.Vector;
|
||||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.Flight;
|
import com.projectkorra.ProjectKorra.Flight;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Utilities.ParticleEffect;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
||||||
|
|
||||||
|
public class FireJet extends CoreAbility {
|
||||||
|
|
||||||
public class FireJet {
|
private static double defaultfactor = config.get().getDouble("Abilities.Fire.FireJet.Speed");
|
||||||
|
private static long defaultduration = config.get().getLong("Abilities.Fire.FireJet.Duration");
|
||||||
public static ConcurrentHashMap<Player, FireJet> instances = new ConcurrentHashMap<Player, FireJet>();
|
private static boolean isToggle = config.get().getBoolean("Abilities.Fire.FireJet.IsAvatarStateToggle");
|
||||||
|
|
||||||
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 Player player;
|
private Player player;
|
||||||
private long time;
|
private long time;
|
||||||
|
@ -31,17 +28,19 @@ public class FireJet {
|
||||||
private double factor = defaultfactor;
|
private double factor = defaultfactor;
|
||||||
|
|
||||||
public FireJet(Player player) {
|
public FireJet(Player player) {
|
||||||
if (instances.containsKey(player)) {
|
/* Initial Checks */
|
||||||
instances.remove(player);
|
if (containsPlayer(player, FireJet.class)) {
|
||||||
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
|
||||||
if (bPlayer.isOnCooldown("FireJet")) return;
|
if (bPlayer.isOnCooldown("FireJet")) return;
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
|
|
||||||
factor = FireMethods.getFirebendingDayAugment(defaultfactor, player.getWorld());
|
factor = FireMethods.getFirebendingDayAugment(defaultfactor, player.getWorld());
|
||||||
Block block = player.getLocation().getBlock();
|
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));
|
player.setVelocity(player.getEyeLocation().getDirection().clone().normalize().multiply(factor));
|
||||||
block.setType(Material.FIRE);
|
block.setType(Material.FIRE);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
@ -50,29 +49,31 @@ public class FireJet {
|
||||||
player.setAllowFlight(true);
|
player.setAllowFlight(true);
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
// timers.put(player, time);
|
// timers.put(player, time);
|
||||||
instances.put(player, this);
|
//instances.put(player, this);
|
||||||
bPlayer.addCooldown("FireJet", ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireJet.Cooldown"));
|
putInstance(player, this);
|
||||||
|
bPlayer.addCooldown("FireJet", config.get().getLong("Abilities.Fire.FireJet.Cooldown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkTemporaryImmunity(Player player) {
|
public static boolean checkTemporaryImmunity(Player player) {
|
||||||
if (instances.containsKey(player)) {
|
if (containsPlayer(player, FireJet.class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void progress() {
|
@Override
|
||||||
|
public boolean progress() {
|
||||||
if (player.isDead() || !player.isOnline()) {
|
if (player.isDead() || !player.isOnline()) {
|
||||||
// player.setAllowFlight(canfly);
|
// player.setAllowFlight(canfly);
|
||||||
instances.remove(player);
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if ((WaterMethods.isWater(player.getLocation().getBlock()) || System.currentTimeMillis() > time + duration)
|
if ((WaterMethods.isWater(player.getLocation().getBlock()) || System.currentTimeMillis() > time + duration)
|
||||||
&& (!AvatarState.isAvatarState(player) || !isToggle)) {
|
&& (!AvatarState.isAvatarState(player) || !isToggle)) {
|
||||||
// player.setAllowFlight(canfly);
|
// player.setAllowFlight(canfly);
|
||||||
instances.remove(player);
|
remove();
|
||||||
} else {
|
} else {
|
||||||
if (GeneralMethods.rand.nextInt(2) == 0) {
|
if (GeneralMethods.rand.nextInt(2) == 0) {
|
||||||
FireMethods.playFirebendingSound(player.getLocation());
|
FireMethods.playFirebendingSound(player.getLocation());
|
||||||
|
@ -92,18 +93,13 @@ public class FireJet {
|
||||||
player.setVelocity(velocity);
|
player.setVelocity(velocity);
|
||||||
player.setFallDistance(0);
|
player.setFallDistance(0);
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
|
|
||||||
public static void progressAll() {
|
|
||||||
for (Player player : instances.keySet()) {
|
|
||||||
instances.get(player).progress();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Player> getPlayers() {
|
public static ArrayList<Player> getPlayers() {
|
||||||
ArrayList<Player> players = new ArrayList<Player>();
|
ArrayList<Player> players = new ArrayList<Player>();
|
||||||
for (Player player : instances.keySet()) {
|
for (Integer id : getInstances(StockAbilities.FireJet).keySet()) {
|
||||||
players.add(player);
|
players.add(getInstances(StockAbilities.FireJet).get(id).getPlayer());
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
@ -128,4 +124,16 @@ public class FireJet {
|
||||||
this.factor = factor;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,12 +136,12 @@ public class FireMethods {
|
||||||
public static void stopBending() {
|
public static void stopBending() {
|
||||||
FireStream.removeAll();
|
FireStream.removeAll();
|
||||||
Fireball.removeAll();
|
Fireball.removeAll();
|
||||||
WallOfFire.instances.clear();
|
WallOfFire.removeAll();
|
||||||
Lightning.instances.clear();
|
Lightning.removeAll();
|
||||||
FireShield.removeAll();
|
FireShield.removeAll();
|
||||||
FireBlast.removeAll();
|
FireBlast.removeAll();
|
||||||
FireBurst.removeAll();
|
FireBurst.removeAll();
|
||||||
FireJet.instances.clear();
|
FireJet.removeAll();
|
||||||
Cook.removeAll();
|
Cook.removeAll();
|
||||||
Illumination.removeAll();
|
Illumination.removeAll();
|
||||||
FireCombo.removeAll();
|
FireCombo.removeAll();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.projectkorra.ProjectKorra.firebending;
|
package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -13,20 +12,19 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
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.Utilities.ParticleEffect;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
||||||
|
|
||||||
public class FireShield {
|
public class FireShield extends CoreAbility {
|
||||||
|
|
||||||
public static ConcurrentHashMap<Player, FireShield> instances = new ConcurrentHashMap<Player, FireShield>();
|
|
||||||
|
|
||||||
private static long interval = 100;
|
private static long interval = 100;
|
||||||
private static long DURATION = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireShield.Duration");
|
private static long DURATION = config.get().getLong("Abilities.Fire.FireShield.Duration");
|
||||||
private static double RADIUS = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireShield.Radius");
|
private static double RADIUS = config.get().getDouble("Abilities.Fire.FireShield.Radius");
|
||||||
private static double DISC_RADIUS = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireShield.DiscRadius");
|
private static double DISC_RADIUS = config.get().getDouble("Abilities.Fire.FireShield.DiscRadius");
|
||||||
private static double fireticks = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireShield.FireTicks");
|
private static double fireticks = config.get().getDouble("Abilities.Fire.FireShield.FireTicks");
|
||||||
private static boolean ignite = true;
|
private static boolean ignite = true;
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
|
@ -42,45 +40,100 @@ public class FireShield {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FireShield(Player player, boolean shield) {
|
public FireShield(Player player, boolean shield) {
|
||||||
this.player = player;
|
/* Initial Checks */
|
||||||
this.shield = shield;
|
if (containsPlayer(player, FireShield.class))
|
||||||
if (instances.containsKey(player))
|
|
||||||
return;
|
return;
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
|
||||||
if (bPlayer.isOnCooldown("FireShield")) return;
|
if (bPlayer.isOnCooldown("FireShield")) return;
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
|
this.player = player;
|
||||||
|
this.shield = shield;
|
||||||
|
|
||||||
if (!player.getEyeLocation().getBlock().isLiquid()) {
|
if (!player.getEyeLocation().getBlock().isLiquid()) {
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
starttime = time;
|
starttime = time;
|
||||||
instances.put(player, this);
|
//instances.put(player, this);
|
||||||
|
putInstance(player, this);
|
||||||
if (!shield)
|
if (!shield)
|
||||||
bPlayer.addCooldown("FireShield", GeneralMethods.getGlobalCooldown());
|
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) {
|
public static void shield(Player player) {
|
||||||
new FireShield(player, true);
|
new FireShield(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void remove() {
|
public double getDiscradius() {
|
||||||
instances.remove(player);
|
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")) {
|
if (((!player.isSneaking()) && shield) || !GeneralMethods.canBend(player.getName(), "FireShield")) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.isOnline() || player.isDead()) {
|
if (!player.isOnline() || player.isDead()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.currentTimeMillis() > starttime + duration && !shield) {
|
if (System.currentTimeMillis() > starttime + duration && !shield) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.currentTimeMillis() > time + interval) {
|
if (System.currentTimeMillis() > time + interval) {
|
||||||
|
@ -129,7 +182,6 @@ public class FireShield {
|
||||||
// FireStream.removeAroundPoint(location, radius);
|
// FireStream.removeAroundPoint(location, radius);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
Location location = player.getEyeLocation().clone();
|
Location location = player.getEyeLocation().clone();
|
||||||
Vector direction = location.getDirection();
|
Vector direction = location.getDirection();
|
||||||
|
@ -137,7 +189,7 @@ public class FireShield {
|
||||||
|
|
||||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "FireShield", location)) {
|
if (GeneralMethods.isRegionProtectedFromBuild(player, "FireShield", location)) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (double theta = 0; theta < 360; theta += 20) {
|
for (double theta = 0; theta < 360; theta += 20) {
|
||||||
|
@ -179,80 +231,33 @@ public class FireShield {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWithinShield(Location loc) {
|
@Override
|
||||||
for (Player player : instances.keySet()){
|
public void reloadVariables() {
|
||||||
FireShield fshield = instances.get(player);
|
DURATION = config.get().getLong("Abilities.Fire.FireShield.Duration");
|
||||||
Location playerLoc = fshield.player.getLocation();
|
RADIUS = config.get().getDouble("Abilities.Fire.FireShield.Radius");
|
||||||
|
DISC_RADIUS = config.get().getDouble("Abilities.Fire.FireShield.DiscRadius");
|
||||||
if(fshield.shield) {
|
fireticks = config.get().getDouble("Abilities.Fire.FireShield.FireTicks");
|
||||||
if (!playerLoc.getWorld().equals(loc.getWorld()))
|
duration = DURATION;
|
||||||
return false;
|
radius = RADIUS;
|
||||||
if(playerLoc.distance(loc) <= fshield.radius)
|
discradius = DISC_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 progressAll() {
|
public void setDiscradius(double discradius) {
|
||||||
for (Player player : instances.keySet())
|
this.discradius = discradius;
|
||||||
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 setDuration(long duration) {
|
public void setDuration(long duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRadius() {
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRadius(double radius) {
|
public void setRadius(double radius) {
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDiscradius() {
|
public void setShield(boolean shield) {
|
||||||
return discradius;
|
this.shield = shield;
|
||||||
}
|
|
||||||
|
|
||||||
public void setDiscradius(double discradius) {
|
|
||||||
this.discradius = discradius;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,23 +11,21 @@ import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
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.Plantbending;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
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, Player> ignitedblocks = new ConcurrentHashMap<Block, Player>();
|
||||||
public static ConcurrentHashMap<Block, Long> ignitedtimes = new ConcurrentHashMap<Block, Long>();
|
public static ConcurrentHashMap<Block, Long> ignitedtimes = new ConcurrentHashMap<Block, Long>();
|
||||||
public static ConcurrentHashMap<LivingEntity, Player> ignitedentities = new ConcurrentHashMap<LivingEntity, Player>();
|
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 firedamage = 3;
|
||||||
public static int tickdamage = 2;
|
public static int tickdamage = 2;
|
||||||
|
|
||||||
private static int ID = Integer.MIN_VALUE;
|
|
||||||
private static double speed = 15;
|
private static double speed = 15;
|
||||||
private static long interval = (long) (1000. / speed);
|
private static long interval = (long) (1000. / speed);
|
||||||
private static long dissipateAfter = 400;
|
private static long dissipateAfter = 400;
|
||||||
|
@ -36,7 +34,6 @@ public class FireStream {
|
||||||
private Location origin;
|
private Location origin;
|
||||||
private Location location;
|
private Location location;
|
||||||
private Vector direction;
|
private Vector direction;
|
||||||
private int id;
|
|
||||||
private long time;
|
private long time;
|
||||||
private double range;
|
private double range;
|
||||||
|
|
||||||
|
@ -49,58 +46,28 @@ public class FireStream {
|
||||||
this.direction.setY(0);
|
this.direction.setY(0);
|
||||||
this.direction = this.direction.clone().normalize();
|
this.direction = this.direction.clone().normalize();
|
||||||
this.location = this.location.clone().add(this.direction);
|
this.location = this.location.clone().add(this.direction);
|
||||||
id = ID;
|
|
||||||
if (ID >= Integer.MAX_VALUE) {
|
|
||||||
ID = Integer.MIN_VALUE;
|
|
||||||
}
|
|
||||||
ID++;
|
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
instances.put(id, this);
|
//instances.put(id, this);
|
||||||
|
putInstance(player, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll() {
|
public static void dissipateAll() {
|
||||||
for (int ID : instances.keySet()) {
|
if (dissipateAfter != 0)
|
||||||
instances.get(ID).progress();
|
for (Block block : ignitedtimes.keySet()) {
|
||||||
}
|
if (block.getType() != Material.FIRE) {
|
||||||
}
|
remove(block);
|
||||||
|
} else {
|
||||||
private boolean progress() {
|
long time = ignitedtimes.get(block);
|
||||||
if (System.currentTimeMillis() - time >= interval) {
|
if (System.currentTimeMillis() > time + dissipateAfter) {
|
||||||
location = location.clone().add(direction);
|
block.setType(Material.AIR);
|
||||||
time = System.currentTimeMillis();
|
remove(block);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ignite(Block block) {
|
public static String getDescription() {
|
||||||
if (WaterMethods.isPlant(block)) {
|
return "This ability no longer exists.";
|
||||||
new Plantbending(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
block.setType(Material.FIRE);
|
|
||||||
ignitedblocks.put(block, this.player);
|
|
||||||
ignitedtimes.put(block, System.currentTimeMillis());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isIgnitable(Player player, Block block) {
|
public static boolean isIgnitable(Player player, Block block) {
|
||||||
|
@ -148,38 +115,6 @@ public class FireStream {
|
||||||
return false;
|
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) {
|
public static void remove(Block block) {
|
||||||
if (ignitedblocks.containsKey(block)) {
|
if (ignitedblocks.containsKey(block)) {
|
||||||
ignitedblocks.remove(block);
|
ignitedblocks.remove(block);
|
||||||
|
@ -187,20 +122,29 @@ public class FireStream {
|
||||||
if (ignitedtimes.containsKey(block)) {
|
if (ignitedtimes.containsKey(block)) {
|
||||||
ignitedtimes.remove(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) {
|
public static void removeAroundPoint(Location location, double radius) {
|
||||||
|
for (int id : getInstances(FireStream.class).keySet()) {
|
||||||
for (int id : instances.keySet()) {
|
FireStream stream = (FireStream) getInstances(FireStream.class).get(id);
|
||||||
FireStream stream = instances.get(id);
|
|
||||||
if (stream.location.getWorld().equals(location.getWorld()))
|
if (stream.location.getWorld().equals(location.getWorld()))
|
||||||
if (stream.location.distance(location) <= radius)
|
if (stream.location.distance(location) <= radius)
|
||||||
instances.remove(id);
|
stream.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstanceType getInstanceType() {
|
||||||
|
return InstanceType.MULTIPLE;
|
||||||
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
@ -209,6 +153,51 @@ public class FireStream {
|
||||||
return range;
|
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) {
|
public void setRange(double range) {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,28 +13,28 @@ import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
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.Ability.AvatarState;
|
||||||
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
|
import com.projectkorra.ProjectKorra.Utilities.ParticleEffect;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirMethods;
|
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 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 long interval = 25;
|
||||||
private static double radius = 1.5;
|
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 MAX_DAMAGE = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Damage");
|
||||||
private static double DAMAGE_RADIUS = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.DamageRadius");
|
private static double DAMAGE_RADIUS = config.get().getDouble("Abilities.Fire.FireBlast.Charged.DamageRadius");
|
||||||
private static double RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.Range");
|
private static double RANGE = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Range");
|
||||||
private static double POWER = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.Power");
|
private static double POWER = config.get().getDouble("Abilities.Fire.FireBlast.Charged.Power");
|
||||||
private static double fireticks = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Charged.FireTicks");
|
private static double fireticks = config.get().getDouble("Abilities.Fire.FireBlast.Charged.FireTicks");
|
||||||
|
|
||||||
private int id;
|
|
||||||
private double maxdamage = MAX_DAMAGE;
|
private double maxdamage = MAX_DAMAGE;
|
||||||
private double range = RANGE;
|
private double range = RANGE;
|
||||||
private double explosionradius = DAMAGE_RADIUS;
|
private double explosionradius = DAMAGE_RADIUS;
|
||||||
|
@ -47,16 +47,17 @@ public class Fireball {
|
||||||
private boolean launched = false;
|
private boolean launched = false;
|
||||||
private Player player;
|
private Player player;
|
||||||
private Location origin;
|
private Location origin;
|
||||||
public Location location;
|
private Location location;
|
||||||
private Vector direction;
|
private Vector direction;
|
||||||
private TNTPrimed explosion = null;
|
private TNTPrimed explosion = null;
|
||||||
|
|
||||||
public Fireball(Player player) {
|
public Fireball(Player player) {
|
||||||
|
reloadVariables();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
starttime = time;
|
starttime = time;
|
||||||
if (FireMethods.isDay(player.getWorld())) {
|
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)) {
|
if (AvatarState.isAvatarState(player)) {
|
||||||
chargetime = 0;
|
chargetime = 0;
|
||||||
|
@ -64,83 +65,29 @@ public class Fireball {
|
||||||
}
|
}
|
||||||
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
|
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
|
||||||
if (!player.getEyeLocation().getBlock().isLiquid()) {
|
if (!player.getEyeLocation().getBlock().isLiquid()) {
|
||||||
id = ID;
|
//instances.put(id, this);
|
||||||
instances.put(id, this);
|
putInstance(player, this);
|
||||||
if (ID == Integer.MAX_VALUE)
|
|
||||||
ID = Integer.MIN_VALUE;
|
|
||||||
ID++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void progress() {
|
public static boolean annihilateBlasts(Location location, double radius, Player source) {
|
||||||
if (GeneralMethods.getBoundAbility(player) == null) {
|
boolean broke = false;
|
||||||
remove();
|
for (Integer id : getInstances(Fireball.class).keySet()) {
|
||||||
return;
|
Fireball fireball = (Fireball) getInstances(Fireball.class).get(id);
|
||||||
}
|
if (!fireball.launched)
|
||||||
|
continue;
|
||||||
if (!GeneralMethods.canBend(player.getName(), "FireBlast") && !launched) {
|
Location fireblastlocation = fireball.location;
|
||||||
remove();
|
if (location.getWorld() == fireblastlocation.getWorld()
|
||||||
return;
|
&& !source.equals(fireball.player)) {
|
||||||
}
|
if (location.distance(fireblastlocation) <= radius) {
|
||||||
|
fireball.explode();
|
||||||
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") && !launched) {
|
broke = true;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
public static Fireball getFireball(Entity entity) {
|
||||||
|
@ -149,6 +96,29 @@ public class Fireball {
|
||||||
return null;
|
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) {
|
public void dealDamage(Entity entity) {
|
||||||
if (explosion == null)
|
if (explosion == null)
|
||||||
return;
|
return;
|
||||||
|
@ -170,37 +140,6 @@ public class Fireball {
|
||||||
AirMethods.breakBreathbendingHold(entity);
|
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() {
|
public void explode() {
|
||||||
// List<Block> blocks = Methods.getBlocksAroundPoint(location, 3);
|
// List<Block> blocks = Methods.getBlocksAroundPoint(location, 3);
|
||||||
// List<Block> blocks2 = new ArrayList<Block>();
|
// List<Block> blocks2 = new ArrayList<Block>();
|
||||||
|
@ -250,6 +189,61 @@ public class Fireball {
|
||||||
remove();
|
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) {
|
private void ignite(Location location) {
|
||||||
for (Block block : GeneralMethods.getBlocksAroundPoint(location, FireBlast.AFFECTING_RADIUS)) {
|
for (Block block : GeneralMethods.getBlocksAroundPoint(location, FireBlast.AFFECTING_RADIUS)) {
|
||||||
if (FireStream.isIgnitable(player, block)) {
|
if (FireStream.isIgnitable(player, block)) {
|
||||||
|
@ -262,103 +256,116 @@ public class Fireball {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll() {
|
@Override
|
||||||
for (int id : instances.keySet())
|
public boolean progress() {
|
||||||
instances.get(id).progress();
|
if (GeneralMethods.getBoundAbility(player) == null) {
|
||||||
}
|
remove();
|
||||||
|
return false;
|
||||||
private void remove() {
|
}
|
||||||
instances.remove(id);
|
|
||||||
}
|
if (!GeneralMethods.canBend(player.getName(), "FireBlast") && !launched) {
|
||||||
|
remove();
|
||||||
public static void removeAll() {
|
return false;
|
||||||
for (int id : instances.keySet())
|
}
|
||||||
instances.get(id).remove();
|
|
||||||
}
|
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") && !launched) {
|
||||||
|
remove();
|
||||||
public static void removeFireballsAroundPoint(Location location, double radius) {
|
return false;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if (System.currentTimeMillis() > starttime + chargetime) {
|
||||||
|
charged = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean annihilateBlasts(Location location, double radius, Player source) {
|
if (!player.isSneaking() && !charged) {
|
||||||
boolean broke = false;
|
new FireBlast(player);
|
||||||
for (int id : instances.keySet()) {
|
remove();
|
||||||
Fireball fireball = instances.get(id);
|
return false;
|
||||||
if (!fireball.launched)
|
}
|
||||||
continue;
|
|
||||||
Location fireblastlocation = fireball.location;
|
if (!player.isSneaking() && !launched) {
|
||||||
if (location.getWorld() == fireblastlocation.getWorld()
|
launched = true;
|
||||||
&& !source.equals(fireball.player)) {
|
location = player.getEyeLocation();
|
||||||
if (location.distance(fireblastlocation) <= radius) {
|
origin = location.clone();
|
||||||
fireball.explode();
|
direction = location.getDirection().normalize().multiply(radius);
|
||||||
broke = true;
|
}
|
||||||
|
|
||||||
|
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 true;
|
||||||
return broke;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxdamage() {
|
@Override
|
||||||
return maxdamage;
|
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) {
|
maxdamage = MAX_DAMAGE;
|
||||||
this.maxdamage = maxdamage;
|
range = RANGE;
|
||||||
}
|
explosionradius = DAMAGE_RADIUS;
|
||||||
|
power = POWER;
|
||||||
public double getRange() {
|
chargetime = defaultchargetime;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChargetime(long chargetime) {
|
public void setChargetime(long chargetime) {
|
||||||
this.chargetime = chargetime;
|
this.chargetime = chargetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public void setExplosionradius(double explosionradius) {
|
||||||
return player;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package com.projectkorra.ProjectKorra.firebending;
|
package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
@ -16,24 +15,24 @@ public class FirebendingManager implements Runnable {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
FirePassive.handlePassive();
|
FirePassive.handlePassive();
|
||||||
FireJet.progressAll();
|
FireJet.progressAll(FireJet.class);
|
||||||
Cook.progressAll();
|
Cook.progressAll(Cook.class);
|
||||||
Illumination.manage(Bukkit.getServer());
|
Illumination.progressAll(Illumination.class);
|
||||||
FireBlast.progressAll();
|
FireBlast.progressAll(FireBlast.class);
|
||||||
Fireball.progressAll();
|
Fireball.progressAll(Fireball.class);
|
||||||
FireBurst.progressAll();
|
FireBurst.progressAll(FireBurst.class);
|
||||||
FireShield.progressAll();
|
FireShield.progressAll(FireShield.class);
|
||||||
Lightning.progressAll();
|
Lightning.progressAll(Lightning.class);
|
||||||
WallOfFire.manage();
|
WallOfFire.progressAll(WallOfFire.class);
|
||||||
Combustion.progressAll();
|
Combustion.progressAll(Combustion.class);
|
||||||
for (Block block : FireStream.ignitedblocks.keySet()) {
|
for (Block block : FireStream.ignitedblocks.keySet()) {
|
||||||
if (block.getType() != Material.FIRE) {
|
if (block.getType() != Material.FIRE) {
|
||||||
FireStream.ignitedblocks.remove(block);
|
FireStream.ignitedblocks.remove(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HeatControl.progressAll();
|
HeatControl.progressAll(HeatControl.class);
|
||||||
FireStream.dissipateAll();
|
FireStream.dissipateAll();
|
||||||
FireStream.progressAll();
|
FireStream.progressAll(FireStream.class);
|
||||||
FireCombo.progressAll();
|
FireCombo.progressAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -12,24 +11,21 @@ import org.bukkit.entity.Player;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.TempBlock;
|
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.Utilities.ParticleEffect;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
|
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Carbogen on 11/02/15.
|
* Created by Carbogen on 11/02/15.
|
||||||
|
* Ability HeatControl
|
||||||
*/
|
*/
|
||||||
public class HeatControl
|
public class HeatControl extends CoreAbility {
|
||||||
{
|
public static double RANGE = config.get().getDouble("Abilities.Fire.HeatControl.Solidify.Range");
|
||||||
public static ConcurrentHashMap<Integer, HeatControl> instances = new ConcurrentHashMap<Integer, HeatControl>();
|
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");
|
||||||
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;
|
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private int id;
|
|
||||||
private int currentRadius = 1;
|
private int currentRadius = 1;
|
||||||
private long delay = 50;
|
private long delay = 50;
|
||||||
private long lastBlockTime = 0;
|
private long lastBlockTime = 0;
|
||||||
|
@ -41,33 +37,81 @@ public class HeatControl
|
||||||
public int radius = RADIUS;
|
public int radius = RADIUS;
|
||||||
public long revertTime = REVERT_TIME;
|
public long revertTime = REVERT_TIME;
|
||||||
|
|
||||||
public HeatControl(Player player)
|
public HeatControl(Player player) {
|
||||||
{
|
/* Initial Checks */
|
||||||
|
|
||||||
if (!isEligible(player))
|
if (!isEligible(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (EarthMethods.getLavaSourceBlock(player, getRange()) == null) {
|
||||||
if(EarthMethods.getLavaSourceBlock(player, getRange()) == null){
|
|
||||||
new Cook(player);
|
new Cook(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* End Initial Checks */
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
if(ID == Integer.MAX_VALUE - 1)
|
lastBlockTime = System.currentTimeMillis();
|
||||||
ID = 0;
|
|
||||||
|
|
||||||
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();
|
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"))
|
if (!GeneralMethods.canBend(player.getName(), "HeatControl"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -80,84 +124,28 @@ public class HeatControl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
public void particles(List<Location> area) {
|
||||||
public void freeze(List<Location> area)
|
if (System.currentTimeMillis() < lastParticleTime + 300)
|
||||||
{
|
|
||||||
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)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lastParticleTime = System.currentTimeMillis();
|
lastParticleTime = System.currentTimeMillis();
|
||||||
|
|
||||||
for(Location l : area)
|
for (Location l : area) {
|
||||||
{
|
if (EarthMethods.isLava(l.getBlock()))
|
||||||
if(EarthMethods.isLava(l.getBlock()))
|
|
||||||
ParticleEffect.SMOKE.display(l, 0, 0, 0, 0.1f, 2);
|
ParticleEffect.SMOKE.display(l, 0, 0, 0, 0.1f, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetLocation(Location loc)
|
@Override
|
||||||
{
|
public boolean progress() {
|
||||||
if(center == null)
|
if (!player.isOnline() || player.isDead() || !isEligible(player) || !player.isSneaking()) {
|
||||||
{
|
remove();
|
||||||
center = loc;
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!loc.equals(center))
|
if(currentRadius >= getRadius()) {
|
||||||
{
|
remove();
|
||||||
currentRadius = 1;
|
return false;
|
||||||
center = loc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void progress()
|
|
||||||
{
|
|
||||||
if(!player.isOnline() || player.isDead() || !isEligible(player) || !player.isSneaking())
|
|
||||||
{
|
|
||||||
stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentRadius >= getRadius())
|
|
||||||
{
|
|
||||||
stop();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Location targetlocation = GeneralMethods.getTargetedLocation(player, range);
|
Location targetlocation = GeneralMethods.getTargetedLocation(player, range);
|
||||||
|
@ -168,72 +156,58 @@ public class HeatControl
|
||||||
|
|
||||||
particles(area);
|
particles(area);
|
||||||
freeze(area);
|
freeze(area);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll()
|
@Override
|
||||||
{
|
public void reloadVariables() {
|
||||||
for(Integer id : instances.keySet())
|
RANGE = config.get().getDouble("Abilities.Fire.HeatControl.Solidify.Range");
|
||||||
{
|
RADIUS = config.get().getInt("Abilities.Fire.HeatControl.Solidify.Radius");
|
||||||
instances.get(id).progress();
|
REVERT_TIME = config.get().getInt("Abilities.Fire.HeatControl.Solidify.RevertTime");
|
||||||
}
|
range = RANGE;
|
||||||
|
radius = RADIUS;
|
||||||
|
revertTime = REVERT_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop()
|
@Override
|
||||||
{
|
public void remove() {
|
||||||
ProjectKorra.plugin.getServer().getScheduler().scheduleSyncDelayedTask(ProjectKorra.plugin, new Runnable()
|
final HeatControl ability = this;
|
||||||
{
|
ProjectKorra.plugin.getServer().getScheduler().scheduleSyncDelayedTask(ProjectKorra.plugin, new Runnable() {
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
revertAll();
|
revertAll();
|
||||||
if(instances.containsKey(id))
|
ability.remove();
|
||||||
instances.remove(id);
|
|
||||||
}
|
}
|
||||||
}, getRevertTime());
|
}, getRevertTime());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void revertAll()
|
public void resetLocation(Location loc) {
|
||||||
{
|
if(center == null) {
|
||||||
for(TempBlock tb : tblocks)
|
center = loc;
|
||||||
{
|
return;
|
||||||
tb.revertBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!loc.equals(center)) {
|
||||||
|
currentRadius = 1;
|
||||||
|
center = loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void revertAll() {
|
||||||
|
for (TempBlock tb : tblocks) {
|
||||||
|
tb.revertBlock();
|
||||||
|
}
|
||||||
tblocks.clear();
|
tblocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer()
|
public void setRadius(int value) {
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
radius = value;
|
radius = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRevertTime(long value)
|
public void setRange(double value) {
|
||||||
{
|
range = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRevertTime(long value) {
|
||||||
revertTime = value;
|
revertTime = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,17 @@ import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
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.Melt;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterMethods;
|
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 int range = config.get().getInt("Abilities.Fire.HeatControl.Melt.Range");
|
||||||
private static final int radius = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.HeatControl.Melt.Radius");
|
private static int radius = config.get().getInt("Abilities.Fire.HeatControl.Melt.Radius");
|
||||||
|
|
||||||
public HeatMelt(Player player) {
|
public HeatMelt(Player player) {
|
||||||
|
reloadVariables();
|
||||||
Location location = GeneralMethods.getTargetedLocation(player,
|
Location location = GeneralMethods.getTargetedLocation(player,
|
||||||
(int) FireMethods.getFirebendingDayAugment(range, player.getWorld()));
|
(int) FireMethods.getFirebendingDayAugment(range, player.getWorld()));
|
||||||
for (Block block : GeneralMethods.getBlocksAroundPoint(location,
|
for (Block block : GeneralMethods.getBlocksAroundPoint(location,
|
||||||
|
@ -39,4 +40,10 @@ public class HeatMelt {
|
||||||
private static boolean isHeatable(Block block) {
|
private static boolean isHeatable(Block block) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reloadVariables() {
|
||||||
|
config.get().getInt("Abilities.Fire.HeatControl.Melt.Range");
|
||||||
|
radius = config.get().getInt("Abilities.Fire.HeatControl.Melt.Radius");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,21 +3,20 @@ package com.projectkorra.ProjectKorra.firebending;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
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>();
|
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 Player player;
|
||||||
private Block block;
|
private Block block;
|
||||||
|
@ -25,21 +24,97 @@ public class Illumination {
|
||||||
private byte normaldata;
|
private byte normaldata;
|
||||||
|
|
||||||
public Illumination(Player player) {
|
public Illumination(Player player) {
|
||||||
|
/* Initial Checks */
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
|
||||||
if (bPlayer.isOnCooldown("Illumination")) return;
|
if (bPlayer.isOnCooldown("Illumination")) return;
|
||||||
|
/* End Initial Checks */
|
||||||
if (instances.containsKey(player)) {
|
|
||||||
instances.get(player).revert();
|
if (containsPlayer(player, Illumination.class)) {
|
||||||
instances.remove(player);
|
revert();
|
||||||
|
remove();
|
||||||
} else {
|
} else {
|
||||||
|
reloadVariables();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
set();
|
set();
|
||||||
instances.put(player, this);
|
//instances.put(player, this);
|
||||||
|
putInstance(player, this);
|
||||||
bPlayer.addCooldown("Illumination", GeneralMethods.getGlobalCooldown());
|
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")
|
@SuppressWarnings("deprecation")
|
||||||
private void set() {
|
private void set() {
|
||||||
Block standingblock = player.getLocation().getBlock();
|
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.";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,34 +18,31 @@ import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
|
import com.projectkorra.ProjectKorra.Ability.CoreAbility;
|
||||||
|
import com.projectkorra.ProjectKorra.Ability.StockAbilities;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
|
import com.projectkorra.ProjectKorra.earthbending.EarthMethods;
|
||||||
|
|
||||||
public class Lightning {
|
public class Lightning extends CoreAbility {
|
||||||
public static enum State {
|
public static boolean SELF_HIT_WATER = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitWater");
|
||||||
START, STRIKE, MAINBOLT
|
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>();
|
private Player player;
|
||||||
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 BendingPlayer bplayer;
|
private BendingPlayer bplayer;
|
||||||
private Location origin, destination;
|
private Location origin, destination;
|
||||||
private double range, chargeTime, cooldown, subArcChance, damage, chainArcs, chainRange, waterRange;
|
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 ArrayList<BukkitRunnable> tasks = new ArrayList<BukkitRunnable>();
|
||||||
private double i = 0.0D;
|
private double i = 0.0D;
|
||||||
private double newY;
|
private double newY;
|
||||||
|
|
||||||
public Lightning(Player player) {
|
public Lightning(Player player) {
|
||||||
|
reloadVariables();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
bplayer = GeneralMethods.getBendingPlayer(player.getName());
|
bplayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
charged = false;
|
charged = false;
|
||||||
|
@ -94,9 +92,186 @@ public class Lightning {
|
||||||
chargeTime = 0;
|
chargeTime = 0;
|
||||||
cooldown = 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.
|
/** Progresses the instance of this ability by 1 tick.
|
||||||
* This is the heart of the ability, it checks if it needs to
|
* This is the heart of the ability, it checks if it needs to
|
||||||
* remove itself, and handles the initial Lightning Arc generation.
|
* 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
|
* Once all of the arcs have been created then this ability instance
|
||||||
* gets removed, but the BukkitRunnables continue until they remove
|
* gets removed, but the BukkitRunnables continue until they remove
|
||||||
* themselves. **/
|
* themselves. **/
|
||||||
private void progress() {
|
@Override
|
||||||
|
public boolean progress() {
|
||||||
if (player.isDead() || !player.isOnline()) {
|
if (player.isDead() || !player.isOnline()) {
|
||||||
removeWithTasks();
|
removeWithTasks();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
else if (GeneralMethods.getBoundAbility(player) == null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Lightning")) {
|
else if (GeneralMethods.getBoundAbility(player) == null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Lightning")) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if(state == State.START) {
|
if(state == State.START) {
|
||||||
if(bplayer.isOnCooldown("Lightning")) {
|
if(bplayer.isOnCooldown("Lightning")) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - time > chargeTime)
|
if (System.currentTimeMillis() - time > chargeTime)
|
||||||
charged = true;
|
charged = true;
|
||||||
|
@ -142,7 +318,7 @@ public class Lightning {
|
||||||
else{
|
else{
|
||||||
if(!player.isSneaking()) {
|
if(!player.isSneaking()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
double d1 = 0.1570796326794897D;
|
double d1 = 0.1570796326794897D;
|
||||||
double d2 = 0.06283185307179587D;
|
double d2 = 0.06283185307179587D;
|
||||||
|
@ -197,61 +373,30 @@ public class Lightning {
|
||||||
}
|
}
|
||||||
if(tasks.size() == 0) {
|
if(tasks.size() == 0) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Checks if a block is transparent, also considers the ARC_ON_ICE config option.
|
public void reloadVariables() {
|
||||||
* @param player the player that is viewing the block
|
SELF_HIT_WATER = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitWater");
|
||||||
* @param block the block
|
SELF_HIT_CLOSE = config.get().getBoolean("Abilities.Fire.Lightning.SelfHitClose");
|
||||||
* @return true if the block is transparent
|
ARC_ON_ICE = config.get().getBoolean("Abilities.Fire.Lightning.ArcOnIce");
|
||||||
*/
|
RANGE = config.get().getDouble("Abilities.Fire.Lightning.Range");
|
||||||
@SuppressWarnings("deprecation")
|
DAMAGE = config.get().getDouble("Abilities.Fire.Lightning.Damage");
|
||||||
public boolean isTransparent(Player player, Block block) {
|
MAX_ARC_ANGLE = config.get().getDouble("Abilities.Fire.Lightning.MaxArcAngle");
|
||||||
if (Arrays.asList(EarthMethods.transparentToEarthbending).contains(block.getTypeId())) {
|
SUB_ARC_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.SubArcChance");
|
||||||
if(GeneralMethods.isRegionProtectedFromBuild(player, "Lightning", block.getLocation()))
|
CHAIN_ARC_RANGE = config.get().getDouble("Abilities.Fire.Lightning.ChainArcRange");
|
||||||
return false;
|
CHAIN_ARC_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.ChainArcChance");
|
||||||
else if(isIce(block.getLocation()))
|
WATER_ARC_RANGE = config.get().getDouble("Abilities.Fire.Lightning.WaterArcRange");
|
||||||
return ARC_ON_ICE;
|
STUN_CHANCE = config.get().getDouble("Abilities.Fire.Lightning.StunChance");
|
||||||
else
|
STUN_DURATION = config.get().getDouble("Abilities.Fire.Lightning.StunDuration");
|
||||||
return true;
|
MAX_CHAIN_ARCS = (int) config.get().getDouble("Abilities.Fire.Lightning.MaxChainArcs");
|
||||||
}
|
WATER_ARCS = (int) config.get().getDouble("Abilities.Fire.Lightning.WaterArcs");
|
||||||
return false;
|
CHARGETIME = (long) config.get().getDouble("Abilities.Fire.Lightning.ChargeTime");
|
||||||
}
|
COOLDOWN = (long) config.get().getDouble("Abilities.Fire.Lightning.Cooldown");
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,71 +409,97 @@ public class Lightning {
|
||||||
}
|
}
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setChainArcChance(double chainArcChance) {
|
||||||
* Removes this ability instance
|
this.chainArcChance = chainArcChance;
|
||||||
*/
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 setChainArcs(double chainArcs) {
|
||||||
* Checks if a location contains a water block
|
this.chainArcs = chainArcs;
|
||||||
* @param loc the location to check
|
}
|
||||||
* @return true if it is water
|
|
||||||
*/
|
public void setChainRange(double chainRange) {
|
||||||
public static boolean isWater(Location loc) {
|
this.chainRange = chainRange;
|
||||||
Material mat = loc.getBlock().getType();
|
}
|
||||||
return mat == Material.WATER || mat == Material.STATIONARY_WATER;
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Represents a Lightning Arc Point particle animation.
|
||||||
* Checks if a location is ice or water
|
* This basically just holds a location and counts the
|
||||||
* @param loc the location to check
|
* amount of times that a particle has been animated.
|
||||||
* @return true if it is water or ice
|
* **/
|
||||||
*/
|
public class AnimLocation {
|
||||||
public static boolean isWaterOrIce(Location loc) {
|
private Location loc;
|
||||||
return isIce(loc) || isWater(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.
|
/** An Arc represents a Lightning arc for the specific ability.
|
||||||
|
@ -354,6 +525,45 @@ public class Lightning {
|
||||||
animCounter = 0;
|
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,
|
/** Runs an arc generation algorithm by first creating two points,
|
||||||
* the starting point and the ending point. Next, it creates a point
|
* the starting point and the ending point. Next, it creates a point
|
||||||
* in the middle that has an offset relative to the beginning and
|
* 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.
|
public int getAnimCounter() {
|
||||||
* @param chance - The chance that an arc will be generated
|
return animCounter;
|
||||||
* 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 ArrayList<AnimLocation> getAnimLocs() {
|
||||||
* Stops this Arc from further animating or doing damage.
|
return animLocs;
|
||||||
*/
|
|
||||||
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 Vector getDirection() {
|
public Vector getDirection() {
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDirection(Vector direction) {
|
public ArrayList<LightningParticle> getParticles() {
|
||||||
this.direction = direction;
|
return particles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAnimCounter() {
|
public ArrayList<Location> getPoints() {
|
||||||
return animCounter;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAnimCounter(int animCounter) {
|
public void setAnimCounter(int animCounter) {
|
||||||
this.animCounter = animCounter;
|
this.animCounter = animCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<AnimLocation> getAnimLocs() {
|
|
||||||
return animLocs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAnimLocs(ArrayList<AnimLocation> animLocs) {
|
public void setAnimLocs(ArrayList<AnimLocation> animLocs) {
|
||||||
this.animLocs = animLocs;
|
this.animLocs = animLocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<LightningParticle> getParticles() {
|
public void setDirection(Vector direction) {
|
||||||
return particles;
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParticles(ArrayList<LightningParticle> particles) {
|
public void setParticles(ArrayList<LightningParticle> particles) {
|
||||||
this.particles = 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
|
/** A Runnable Particle that continuously displays itself
|
||||||
* until it reaches a certain time limit.
|
* until it reaches a certain time limit.
|
||||||
*
|
*
|
||||||
|
@ -600,140 +741,7 @@ public class Lightning {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Below are all of the accessor/mutator methods **/
|
public static enum State {
|
||||||
public Player getPlayer() {
|
START, STRIKE, MAINBOLT
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,17 +6,19 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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) {
|
public RingOfFire(Player player) {
|
||||||
|
/* Initial Checks */
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
if (bPlayer.isOnCooldown("Blaze")) return;
|
if (bPlayer.isOnCooldown("Blaze")) return;
|
||||||
|
/* End Initial Checks */
|
||||||
|
reloadVariables();
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
|
|
||||||
for (double degrees = 0; degrees < 360; degrees += 10) {
|
for (double degrees = 0; degrees < 360; degrees += 10) {
|
||||||
|
@ -49,4 +51,9 @@ public class RingOfFire {
|
||||||
+ "engulfing everything around you. Use with extreme caution.";
|
+ "engulfing everything around you. Use with extreme caution.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reloadVariables() {
|
||||||
|
defaultrange = config.get().getInt("Abilities.Fire.Blaze.RingOfFire.Range");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,12 +2,10 @@ package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -15,28 +13,27 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
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.Utilities.ParticleEffect;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirMethods;
|
import com.projectkorra.ProjectKorra.airbending.AirMethods;
|
||||||
|
|
||||||
public class WallOfFire {
|
public class WallOfFire extends CoreAbility {
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
private static double maxangle = 50;
|
private static double maxangle = 50;
|
||||||
|
|
||||||
public static FileConfiguration config = ProjectKorra.plugin.getConfig();
|
private static int RANGE = config.get().getInt("Abilities.Fire.WallOfFire.Range");
|
||||||
private static int RANGE = config.getInt("Abilities.Fire.WallOfFire.Range");
|
private static int HEIGHT = config.get().getInt("Abilities.Fire.WallOfFire.Height");
|
||||||
private int HEIGHT = config.getInt("Abilities.Fire.WallOfFire.Height");
|
private static int WIDTH = config.get().getInt("Abilities.Fire.WallOfFire.Width");
|
||||||
private int WIDTH = config.getInt("Abilities.Fire.WallOfFire.Width");
|
private static long DURATION = config.get().getLong("Abilities.Fire.WallOfFire.Duration");
|
||||||
private long DURATION = config.getLong("Abilities.Fire.WallOfFire.Duration");
|
private static int DAMAGE = config.get().getInt("Abilities.Fire.WallOfFire.Damage");
|
||||||
private int DAMAGE = config.getInt("Abilities.Fire.WallOfFire.Damage");
|
|
||||||
private static long interval = 250;
|
private static long interval = 250;
|
||||||
private static long COOLDOWN = config.getLong("Abilities.Fire.WallOfFire.Cooldown");
|
private static long COOLDOWN = config.get().getLong("Abilities.Fire.WallOfFire.Cooldown");
|
||||||
public static ConcurrentHashMap<Player, WallOfFire> instances = new ConcurrentHashMap<Player, WallOfFire>();
|
private static long DAMAGE_INTERVAL = config.get().getLong("Abilities.Fire.WallOfFire.Interval");
|
||||||
private static long DAMAGE_INTERVAL = config.getLong("Abilities.Fire.WallOfFire.Interval");
|
private static double FIRETICKS = config.get().getDouble("Abilities.Fire.WallOfFire.FireTicks");
|
||||||
private static double fireticks = config.getDouble("Abilities.Fire.WallOfFire.FireTicks");
|
|
||||||
|
|
||||||
private Location origin;
|
private Location origin;
|
||||||
private long time, starttime;
|
private long time, starttime;
|
||||||
|
@ -52,13 +49,13 @@ public class WallOfFire {
|
||||||
private List<Block> blocks = new ArrayList<Block>();
|
private List<Block> blocks = new ArrayList<Block>();
|
||||||
|
|
||||||
public WallOfFire(Player player) {
|
public WallOfFire(Player player) {
|
||||||
if (instances.containsKey(player) && !AvatarState.isAvatarState(player)) {
|
/* Initial Checks */
|
||||||
|
if (containsPlayer(player, WallOfFire.class) && !AvatarState.isAvatarState(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
|
|
||||||
if (bPlayer.isOnCooldown("WallOfFire")) return;
|
if (bPlayer.isOnCooldown("WallOfFire")) return;
|
||||||
|
/* End Initial Checks */
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
|
@ -93,24 +90,26 @@ public class WallOfFire {
|
||||||
|
|
||||||
initializeBlocks();
|
initializeBlocks();
|
||||||
|
|
||||||
instances.put(player, this);
|
//instances.put(player, this);
|
||||||
|
putInstance(player, this);
|
||||||
bPlayer.addCooldown("WallOfFire", cooldown);
|
bPlayer.addCooldown("WallOfFire", cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void progress() {
|
@Override
|
||||||
|
public boolean progress() {
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
|
|
||||||
if (time - starttime > cooldown) {
|
if (time - starttime > cooldown) {
|
||||||
instances.remove(player);
|
remove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!active)
|
if (!active)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (time - starttime > duration) {
|
if (time - starttime > duration) {
|
||||||
active = false;
|
active = false;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time - starttime > intervaltick * interval) {
|
if (time - starttime > intervaltick * interval) {
|
||||||
|
@ -122,7 +121,7 @@ public class WallOfFire {
|
||||||
damagetick++;
|
damagetick++;
|
||||||
damage();
|
damage();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeBlocks() {
|
private void initializeBlocks() {
|
||||||
|
@ -187,7 +186,7 @@ public class WallOfFire {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void affect(Entity entity) {
|
private void affect(Entity entity) {
|
||||||
entity.setFireTicks((int) (fireticks * 20));
|
entity.setFireTicks((int) (FIRETICKS * 20));
|
||||||
GeneralMethods.setVelocity(entity, new Vector(0, 0, 0));
|
GeneralMethods.setVelocity(entity, new Vector(0, 0, 0));
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
GeneralMethods.damageEntity(player, entity, damage);
|
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() {
|
public Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +245,7 @@ public class WallOfFire {
|
||||||
|
|
||||||
public void setCooldown(long cooldown) {
|
public void setCooldown(long cooldown) {
|
||||||
this.cooldown = cooldown;
|
this.cooldown = cooldown;
|
||||||
if(player != null)
|
if (player != null)
|
||||||
GeneralMethods.getBendingPlayer(player.getName()).addCooldown("WallOfFire", cooldown);
|
GeneralMethods.getBendingPlayer(player.getName()).addCooldown("WallOfFire", cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,4 +256,28 @@ public class WallOfFire {
|
||||||
public void setDamageinterval(long damageinterval) {
|
public void setDamageinterval(long damageinterval) {
|
||||||
this.damageinterval = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -377,8 +377,8 @@ public class WaterArms {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIfZapped() {
|
private void checkIfZapped() {
|
||||||
for (int i = 0; i < Lightning.instances.size(); i++) {
|
for (Integer id : Lightning.getInstances(Lightning.class).keySet()) {
|
||||||
Lightning l = Lightning.instances.get(i);
|
Lightning l = (Lightning) Lightning.getInstances(Lightning.class).get(id);
|
||||||
for (Lightning.Arc arc : l.getArcs()) {
|
for (Lightning.Arc arc : l.getArcs()) {
|
||||||
for (Block arm : revert.keySet()) {
|
for (Block arm : revert.keySet()) {
|
||||||
for (Location loc : arc.getPoints()) {
|
for (Location loc : arc.getPoints()) {
|
||||||
|
@ -388,11 +388,9 @@ public class WaterArms {
|
||||||
arm.getLocation(), 1.25))
|
arm.getLocation(), 1.25))
|
||||||
FireMethods.playLightningbendingParticle(l1);
|
FireMethods.playLightningbendingParticle(l1);
|
||||||
if (lightningKill)
|
if (lightningKill)
|
||||||
GeneralMethods.damageEntity(Lightning.instances
|
GeneralMethods.damageEntity(l.getPlayer(), player, 60D);
|
||||||
.get(i).getPlayer(), player, 60D);
|
|
||||||
else
|
else
|
||||||
GeneralMethods.damageEntity(Lightning.instances
|
GeneralMethods.damageEntity(l.getPlayer(), player,
|
||||||
.get(i).getPlayer(), player,
|
|
||||||
lightningDamage);
|
lightningDamage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue