mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 03:30:10 +00:00
Merge pull request #213 from nathank33/master
Efficiency Improvements, EarthSmash Fix, Fire Revert Fix
This commit is contained in:
commit
9102fd7fc2
5 changed files with 319 additions and 327 deletions
|
@ -21,16 +21,15 @@ 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
|
||||
* access this HashMap use either {@link #getInstance()} from the ability
|
||||
* instance or {@link #getInstance(StockAbility)} from the outside.
|
||||
*/
|
||||
//private static ConcurrentHashMap<StockAbility, 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<StockAbility, ArrayList<Integer>> abilityMap = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<Integer, CoreAbility> instances = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<StockAbility, ArrayList<Integer>> abilityMap = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<Class<? extends CoreAbility>, ConcurrentHashMap<Integer, CoreAbility>> classAbilityMap = new ConcurrentHashMap<>();
|
||||
|
||||
private static int ID = Integer.MIN_VALUE;
|
||||
|
||||
private final StockAbility stockAbility = getStockAbility();
|
||||
private Player player;
|
||||
private UUID uniqueId;
|
||||
|
@ -45,20 +44,7 @@ public abstract class CoreAbility implements Ability {
|
|||
*/
|
||||
public static final boolean containsPlayer(Player player, Class<? extends CoreAbility> ability) {
|
||||
CoreAbility coreAbility = getAbilityFromPlayer(player, ability);
|
||||
if (coreAbility != null) {
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
List<CoreAbility> abilities = getAbilitiesFromPlayer(player);
|
||||
for (CoreAbility coreAbility : abilities) {
|
||||
if (ability.isInstance(coreAbility)) {
|
||||
if (coreAbility.getPlayer().getUniqueId().equals(player.getUniqueId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
return coreAbility != null ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +80,7 @@ public abstract class CoreAbility implements Ability {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the ability instance by its id.
|
||||
*
|
||||
|
@ -108,8 +94,8 @@ public abstract class CoreAbility implements Ability {
|
|||
/**
|
||||
* An access method to get an the instances of a {@link StockAbility}.
|
||||
* <b>IMPORTANT: </b> If this is used in a for each loop use
|
||||
* {@link #getAbility(int)} to get the ability. Incorrect usage may
|
||||
* cause over looping and is capable of hanging the thead.
|
||||
* {@link #getAbility(int)} to get the ability. Incorrect usage may cause
|
||||
* over looping and is capable of hanging the thead.
|
||||
*
|
||||
* @param ability The instances map to get
|
||||
* @return a map of instances from the specified {@link StockAbility}
|
||||
|
@ -128,21 +114,16 @@ public abstract class CoreAbility implements Ability {
|
|||
/**
|
||||
* An access method to get an the instances of a {@link CoreAbility} by its
|
||||
* class. <b>IMPORTANT: </b> If this is used in a for each loop use
|
||||
* {@link #getAbility(int)} to get the ability. Incorrect usage may
|
||||
* cause over looping and is capable of hanging the thead.
|
||||
* {@link #getAbility(int)} to get the ability. Incorrect usage may cause
|
||||
* over looping and is capable of hanging the thead.
|
||||
*
|
||||
* @param ability The instances map to get
|
||||
* @return a map of instances from the specified class
|
||||
* @see #getInstances(StockAbility)
|
||||
*/
|
||||
public final static ConcurrentHashMap<Integer, CoreAbility> getInstances(Class<? extends CoreAbility> ability) {
|
||||
ConcurrentHashMap<Integer, CoreAbility> instanceMap = new ConcurrentHashMap<>();
|
||||
for (Integer id : instances.keySet()) {
|
||||
if (ability.isInstance(instances.get(id))) {
|
||||
instanceMap.put(id, instances.get(id));
|
||||
}
|
||||
}
|
||||
return instanceMap;
|
||||
ConcurrentHashMap<Integer, CoreAbility> instanceMap = classAbilityMap.get(ability.getClass());
|
||||
return instanceMap != null ? instanceMap : new ConcurrentHashMap<Integer, CoreAbility>();
|
||||
}
|
||||
|
||||
//TODO: Update bending managers to use bellow method
|
||||
|
@ -165,9 +146,10 @@ public abstract class CoreAbility implements Ability {
|
|||
* @see #progressAll(StockAbility)
|
||||
*/
|
||||
public static void progressAll(Class<? extends CoreAbility> ability) {
|
||||
for (Integer id : instances.keySet()) {
|
||||
if (ability.isInstance(instances.get(id))) {
|
||||
instances.get(id).progress();
|
||||
ConcurrentHashMap<Integer, CoreAbility> classAbilities = classAbilityMap.get(ability);
|
||||
if (classAbilities != null) {
|
||||
for (Integer id : classAbilities.keySet()) {
|
||||
classAbilities.get(id).progress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,10 +211,7 @@ public abstract class CoreAbility implements Ability {
|
|||
* @return true if ability is a stock ability
|
||||
*/
|
||||
public boolean isStockAbility() {
|
||||
if (getStockAbility() == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return getStockAbility() != null ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,7 +277,14 @@ public abstract class CoreAbility implements Ability {
|
|||
this.id = ID;
|
||||
this.uniqueId = player.getUniqueId();
|
||||
this.player = player;
|
||||
Class<? extends CoreAbility> classKey = ability.getClass();
|
||||
|
||||
if (!classAbilityMap.containsKey(classKey)) {
|
||||
classAbilityMap.put(classKey, new ConcurrentHashMap<Integer, CoreAbility>());
|
||||
}
|
||||
classAbilityMap.get(classKey).put(id, ability);
|
||||
instances.put(id, ability);
|
||||
|
||||
if (stockAbility != null) {
|
||||
if (abilityMap.containsKey(stockAbility)) {
|
||||
abilityMap.get(stockAbility).add(id);
|
||||
|
@ -306,6 +292,7 @@ public abstract class CoreAbility implements Ability {
|
|||
abilityMap.put(stockAbility, new ArrayList<Integer>(Arrays.asList(id)));
|
||||
}
|
||||
}
|
||||
|
||||
if (ID == Integer.MAX_VALUE)
|
||||
ID = Integer.MIN_VALUE;
|
||||
ID++;
|
||||
|
@ -329,6 +316,11 @@ public abstract class CoreAbility implements Ability {
|
|||
if (instances.containsKey(id)) {
|
||||
instances.remove(id);
|
||||
}
|
||||
|
||||
if (classAbilityMap.containsKey(this.getClass())) {
|
||||
classAbilityMap.get(this.getClass()).remove(id);
|
||||
}
|
||||
|
||||
if (stockAbility != null) {
|
||||
if (abilityMap.containsKey(stockAbility)) {
|
||||
abilityMap.get(stockAbility).remove(id);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class ComboManager {
|
|||
comboAbilityList.add(new ComboAbility("FireKick", fireKick, FireCombo.class));
|
||||
descriptions.put("FireKick", "A short ranged arc of fire launches from the player's feet dealing moderate damage to enemies.");
|
||||
instructions.put("FireKick", "FireBlast > FireBlast > (Hold Shift) > FireBlast.");
|
||||
|
||||
|
||||
ArrayList<AbilityInformation> fireSpin = new ArrayList<AbilityInformation>();
|
||||
fireSpin.add(new AbilityInformation("FireBlast", ClickType.LEFT_CLICK));
|
||||
fireSpin.add(new AbilityInformation("FireBlast", ClickType.LEFT_CLICK));
|
||||
|
@ -45,7 +45,7 @@ public class ComboManager {
|
|||
comboAbilityList.add(new ComboAbility("FireSpin", fireSpin, FireCombo.class));
|
||||
descriptions.put("FireSpin", "A circular array of fire that causes damage and massive knockback to nearby enemies.");
|
||||
instructions.put("FireSpin", "FireBlast > FireBlast > FireShield > (Tap Shift).");
|
||||
|
||||
|
||||
ArrayList<AbilityInformation> jetBlast = new ArrayList<AbilityInformation>();
|
||||
jetBlast.add(new AbilityInformation("FireJet", ClickType.SHIFT_DOWN));
|
||||
jetBlast.add(new AbilityInformation("FireJet", ClickType.SHIFT_UP));
|
||||
|
@ -57,7 +57,7 @@ public class ComboManager {
|
|||
comboAbilityList.add(new ComboAbility("JetBlast", jetBlast, FireCombo.class));
|
||||
descriptions.put("JetBlast", "Create an explosive blast that propels your FireJet at higher speeds.");
|
||||
instructions.put("JetBlast", "FireJet (Tap Shift) > FireJet (Tap Shift) > FireShield (Tap Shift) > FireJet.");
|
||||
|
||||
|
||||
ArrayList<AbilityInformation> jetBlaze = new ArrayList<AbilityInformation>();
|
||||
jetBlaze.add(new AbilityInformation("FireJet", ClickType.SHIFT_DOWN));
|
||||
jetBlaze.add(new AbilityInformation("FireJet", ClickType.SHIFT_UP));
|
||||
|
@ -69,7 +69,7 @@ public class ComboManager {
|
|||
comboAbilityList.add(new ComboAbility("JetBlaze", jetBlaze, FireCombo.class));
|
||||
descriptions.put("JetBlaze", "Damages and burns all enemies in the proximity of your FireJet.");
|
||||
instructions.put("JetBlaze", "FireJet (Tap Shift) > FireJet (Tap Shift) > Blaze (Tap Shift) > FireJet.");
|
||||
|
||||
|
||||
ArrayList<AbilityInformation> fireWheel = new ArrayList<AbilityInformation>();
|
||||
fireWheel.add(new AbilityInformation("FireShield", ClickType.SHIFT_DOWN));
|
||||
fireWheel.add(new AbilityInformation("FireShield", ClickType.RIGHT_CLICK));
|
||||
|
@ -78,7 +78,7 @@ public class ComboManager {
|
|||
comboAbilityList.add(new ComboAbility("FireWheel", fireWheel, FireCombo.class));
|
||||
descriptions.put("FireWheel", "A high-speed wheel of fire that travels along the ground for long distances dealing high damage.");
|
||||
instructions.put("FireWheel", "FireShield (Hold Shift) > Right Click a block in front of you twice > Switch to Blaze > Release Shift.");
|
||||
|
||||
|
||||
ArrayList<AbilityInformation> twister = new ArrayList<AbilityInformation>();
|
||||
twister.add(new AbilityInformation("AirShield", ClickType.SHIFT_DOWN));
|
||||
twister.add(new AbilityInformation("AirShield", ClickType.SHIFT_UP));
|
||||
|
@ -87,7 +87,7 @@ public class ComboManager {
|
|||
comboAbilityList.add(new ComboAbility("Twister", twister, AirCombo.class));
|
||||
descriptions.put("Twister", "Create a cyclone of air that travels along the ground grabbing nearby entities.");
|
||||
instructions.put("Twister", "AirShield (Tap Shift) > Tornado (Hold Shift) > AirBlast (Left Click)");
|
||||
|
||||
|
||||
ArrayList<AbilityInformation> airStream = new ArrayList<AbilityInformation>();
|
||||
airStream.add(new AbilityInformation("AirShield", ClickType.SHIFT_DOWN));
|
||||
airStream.add(new AbilityInformation("AirSuction", ClickType.LEFT_CLICK));
|
||||
|
@ -95,7 +95,7 @@ public class ComboManager {
|
|||
comboAbilityList.add(new ComboAbility("AirStream", airStream, AirCombo.class));
|
||||
descriptions.put("AirStream", "Control a large stream of air that grabs onto enemies allowing you to direct them temporarily.");
|
||||
instructions.put("AirStream", "AirShield (Hold Shift) > AirSuction (Left Click) > AirBlast (Left Click)");
|
||||
|
||||
|
||||
/*
|
||||
* ArrayList<AbilityInformation> airSlice = new
|
||||
* ArrayList<AbilityInformation>(); airSlice.add(new
|
||||
|
@ -115,19 +115,24 @@ public class ComboManager {
|
|||
comboAbilityList.add(new ComboAbility("AirSweep", airSweep, AirCombo.class));
|
||||
descriptions.put("AirSweep", "Sweep the air in front of you hitting multiple enemies, causing moderate damage and a large knockback. The radius and direction of AirSweep is controlled by moving your mouse in a sweeping motion. For example, if you want to AirSweep upward, then move your mouse upward right after you left click AirBurst");
|
||||
instructions.put("AirSweep", "AirSwipe (Left Click) > AirSwipe (Left Click) > AirBurst (Hold Shift) > AirBurst (Left Click)");
|
||||
|
||||
|
||||
ArrayList<AbilityInformation> iceWave = new ArrayList<AbilityInformation>();
|
||||
iceWave.add(new AbilityInformation("WaterSpout", ClickType.SHIFT_UP));
|
||||
iceWave.add(new AbilityInformation("PhaseChange", ClickType.LEFT_CLICK));
|
||||
comboAbilityList.add(new ComboAbility("IceWave", iceWave, WaterCombo.class));
|
||||
descriptions.put("IceWave", "PhaseChange your WaterWave into an IceWave that freezes and damages enemies.");
|
||||
instructions.put("IceWave", "Create a WaterSpout Wave > PhaseChange (Left Click)");
|
||||
|
||||
/*ArrayList<AbilityInformation> icePillar = new ArrayList<AbilityInformation>();
|
||||
icePillar.add(new AbilityInformation("IceSpike", ClickType.LEFT_CLICK));
|
||||
icePillar.add(new AbilityInformation("IceSpike", ClickType.LEFT_CLICK));
|
||||
icePillar.add(new AbilityInformation("WaterSpout", ClickType.LEFT_CLICK));
|
||||
comboAbilityList.add(new ComboAbility("IcePillar", icePillar, WaterCombo.class));*/
|
||||
instructions.put("IceWave", "Create a WaterSpout Wave > PhaseChange (Left Click)");
|
||||
|
||||
/*
|
||||
* ArrayList<AbilityInformation> icePillar = new
|
||||
* ArrayList<AbilityInformation>(); icePillar.add(new
|
||||
* AbilityInformation("IceSpike", ClickType.LEFT_CLICK));
|
||||
* icePillar.add(new AbilityInformation("IceSpike",
|
||||
* ClickType.LEFT_CLICK)); icePillar.add(new
|
||||
* AbilityInformation("WaterSpout", ClickType.LEFT_CLICK));
|
||||
* comboAbilityList.add(new ComboAbility("IcePillar", icePillar,
|
||||
* WaterCombo.class));
|
||||
*/
|
||||
|
||||
ArrayList<AbilityInformation> iceBullet = new ArrayList<AbilityInformation>();
|
||||
iceBullet.add(new AbilityInformation("WaterBubble", ClickType.SHIFT_DOWN));
|
||||
|
@ -136,8 +141,8 @@ public class ComboManager {
|
|||
iceBullet.add(new AbilityInformation("IceBlast", ClickType.LEFT_CLICK));
|
||||
comboAbilityList.add(new ComboAbility("IceBullet", iceBullet, WaterCombo.class));
|
||||
descriptions.put("IceBullet", "Using a large cavern of ice, you can punch ice shards at your opponent causing moderate damage. To rapid fire, you must alternate between Left clicking and right clicking with IceBlast.");
|
||||
instructions.put("IceBullet", "WaterBubble (Tap Shift) > IceBlast (Hold Shift) > IceBlast (Left Click) > Wait for ice to Form > Then alternate between Left and Right click with IceBlast");
|
||||
|
||||
instructions.put("IceBullet", "WaterBubble (Tap Shift) > IceBlast (Hold Shift) > IceBlast (Left Click) > Wait for ice to Form > Then alternate between Left and Right click with IceBlast");
|
||||
|
||||
ArrayList<AbilityInformation> iceBulletLeft = new ArrayList<AbilityInformation>();
|
||||
iceBulletLeft.add(new AbilityInformation("IceBlast", ClickType.LEFT_CLICK));
|
||||
comboAbilityList.add(new ComboAbility("IceBulletLeftClick", iceBulletLeft, WaterCombo.class));
|
||||
|
@ -219,18 +224,18 @@ public class ComboManager {
|
|||
Enumeration<String> keys = recentlyUsedAbilities.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String name = keys.nextElement();
|
||||
ArrayList<AbilityInformation> combos = recentlyUsedAbilities.get(name);
|
||||
ArrayList<AbilityInformation> usedAbilities = recentlyUsedAbilities.get(name);
|
||||
ArrayList<AbilityInformation> stillValidAbilities = new ArrayList<AbilityInformation>();
|
||||
recentlyUsedAbilities.remove(name);
|
||||
for (int i = 0; i < combos.size(); i++) {
|
||||
AbilityInformation info = combos.get(i);
|
||||
if (System.currentTimeMillis() - info.getTime() > CLEANUP_DELAY) {
|
||||
combos.remove(i);
|
||||
i--;
|
||||
|
||||
for (AbilityInformation info : usedAbilities) {
|
||||
if (System.currentTimeMillis() - info.getTime() <= CLEANUP_DELAY) {
|
||||
stillValidAbilities.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
if (combos.size() > 0)
|
||||
recentlyUsedAbilities.put(name, combos);
|
||||
if (stillValidAbilities.size() > 0)
|
||||
recentlyUsedAbilities.put(name, stillValidAbilities);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,11 +253,12 @@ public class ComboManager {
|
|||
tempList.add(0, list.get(list.size() - 1 - i));
|
||||
return tempList;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<String> getCombosForElement(Element element) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (ComboAbility comboab : comboAbilityList) {
|
||||
if (GeneralMethods.getComboElement(comboab.getName()) == element && descriptions.containsKey(comboab.getName())) list.add(comboab.getName());
|
||||
if (GeneralMethods.getComboElement(comboab.getName()) == element && descriptions.containsKey(comboab.getName()))
|
||||
list.add(comboab.getName());
|
||||
}
|
||||
Collections.sort(list);
|
||||
return list;
|
||||
|
@ -263,7 +269,7 @@ public class ComboManager {
|
|||
public void run() {
|
||||
cleanupOldCombos();
|
||||
}
|
||||
}.runTaskTimer(ProjectKorra.plugin, 0, CLEANUP_DELAY);
|
||||
}.runTaskTimer(ProjectKorra.plugin, 0, CLEANUP_DELAY / 1000 * 20);
|
||||
}
|
||||
|
||||
public static class AbilityInformation {
|
||||
|
|
|
@ -43,7 +43,7 @@ public class EarthSmash {
|
|||
public static long MAIN_COOLDOWN = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.EarthSmash.Cooldown");
|
||||
public static long FLYING_REMOVE_TIMER = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.EarthSmash.FlightTimer");
|
||||
public static long REMOVE_TIMER = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.EarthSmash.RemoveTimer");
|
||||
|
||||
|
||||
private static int REQUIRED_BENDABLE_BLOCKS = 11;
|
||||
private static int MAX_BLOCKS_TO_PASS_THROUGH = 3;
|
||||
private static double GRAB_DETECTION_RADIUS = 2.5;
|
||||
|
@ -51,7 +51,7 @@ public class EarthSmash {
|
|||
private static long SHOOTING_ANIMATION_COOLDOWN = 25;
|
||||
private static long FLYING_ANIMATION_COOLDOWN = 0;
|
||||
private static long LIFT_ANIMATION_COOLDOWN = 30;
|
||||
|
||||
|
||||
private Player player;
|
||||
private BendingPlayer bplayer;
|
||||
private Block origin;
|
||||
|
@ -64,16 +64,16 @@ public class EarthSmash {
|
|||
private ArrayList<Entity> affectedEntities = new ArrayList<Entity>();
|
||||
private ArrayList<BlockRepresenter> currentBlocks = new ArrayList<BlockRepresenter>();
|
||||
private ArrayList<TempBlock> affectedBlocks = new ArrayList<TempBlock>();
|
||||
|
||||
|
||||
public EarthSmash(Player player, ClickType type) {
|
||||
if(!GeneralMethods.hasPermission(player, "EarthSmash"))
|
||||
if (!GeneralMethods.hasPermission(player, "EarthSmash"))
|
||||
return;
|
||||
|
||||
|
||||
this.player = player;
|
||||
bplayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||
this.time = System.currentTimeMillis();
|
||||
|
||||
if(type == ClickType.SHIFT_DOWN || type == ClickType.SHIFT_UP && !player.isSneaking()) {
|
||||
|
||||
if (type == ClickType.SHIFT_DOWN || type == ClickType.SHIFT_UP && !player.isSneaking()) {
|
||||
grabRange = GRAB_RANGE;
|
||||
chargeTime = CHARGE_TIME;
|
||||
cooldown = MAIN_COOLDOWN;
|
||||
|
@ -83,9 +83,9 @@ public class EarthSmash {
|
|||
flySpeed = FLYING_PLAYER_SPEED;
|
||||
flightRemove = FLYING_REMOVE_TIMER;
|
||||
shootRange = TRAVEL_RANGE;
|
||||
if(AvatarState.isAvatarState(player)) {
|
||||
if (AvatarState.isAvatarState(player)) {
|
||||
grabRange = AvatarState.getValue(grabRange);
|
||||
chargeTime = AvatarState.getValue(chargeTime);
|
||||
chargeTime = 0;
|
||||
cooldown = 0;
|
||||
damage = AvatarState.getValue(damage);
|
||||
knockback = AvatarState.getValue(knockback);
|
||||
|
@ -94,15 +94,15 @@ public class EarthSmash {
|
|||
flightRemove = Integer.MAX_VALUE;
|
||||
shootRange = AvatarState.getValue(shootRange);
|
||||
}
|
||||
|
||||
|
||||
EarthSmash flySmash = flyingInSmashCheck(player);
|
||||
if(flySmash != null) {
|
||||
if (flySmash != null) {
|
||||
flySmash.state = State.FLYING;
|
||||
flySmash.player = player;
|
||||
flySmash.flightStart = System.currentTimeMillis();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
EarthSmash grabbedSmash = aimingAtSmashCheck(player, State.LIFTED);
|
||||
if (grabbedSmash == null) {
|
||||
if (bplayer.isOnCooldown("EarthSmash")) {
|
||||
|
@ -110,106 +110,94 @@ public class EarthSmash {
|
|||
}
|
||||
grabbedSmash = aimingAtSmashCheck(player, State.SHOT);
|
||||
}
|
||||
if(grabbedSmash != null) {
|
||||
if (grabbedSmash != null) {
|
||||
grabbedSmash.state = State.GRABBED;
|
||||
grabbedSmash.grabbedRange = grabbedSmash.loc.distance(player.getEyeLocation());
|
||||
grabbedSmash.player = player;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(type == ClickType.LEFT_CLICK && player.isSneaking()) {
|
||||
for(EarthSmash smash : instances) {
|
||||
if(smash.state == State.GRABBED && smash.player == player) {
|
||||
} else if (type == ClickType.LEFT_CLICK && player.isSneaking()) {
|
||||
for (EarthSmash smash : instances) {
|
||||
if (smash.state == State.GRABBED && smash.player == player) {
|
||||
smash.state = State.SHOT;
|
||||
smash.destination = player.getEyeLocation().clone().add
|
||||
(player.getEyeLocation().getDirection().normalize().multiply(smash.shootRange));
|
||||
smash.destination = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(smash.shootRange));
|
||||
smash.loc.getWorld().playEffect(smash.loc, Effect.GHAST_SHOOT, 0, 10);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(type == ClickType.RIGHT_CLICK && player.isSneaking()) {
|
||||
} else if (type == ClickType.RIGHT_CLICK && player.isSneaking()) {
|
||||
EarthSmash grabbedSmash = aimingAtSmashCheck(player, State.GRABBED);
|
||||
if(grabbedSmash != null) {
|
||||
if (grabbedSmash != null) {
|
||||
player.teleport(grabbedSmash.loc.clone().add(0, 2, 0));
|
||||
grabbedSmash.state = State.FLYING;
|
||||
grabbedSmash.player = player;
|
||||
grabbedSmash.flightStart = System.currentTimeMillis();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
instances.add(this);
|
||||
}
|
||||
|
||||
|
||||
public void progress() {
|
||||
progressCounter++;
|
||||
if(state == State.LIFTED && REMOVE_TIMER > 0 && System.currentTimeMillis() - time > REMOVE_TIMER) {
|
||||
if (state == State.LIFTED && REMOVE_TIMER > 0 && System.currentTimeMillis() - time > REMOVE_TIMER) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
if(state == State.START || state == State.FLYING || state == State.GRABBED) {
|
||||
if(player.isDead() || !player.isOnline()) {
|
||||
if (state == State.START || state == State.FLYING || state == State.GRABBED) {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(state == State.START) {
|
||||
} else if (state == State.START) {
|
||||
String ability = GeneralMethods.getBoundAbility(player);
|
||||
if(ability == null || !ability.equalsIgnoreCase("EarthSmash") || bplayer.isOnCooldown("EarthSmash")) {
|
||||
if (ability == null || !ability.equalsIgnoreCase("EarthSmash") || bplayer.isOnCooldown("EarthSmash")) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
} else if (state == State.START || state == State.FLYING || state == State.GRABBED) {
|
||||
if (!GeneralMethods.canBend(player.getName(), "EarthSmash")) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(state == State.START || state == State.FLYING || state == State.GRABBED) {
|
||||
if(!GeneralMethods.canBend(player.getName(), "EarthSmash")) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(state == State.START && progressCounter > 1) {
|
||||
if(!player.isSneaking()) {
|
||||
if(System.currentTimeMillis() - time > chargeTime) {
|
||||
|
||||
if (state == State.START && progressCounter > 1) {
|
||||
if (!player.isSneaking()) {
|
||||
if (System.currentTimeMillis() - time > chargeTime) {
|
||||
origin = EarthMethods.getEarthSourceBlock(player, grabRange);
|
||||
if(origin == null){
|
||||
if (origin == null) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
bplayer.addCooldown("EarthSmash", cooldown);
|
||||
loc = origin.getLocation();
|
||||
state = State.LIFTING;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(System.currentTimeMillis() - time > chargeTime) {
|
||||
Location tempLoc = player.getEyeLocation().add(player.getEyeLocation()
|
||||
.getDirection().normalize().multiply(1.2));
|
||||
} else if (System.currentTimeMillis() - time > chargeTime) {
|
||||
Location tempLoc = player.getEyeLocation().add(player.getEyeLocation().getDirection().normalize().multiply(1.2));
|
||||
tempLoc.add(0, 0.3, 0);
|
||||
ParticleEffect.SMOKE.display(tempLoc, 0.3F, 0.1F, 0.3F, 0, 4);
|
||||
ParticleEffect.SMOKE.display(tempLoc, 0.3F, 0.1F, 0.3F, 0, 4);
|
||||
}
|
||||
}
|
||||
else if(state == State.LIFTING) {
|
||||
if(System.currentTimeMillis() - delay >= LIFT_ANIMATION_COOLDOWN) {
|
||||
} else if (state == State.LIFTING) {
|
||||
if (System.currentTimeMillis() - delay >= LIFT_ANIMATION_COOLDOWN) {
|
||||
delay = System.currentTimeMillis();
|
||||
animateLift();
|
||||
}
|
||||
}
|
||||
else if(state == State.GRABBED) {
|
||||
if(player.isSneaking()) {
|
||||
} else if (state == State.GRABBED) {
|
||||
if (player.isSneaking()) {
|
||||
revert();
|
||||
Location oldLoc = loc.clone();
|
||||
loc = player.getEyeLocation().add(
|
||||
player.getEyeLocation().getDirection().normalize().multiply(grabbedRange));
|
||||
|
||||
loc = player.getEyeLocation().add(player.getEyeLocation().getDirection().normalize().multiply(grabbedRange));
|
||||
|
||||
//Check to make sure the new location is available to move to
|
||||
for(Block block : getBlocks())
|
||||
if(block.getType() != Material.AIR && !EarthMethods.isTransparentToEarthbending(player, block)) {
|
||||
for (Block block : getBlocks())
|
||||
if (block.getType() != Material.AIR && !EarthMethods.isTransparentToEarthbending(player, block)) {
|
||||
loc = oldLoc;
|
||||
break;
|
||||
}
|
||||
|
@ -217,33 +205,30 @@ public class EarthSmash {
|
|||
AirMethods.removeAirSpouts(loc, 2, player);
|
||||
draw();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state = State.LIFTED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(state == State.SHOT) {
|
||||
if(System.currentTimeMillis() - delay >= SHOOTING_ANIMATION_COOLDOWN) {
|
||||
} else if (state == State.SHOT) {
|
||||
if (System.currentTimeMillis() - delay >= SHOOTING_ANIMATION_COOLDOWN) {
|
||||
delay = System.currentTimeMillis();
|
||||
if(GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
revert();
|
||||
loc.add(GeneralMethods.getDirection(loc, destination).normalize().multiply(1));
|
||||
if(loc.distanceSquared(destination) < 4) {
|
||||
if (loc.distanceSquared(destination) < 4) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
// If an earthsmash runs into too many blocks we should remove it
|
||||
int badBlocksFound = 0;
|
||||
for(Block block : getBlocks())
|
||||
if(block.getType() != Material.AIR &&
|
||||
(!EarthMethods.isTransparentToEarthbending(player, block) || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER))
|
||||
for (Block block : getBlocks())
|
||||
if (block.getType() != Material.AIR && (!EarthMethods.isTransparentToEarthbending(player, block) || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER))
|
||||
badBlocksFound++;
|
||||
|
||||
if(badBlocksFound > MAX_BLOCKS_TO_PASS_THROUGH) {
|
||||
|
||||
if (badBlocksFound > MAX_BLOCKS_TO_PASS_THROUGH) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
@ -254,155 +239,151 @@ public class EarthSmash {
|
|||
smashToSmashCollisionDetection();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(state == State.FLYING) {
|
||||
if(!player.isSneaking()){
|
||||
} else if (state == State.FLYING) {
|
||||
if (!player.isSneaking()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
else if(System.currentTimeMillis() - delay >= FLYING_ANIMATION_COOLDOWN)
|
||||
{
|
||||
} else if (System.currentTimeMillis() - delay >= FLYING_ANIMATION_COOLDOWN) {
|
||||
delay = System.currentTimeMillis();
|
||||
if(GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
revert();
|
||||
destination = player.getEyeLocation().clone().add
|
||||
(player.getEyeLocation().getDirection().normalize().multiply(shootRange));
|
||||
destination = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(shootRange));
|
||||
Vector direction = GeneralMethods.getDirection(loc, destination).normalize();
|
||||
|
||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc.clone().add(0,2,0), FLIGHT_DETECTION_RADIUS);
|
||||
if(entities.size() == 0){
|
||||
|
||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc.clone().add(0, 2, 0), FLIGHT_DETECTION_RADIUS);
|
||||
if (entities.size() == 0) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
for(Entity entity : entities)
|
||||
for (Entity entity : entities)
|
||||
entity.setVelocity(direction.clone().multiply(flySpeed));
|
||||
|
||||
|
||||
//These values tend to work well when dealing with a person aiming upward or downward.
|
||||
if(direction.getY() < -0.35)
|
||||
loc = player.getLocation().clone().add(0,-3.2,0);
|
||||
else if(direction.getY() > 0.35)
|
||||
loc = player.getLocation().clone().add(0,-1.7,0);
|
||||
if (direction.getY() < -0.35)
|
||||
loc = player.getLocation().clone().add(0, -3.2, 0);
|
||||
else if (direction.getY() > 0.35)
|
||||
loc = player.getLocation().clone().add(0, -1.7, 0);
|
||||
else
|
||||
loc = player.getLocation().clone().add(0,-2.2,0);
|
||||
loc = player.getLocation().clone().add(0, -2.2, 0);
|
||||
draw();
|
||||
}
|
||||
if(System.currentTimeMillis() - flightStart > flightRemove){
|
||||
if (System.currentTimeMillis() - flightStart > flightRemove) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void animateLift()
|
||||
{
|
||||
public void animateLift() {
|
||||
/**
|
||||
* Begins animating the EarthSmash from the ground. The lift animation consists
|
||||
* of 3 steps, and each one has to design the shape in the ground that removes the
|
||||
* earthbendable material. We also need to make sure that there is a clear path for
|
||||
* the EarthSmash to rise, and that there is enough earthbendable material for it to be created.
|
||||
* Begins animating the EarthSmash from the ground. The lift animation
|
||||
* consists of 3 steps, and each one has to design the shape in the
|
||||
* ground that removes the earthbendable material. We also need to make
|
||||
* sure that there is a clear path for the EarthSmash to rise, and that
|
||||
* there is enough earthbendable material for it to be created.
|
||||
*/
|
||||
if(animCounter < 4) {
|
||||
if (animCounter < 4) {
|
||||
revert();
|
||||
loc.add(0,1,0);
|
||||
loc.add(0, 1, 0);
|
||||
//Remove the blocks underneath the rising smash
|
||||
if(animCounter == 0) {
|
||||
if (animCounter == 0) {
|
||||
//Check all of the blocks and make sure that they can be removed AND make sure there is enough dirt
|
||||
int totalBendableBlocks = 0;
|
||||
for(int x = -1; x <= 1; x++)
|
||||
for(int y = -2; y <= -1; y++)
|
||||
for(int z = -1; z <= 1; z++) {
|
||||
Block block = loc.clone().add(x,y,z).getBlock();
|
||||
if(GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", block.getLocation())) {
|
||||
for (int x = -1; x <= 1; x++)
|
||||
for (int y = -2; y <= -1; y++)
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
Block block = loc.clone().add(x, y, z).getBlock();
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", block.getLocation())) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
if(isEarthbendableMaterial(block.getType()))
|
||||
if (isEarthbendableMaterial(block.getType()))
|
||||
totalBendableBlocks++;
|
||||
}
|
||||
if(totalBendableBlocks < REQUIRED_BENDABLE_BLOCKS) {
|
||||
if (totalBendableBlocks < REQUIRED_BENDABLE_BLOCKS) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
//Make sure there is a clear path upward otherwise remove
|
||||
for(int y = 0; y <= 3; y++) {
|
||||
Block tempBlock = loc.clone().add(0,y,0).getBlock();
|
||||
if(!EarthMethods.isTransparentToEarthbending(player, tempBlock) && tempBlock.getType() != Material.AIR) {
|
||||
for (int y = 0; y <= 3; y++) {
|
||||
Block tempBlock = loc.clone().add(0, y, 0).getBlock();
|
||||
if (!EarthMethods.isTransparentToEarthbending(player, tempBlock) && tempBlock.getType() != Material.AIR) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//Design what this EarthSmash looks like by using BlockRepresenters
|
||||
Location tempLoc = loc.clone().add(0,-2,0);
|
||||
for(int x = -1; x <= 1; x++)
|
||||
for(int y = -1; y <= 1; y++)
|
||||
for(int z = -1; z <= 1; z++)
|
||||
if((Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2 == 0) {
|
||||
Block block = tempLoc.clone().add(x,y,z).getBlock();
|
||||
Location tempLoc = loc.clone().add(0, -2, 0);
|
||||
for (int x = -1; x <= 1; x++)
|
||||
for (int y = -1; y <= 1; y++)
|
||||
for (int z = -1; z <= 1; z++)
|
||||
if ((Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2 == 0) {
|
||||
Block block = tempLoc.clone().add(x, y, z).getBlock();
|
||||
currentBlocks.add(new BlockRepresenter(x, y, z, selectMaterialForRepresenter(block.getType()), block.getData()));
|
||||
}
|
||||
|
||||
|
||||
//Remove the design of the second level of removed dirt
|
||||
for(int x = -1; x <= 1; x++)
|
||||
for(int z = -1; z <= 1; z++) {
|
||||
if((Math.abs(x) + Math.abs(z)) % 2 == 1) {
|
||||
Block block = loc.clone().add(x,-2,z).getBlock();
|
||||
if(isEarthbendableMaterial(block.getType()))
|
||||
for (int x = -1; x <= 1; x++)
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
if ((Math.abs(x) + Math.abs(z)) % 2 == 1) {
|
||||
Block block = loc.clone().add(x, -2, z).getBlock();
|
||||
if (isEarthbendableMaterial(block.getType()))
|
||||
EarthMethods.addTempAirBlock(block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Remove the first level of dirt
|
||||
Block block = loc.clone().add(x,-1,z).getBlock();
|
||||
if(isEarthbendableMaterial(block.getType()))
|
||||
EarthMethods.addTempAirBlock(block);
|
||||
|
||||
Block block = loc.clone().add(x, -1, z).getBlock();
|
||||
if (isEarthbendableMaterial(block.getType()))
|
||||
EarthMethods.addTempAirBlock(block);
|
||||
|
||||
}
|
||||
/*
|
||||
* We needed to calculate all of the blocks based on the location being 1 above the initial
|
||||
* bending block, however we want to animate it starting from the original bending block.
|
||||
* We needed to calculate all of the blocks based on the
|
||||
* location being 1 above the initial bending block, however we
|
||||
* want to animate it starting from the original bending block.
|
||||
* We must readjust the location back to what it originally was.
|
||||
*/
|
||||
loc.add(0,-1,0);
|
||||
loc.add(0, -1, 0);
|
||||
|
||||
}
|
||||
//Move any entities that are above the rock
|
||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc, 2.5);
|
||||
for(Entity entity : entities) {
|
||||
for (Entity entity : entities) {
|
||||
org.bukkit.util.Vector velocity = entity.getVelocity();
|
||||
entity.setVelocity(velocity.add(new Vector(0,0.36,0)));
|
||||
entity.setVelocity(velocity.add(new Vector(0, 0.36, 0)));
|
||||
}
|
||||
loc.getWorld().playEffect(loc, Effect.GHAST_SHOOT, 0, 7);
|
||||
draw();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state = State.LIFTED;
|
||||
}
|
||||
animCounter++;
|
||||
}
|
||||
|
||||
|
||||
public void draw() {
|
||||
/**
|
||||
* Redraws the blocks for this instance of EarthSmash.
|
||||
*/
|
||||
if(currentBlocks.size() == 0) {
|
||||
if (currentBlocks.size() == 0) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
for(BlockRepresenter blockRep : currentBlocks) {
|
||||
Block block = loc.clone().add(blockRep.getX(),blockRep.getY(),blockRep.getZ()).getBlock();
|
||||
if(player != null && EarthMethods.isTransparentToEarthbending(player,block)) {
|
||||
for (BlockRepresenter blockRep : currentBlocks) {
|
||||
Block block = loc.clone().add(blockRep.getX(), blockRep.getY(), blockRep.getZ()).getBlock();
|
||||
if (player != null && EarthMethods.isTransparentToEarthbending(player, block)) {
|
||||
affectedBlocks.add(new TempBlock(block, blockRep.getType(), blockRep.getData()));
|
||||
EarthMethods.tempNoEarthbending.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void revert() {
|
||||
checkRemainingBlocks();
|
||||
for(int i = 0; i < affectedBlocks.size(); i++) {
|
||||
for (int i = 0; i < affectedBlocks.size(); i++) {
|
||||
TempBlock tblock = affectedBlocks.get(i);
|
||||
EarthMethods.tempNoEarthbending.remove(tblock.getBlock());
|
||||
tblock.revertBlock();
|
||||
|
@ -410,162 +391,166 @@ public class EarthSmash {
|
|||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkRemainingBlocks() {
|
||||
/**
|
||||
* Checks to see which of the blocks are still attached to the
|
||||
* EarthSmash, remember that blocks can be broken or used in other abilities
|
||||
* so we need to double check and remove any that are not still attached.
|
||||
* EarthSmash, remember that blocks can be broken or used in other
|
||||
* abilities so we need to double check and remove any that are not
|
||||
* still attached.
|
||||
*
|
||||
* Also when we remove the blocks from instances, movedearth, or tempair
|
||||
* we should do it on a delay because tempair takes a couple seconds before
|
||||
* the block shows up in that map.
|
||||
* we should do it on a delay because tempair takes a couple seconds
|
||||
* before the block shows up in that map.
|
||||
*/
|
||||
for(int i = 0; i < currentBlocks.size(); i++) {
|
||||
for (int i = 0; i < currentBlocks.size(); i++) {
|
||||
BlockRepresenter brep = currentBlocks.get(i);
|
||||
final Block block = loc.clone().add(brep.getX(), brep.getY(), brep.getZ()).getBlock();
|
||||
// Check for grass because sometimes the dirt turns into grass.
|
||||
if(block.getType() != brep.getType()
|
||||
&& (block.getType() != Material.GRASS)
|
||||
&& (block.getType() != Material.COBBLESTONE)) {
|
||||
if (block.getType() != brep.getType() && (block.getType() != Material.GRASS) && (block.getType() != Material.COBBLESTONE)) {
|
||||
currentBlocks.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void remove() {
|
||||
state = State.REMOVED;
|
||||
revert();
|
||||
instances.remove(this);
|
||||
}
|
||||
|
||||
|
||||
public List<Block> getBlocks() {
|
||||
/**
|
||||
* Gets the blocks surrounding the EarthSmash's loc.
|
||||
* This method ignores the blocks that should be Air, and only returns the ones that are dirt.
|
||||
* Gets the blocks surrounding the EarthSmash's loc. This method ignores
|
||||
* the blocks that should be Air, and only returns the ones that are
|
||||
* dirt.
|
||||
*/
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
for(int x = -1; x <= 1; x++)
|
||||
for(int y = -1; y <= 1; y++)
|
||||
for(int z = -1; z <= 1; z++)
|
||||
if((Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2 == 0) //Give it the cool shape
|
||||
if(loc != null)
|
||||
blocks.add(loc.getWorld().getBlockAt(loc.clone().add(x,y,z)));
|
||||
for (int x = -1; x <= 1; x++)
|
||||
for (int y = -1; y <= 1; y++)
|
||||
for (int z = -1; z <= 1; z++)
|
||||
if ((Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2 == 0) //Give it the cool shape
|
||||
if (loc != null)
|
||||
blocks.add(loc.getWorld().getBlockAt(loc.clone().add(x, y, z)));
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
||||
public List<Block> getBlocksIncludingInner() {
|
||||
/**
|
||||
* Gets the blocks surrounding the EarthSmash's loc.
|
||||
* This method returns all the blocks surrounding the loc, including dirt and air.
|
||||
* Gets the blocks surrounding the EarthSmash's loc. This method returns
|
||||
* all the blocks surrounding the loc, including dirt and air.
|
||||
*/
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
for(int x = -1; x <= 1; x++)
|
||||
for(int y = -1; y <= 1; y++)
|
||||
for(int z = -1; z <= 1; z++)
|
||||
if(loc != null)
|
||||
blocks.add(loc.getWorld().getBlockAt(loc.clone().add(x,y,z)));
|
||||
for (int x = -1; x <= 1; x++)
|
||||
for (int y = -1; y <= 1; y++)
|
||||
for (int z = -1; z <= 1; z++)
|
||||
if (loc != null)
|
||||
blocks.add(loc.getWorld().getBlockAt(loc.clone().add(x, y, z)));
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
||||
public static Material selectMaterial(Material mat) {
|
||||
/**
|
||||
* Switches the Sand Material and Gravel to SandStone and stone respectively,
|
||||
* since gravel and sand cannot be bent due to gravity.
|
||||
* Switches the Sand Material and Gravel to SandStone and stone
|
||||
* respectively, since gravel and sand cannot be bent due to gravity.
|
||||
*/
|
||||
if(mat == Material.SAND) return Material.SANDSTONE;
|
||||
else if(mat == Material.GRAVEL) return Material.STONE;
|
||||
else return mat;
|
||||
if (mat == Material.SAND)
|
||||
return Material.SANDSTONE;
|
||||
else if (mat == Material.GRAVEL)
|
||||
return Material.STONE;
|
||||
else
|
||||
return mat;
|
||||
}
|
||||
|
||||
|
||||
public Material selectMaterialForRepresenter(Material mat) {
|
||||
Material tempMat = selectMaterial(mat);
|
||||
Random rand = new Random();
|
||||
if(!isEarthbendableMaterial(tempMat)) {
|
||||
if(currentBlocks.size() < 1)
|
||||
if (!isEarthbendableMaterial(tempMat)) {
|
||||
if (currentBlocks.size() < 1)
|
||||
return Material.DIRT;
|
||||
else
|
||||
else
|
||||
return currentBlocks.get(rand.nextInt(currentBlocks.size())).getType();
|
||||
}
|
||||
return tempMat;
|
||||
}
|
||||
|
||||
|
||||
private EarthSmash aimingAtSmashCheck(Player player, State reqState) {
|
||||
/**
|
||||
* Determines if a player is trying to grab an EarthSmash.
|
||||
* A player is trying to grab an EarthSmash if they are staring at it and holding shift.
|
||||
* Determines if a player is trying to grab an EarthSmash. A player is
|
||||
* trying to grab an EarthSmash if they are staring at it and holding
|
||||
* shift.
|
||||
*/
|
||||
if(!ALLOW_GRAB)
|
||||
if (!ALLOW_GRAB)
|
||||
return null;
|
||||
@SuppressWarnings("deprecation")
|
||||
List<Block> blocks = player.getLineOfSight(EarthMethods.getTransparentEarthbending(), (int) Math.round(grabRange));
|
||||
for(EarthSmash smash : instances) {
|
||||
if(reqState == null || smash.state == reqState)
|
||||
for(Block block : blocks)
|
||||
if(block.getLocation().getWorld() == smash.loc.getWorld() &&
|
||||
block.getLocation().distanceSquared(smash.loc) <= Math.pow(GRAB_DETECTION_RADIUS, 2))
|
||||
for (EarthSmash smash : instances) {
|
||||
if (reqState == null || smash.state == reqState)
|
||||
for (Block block : blocks)
|
||||
if (block.getLocation().getWorld() == smash.loc.getWorld() && block.getLocation().distanceSquared(smash.loc) <= Math.pow(GRAB_DETECTION_RADIUS, 2))
|
||||
return smash;
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void shootingCollisionDetection() {
|
||||
/**
|
||||
* This method handles any collision between an EarthSmash and the surrounding entities,
|
||||
* the method only applies to earthsmashes that have already been shot.
|
||||
* This method handles any collision between an EarthSmash and the
|
||||
* surrounding entities, the method only applies to earthsmashes that
|
||||
* have already been shot.
|
||||
*/
|
||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc, FLIGHT_DETECTION_RADIUS);
|
||||
for(Entity entity : entities)
|
||||
if(entity instanceof LivingEntity
|
||||
&& entity != player
|
||||
&& !affectedEntities.contains(entity)) {
|
||||
for (Entity entity : entities)
|
||||
if (entity instanceof LivingEntity && entity != player && !affectedEntities.contains(entity)) {
|
||||
affectedEntities.add(entity);
|
||||
double damage = currentBlocks.size() / 13 * this.damage;
|
||||
GeneralMethods.damageEntity(player, entity, damage);
|
||||
Vector travelVec = GeneralMethods.getDirection(loc, entity.getLocation());
|
||||
entity.setVelocity(travelVec.setY(knockup).normalize().multiply(knockback));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void smashToSmashCollisionDetection() {
|
||||
/**
|
||||
* EarthSmash to EarthSmash collision can only happen when one of the Smashes have
|
||||
* been shot by a player. If we find out that one of them have collided then we want to return
|
||||
* since a smash can only remove 1 at a time.
|
||||
* EarthSmash to EarthSmash collision can only happen when one of the
|
||||
* Smashes have been shot by a player. If we find out that one of them
|
||||
* have collided then we want to return since a smash can only remove 1
|
||||
* at a time.
|
||||
*/
|
||||
for(int i = 0; i < instances.size(); i++) {
|
||||
for (int i = 0; i < instances.size(); i++) {
|
||||
EarthSmash smash = instances.get(i);
|
||||
if(smash.loc != null) {
|
||||
if(smash != this && smash.loc.getWorld() == loc.getWorld() &&smash.loc.distanceSquared(loc) < Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
||||
if (smash.loc != null) {
|
||||
if (smash != this && smash.loc.getWorld() == loc.getWorld() && smash.loc.distanceSquared(loc) < Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
||||
smash.remove();
|
||||
remove();
|
||||
i-=2;
|
||||
i -= 2;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static EarthSmash flyingInSmashCheck(Player player) {
|
||||
/**
|
||||
* Determines whether or not a player is trying to fly ontop of an EarthSmash.
|
||||
* A player is considered "flying" if they are standing ontop of the earthsmash and holding shift.
|
||||
* Determines whether or not a player is trying to fly ontop of an
|
||||
* EarthSmash. A player is considered "flying" if they are standing
|
||||
* ontop of the earthsmash and holding shift.
|
||||
*/
|
||||
if(!ALLOW_FLIGHT)
|
||||
if (!ALLOW_FLIGHT)
|
||||
return null;
|
||||
|
||||
for(EarthSmash smash : instances) {
|
||||
|
||||
for (EarthSmash smash : instances) {
|
||||
//Check to see if the player is standing on top of the smash.
|
||||
if(smash.state == State.LIFTED) {
|
||||
if(smash.loc.getWorld().equals(player.getWorld())
|
||||
&& smash.loc.clone().add(0,2,0).distanceSquared(player.getLocation()) <= Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
||||
if (smash.state == State.LIFTED) {
|
||||
if (smash.loc.getWorld().equals(player.getWorld()) && smash.loc.clone().add(0, 2, 0).distanceSquared(player.getLocation()) <= Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
||||
return smash;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isEarthbendableMaterial(Material mat) {
|
||||
for (String s : ProjectKorra.plugin.getConfig().getStringList("Properties.Earth.EarthbendableBlocks")) {
|
||||
if (mat == Material.getMaterial(s))
|
||||
|
@ -573,30 +558,32 @@ public class EarthSmash {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static void progressAll() {
|
||||
for(int i = 0; i < instances.size(); i++)
|
||||
for (int i = 0; i < instances.size(); i++)
|
||||
instances.get(i).progress();
|
||||
}
|
||||
|
||||
|
||||
public static void removeAll() {
|
||||
for(int i = 0; i < instances.size(); i++) {
|
||||
for (int i = 0; i < instances.size(); i++) {
|
||||
instances.get(i).remove();
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BlockRepresenter {
|
||||
/**
|
||||
* A BlockRepresenter is used to keep track of each of
|
||||
* the individual types of blocks that are attached to an EarthSmash.
|
||||
* Without the representer then an EarthSmash can only be made up of 1 material
|
||||
* at a time. For example, an ESmash that is entirely dirt, coalore, or sandstone.
|
||||
* Using the representer will allow all the materials to be mixed together.
|
||||
* A BlockRepresenter is used to keep track of each of the individual
|
||||
* types of blocks that are attached to an EarthSmash. Without the
|
||||
* representer then an EarthSmash can only be made up of 1 material at a
|
||||
* time. For example, an ESmash that is entirely dirt, coalore, or
|
||||
* sandstone. Using the representer will allow all the materials to be
|
||||
* mixed together.
|
||||
*/
|
||||
private int x, y, z;
|
||||
private Material type;
|
||||
private byte data;
|
||||
|
||||
public BlockRepresenter(int x, int y, int z, Material type, byte data) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
@ -604,77 +591,78 @@ public class EarthSmash {
|
|||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
public Material getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public byte getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
|
||||
public void setZ(int z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
public void setType(Material type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
public void setData(byte data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return x + ", " + y + ", " + z + ", " + type.toString();
|
||||
return x + ", " + y + ", " + z + ", " + type.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Pair<F, S> {
|
||||
private F first; //first member of pair
|
||||
private S second; //second member of pair
|
||||
private F first; //first member of pair
|
||||
private S second; //second member of pair
|
||||
|
||||
public Pair(F first, S second) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
public Pair(F first, S second) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
public void setFirst(F first) {
|
||||
this.first = first;
|
||||
}
|
||||
public void setFirst(F first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public void setSecond(S second) {
|
||||
this.second = second;
|
||||
}
|
||||
public void setSecond(S second) {
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
public F getFirst() {
|
||||
return first;
|
||||
}
|
||||
public F getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public S getSecond() {
|
||||
return second;
|
||||
}
|
||||
public S getSecond() {
|
||||
return second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
@ -689,7 +677,7 @@ public class EarthSmash {
|
|||
|
||||
public void setCooldown(long cooldown) {
|
||||
this.cooldown = cooldown;
|
||||
if(player != null)
|
||||
if (player != null)
|
||||
bplayer.addCooldown("EarthSmash", cooldown);
|
||||
}
|
||||
|
||||
|
|
|
@ -223,7 +223,9 @@ public class FireBlast extends CoreAbility {
|
|||
private void ignite(Location location) {
|
||||
for (Block block : GeneralMethods.getBlocksAroundPoint(location, affectingradius)) {
|
||||
if (FireStream.isIgnitable(player, block) && !safe.contains(block)) {
|
||||
new Plantbending(block);
|
||||
if (WaterMethods.isPlantbendable(block)) {
|
||||
new Plantbending(block);
|
||||
}
|
||||
block.setType(Material.FIRE);
|
||||
if (dissipate) {
|
||||
FireStream.ignitedblocks.put(block, player);
|
||||
|
|
|
@ -307,6 +307,10 @@ public class WaterMethods {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPlantbendable(Block block) {
|
||||
return WaterMethods.isPlantbendable(block, false);
|
||||
}
|
||||
|
||||
public static void playFocusWaterEffect(Block block) {
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 4, 20);
|
||||
|
|
Loading…
Reference in a new issue