mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
EarthBlast
This commit is contained in:
parent
256ad9fd59
commit
a2647b4501
7 changed files with 695 additions and 0 deletions
|
@ -105,6 +105,10 @@ public class BendingManager implements Runnable {
|
|||
FireStream.progress(id);
|
||||
}
|
||||
|
||||
for (int ID : EarthBlast.instances.keySet()) {
|
||||
EarthBlast.progress(ID);
|
||||
}
|
||||
|
||||
for (Block block: FireStream.ignitedblocks.keySet()) {
|
||||
if (block.getType() != Material.FIRE) {
|
||||
FireStream.ignitedblocks.remove(block);
|
||||
|
|
|
@ -215,6 +215,24 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Earth.Collapse.Radius", 7);
|
||||
config.addDefault("Abilities.Earth.Collapse.Speed", 8);
|
||||
|
||||
config.addDefault("Abilities.Earth.EarthBlast.Enabled", true);
|
||||
config.addDefault("Abilities.Earth.EarthBlast.Description", "To use, place your cursor over an earthbendable object (dirt, rock, ores, etc) "
|
||||
+ "and tap sneak (default: shift). The object will temporarily turn to stone, "
|
||||
+ "indicating that you have it focused as the source for your ability. "
|
||||
+ "After you have selected an origin (you no longer need to be sneaking), "
|
||||
+ "simply left-click in any direction and you will see your object launch "
|
||||
+ "off in that direction, smashing into any creature in its path. If you look "
|
||||
+ "towards a creature when you use this ability, it will target that creature. "
|
||||
+ "A collision from Earth Blast both knocks the target back and deals some damage. "
|
||||
+ "You cannot have multiple of these abilities flying at the same time.");
|
||||
config.addDefault("Abilities.Earth.EarthBlast.CanHitSelf", false);
|
||||
config.addDefault("Abilities.Earth.EarthBlast.PrepareRange", 7);
|
||||
config.addDefault("Abilities.Earth.EarthBlast.Range", 20);
|
||||
config.addDefault("Abilities.Earth.EarthBlast.Speed", 35);
|
||||
config.addDefault("Abilities.Earth.EarthBlast.Revert", true);
|
||||
config.addDefault("Abilities.Earth.Earthblast.Damage", 4);
|
||||
config.addDefault("Abilities.Earth.EarthBlast.Push", 0.3);
|
||||
|
||||
config.addDefault("Abilities.Earth.RaiseEarth.Enabled", true);
|
||||
config.addDefault("Abilities.Earth.RaiseEarth.Description", "To use, simply left-click on an earthbendable block. "
|
||||
+ "A column of earth will shoot upwards from that location. "
|
||||
|
|
|
@ -54,6 +54,7 @@ import com.projectkorra.ProjectKorra.chiblocking.Paralyze;
|
|||
import com.projectkorra.ProjectKorra.earthbending.Catapult;
|
||||
import com.projectkorra.ProjectKorra.earthbending.Collapse;
|
||||
import com.projectkorra.ProjectKorra.earthbending.CompactColumn;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthWall;
|
||||
|
@ -208,6 +209,9 @@ public class PKListener implements Listener {
|
|||
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) {
|
||||
return;
|
||||
}
|
||||
if (abil.equalsIgnoreCase("EarthBlast")) {
|
||||
new EarthBlast(player);
|
||||
}
|
||||
if (abil.equalsIgnoreCase("RaiseEarth")) {
|
||||
new EarthWall(player);
|
||||
}
|
||||
|
@ -291,6 +295,45 @@ public class PKListener implements Listener {
|
|||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
for (Block block : event.blockList()) {
|
||||
EarthBlast blast = EarthBlast.getBlastFromSource(block);
|
||||
|
||||
if (blast != null) {
|
||||
blast.cancel();
|
||||
}
|
||||
if (FreezeMelt.frozenblocks.containsKey(block)) {
|
||||
FreezeMelt.thaw(block);
|
||||
}
|
||||
// if (WalkOnWater.affectedblocks.containsKey(block)) {
|
||||
// WalkOnWater.thaw(block);
|
||||
// }
|
||||
if (WaterWall.wallblocks.containsKey(block)) {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
if (!Wave.canThaw(block)) {
|
||||
Wave.thaw(block);
|
||||
}
|
||||
if (Methods.movedearth.containsKey(block)) {
|
||||
// Tools.removeEarthbendedBlockIndex(block);
|
||||
Methods.removeRevertIndex(block);
|
||||
}
|
||||
}
|
||||
|
||||
// if (event.getEntity() == null) {
|
||||
// Plugin ch = Bukkit.getPluginManager().getPlugin("CreeperHeal");
|
||||
// if (ch != null) {
|
||||
// CreeperHeal creeperheal = (CreeperHeal) Bukkit
|
||||
// .getPluginManager().getPlugin("CreeperHeal");
|
||||
// creeperheal
|
||||
// .recordBlocks(event.blockList(), event.getLocation());
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityExplodeEvent(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
@ -405,6 +448,10 @@ public class PKListener implements Listener {
|
|||
new Catapult(player);
|
||||
}
|
||||
|
||||
if (abil.equalsIgnoreCase("EarthBlast")) {
|
||||
EarthBlast.throwEarth(player);
|
||||
}
|
||||
|
||||
if (abil.equalsIgnoreCase("RaiseEarth")) {
|
||||
new EarthColumn(player);
|
||||
}
|
||||
|
|
614
src/com/projectkorra/ProjectKorra/earthbending/EarthBlast.java
Normal file
614
src/com/projectkorra/ProjectKorra/earthbending/EarthBlast.java
Normal file
|
@ -0,0 +1,614 @@
|
|||
package com.projectkorra.ProjectKorra.earthbending;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.firebending.FireBlast;
|
||||
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
||||
|
||||
public class EarthBlast {
|
||||
|
||||
public static ConcurrentHashMap<Integer, EarthBlast> instances = new ConcurrentHashMap<Integer, EarthBlast>();
|
||||
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
|
||||
// private static ConcurrentHashMap<Player, EarthBlast> prepared = new
|
||||
// ConcurrentHashMap<Player, EarthBlast>();
|
||||
|
||||
private static boolean hitself = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth.EarthBlast.CanHitSelf");
|
||||
private static double preparerange = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthBlast.PrepareRange");
|
||||
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthBlast.Range");
|
||||
private static int damage = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.EarthBlast.Damage");
|
||||
private static double speed = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthBlast.Speed");
|
||||
private static final double deflectrange = 3;
|
||||
|
||||
private static boolean revert = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth.EarthBlast.Revert");
|
||||
private static double pushfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthBlast.Push");
|
||||
// private static double speed = 1.5;
|
||||
|
||||
private static long interval = (long) (1000. / speed);
|
||||
|
||||
private static int ID = Integer.MIN_VALUE;
|
||||
|
||||
private Player player;
|
||||
private int id;
|
||||
private Location location = null;
|
||||
private Block sourceblock = null;
|
||||
private Material sourcetype = null;
|
||||
private boolean progressing = false;
|
||||
private Location destination = null;
|
||||
private Location firstdestination = null;
|
||||
// private Vector firstdirection = null;
|
||||
// private Vector targetdirection = null;
|
||||
private boolean falling = false;
|
||||
private long time;
|
||||
private boolean settingup = true;
|
||||
|
||||
public EarthBlast(Player player) {
|
||||
this.player = player;
|
||||
if (prepare()) {
|
||||
// if (instances.containsKey(player.getEntityId())) {
|
||||
// instances.get(player.getEntityId()).cancel();
|
||||
// }
|
||||
id = ID++;
|
||||
if (ID >= Integer.MAX_VALUE)
|
||||
ID = Integer.MIN_VALUE;
|
||||
instances.put(id, this);
|
||||
// prepared.put(player, this);
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean prepare() {
|
||||
cancelPrevious();
|
||||
Block block = Methods.getEarthSourceBlock(player, preparerange);
|
||||
// if (Methods.isEarthbendable(player, block)) {
|
||||
// sourceblock = block;
|
||||
// focusBlock();
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
block(player);
|
||||
if (block != null) {
|
||||
sourceblock = block;
|
||||
focusBlock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Location getTargetLocation(Player player) {
|
||||
Entity target = Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
|
||||
Location location;
|
||||
if (target == null) {
|
||||
location = Methods.getTargetedLocation(player, range);
|
||||
} else {
|
||||
// targetting = true;
|
||||
location = ((LivingEntity) target).getEyeLocation();
|
||||
// location.setY(location.getY() - 1);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
private void cancelPrevious() {
|
||||
// if (prepared.containsKey(player)) {
|
||||
// EarthBlast old = prepared.get(player);
|
||||
// if (!old.progressing) {
|
||||
// old.cancel();
|
||||
// }
|
||||
// }
|
||||
|
||||
for (int id : instances.keySet()) {
|
||||
EarthBlast blast = instances.get(id);
|
||||
if (blast.player == player && !blast.progressing)
|
||||
blast.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
unfocusBlock();
|
||||
}
|
||||
|
||||
private void focusBlock() {
|
||||
if (EarthPassive.isPassiveSand(sourceblock))
|
||||
EarthPassive.revertSand(sourceblock);
|
||||
if (sourceblock.getType() == Material.SAND) {
|
||||
sourceblock.setType(Material.SANDSTONE);
|
||||
sourcetype = Material.SAND;
|
||||
} else if (sourceblock.getType() == Material.STONE) {
|
||||
sourceblock.setType(Material.COBBLESTONE);
|
||||
sourcetype = Material.STONE;
|
||||
} else {
|
||||
sourcetype = sourceblock.getType();
|
||||
sourceblock.setType(Material.STONE);
|
||||
}
|
||||
|
||||
location = sourceblock.getLocation();
|
||||
}
|
||||
|
||||
private void unfocusBlock() {
|
||||
sourceblock.setType(sourcetype);
|
||||
instances.remove(id);
|
||||
}
|
||||
|
||||
public void throwEarth() {
|
||||
if (sourceblock != null) {
|
||||
if (sourceblock.getWorld() == player.getWorld()) {
|
||||
if (Methods.movedearth.containsKey(sourceblock)) {
|
||||
if (!revert)
|
||||
Methods.removeRevertIndex(sourceblock);
|
||||
// Methods.removeEarthbendedBlockIndex(sourceblock);
|
||||
}
|
||||
Entity target = Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
|
||||
// Methods.verbose(target);
|
||||
if (target == null) {
|
||||
destination = player.getTargetBlock(
|
||||
Methods.getTransparentEarthbending(), (int) range)
|
||||
.getLocation();
|
||||
firstdestination = sourceblock.getLocation().clone();
|
||||
firstdestination.setY(destination.getY());
|
||||
} else {
|
||||
destination = ((LivingEntity) target).getEyeLocation();
|
||||
firstdestination = sourceblock.getLocation().clone();
|
||||
firstdestination.setY(destination.getY());
|
||||
destination = Methods.getPointOnLine(firstdestination,
|
||||
destination, range);
|
||||
}
|
||||
// firstdestination.getBlock().setType(Material.GLOWSTONE);
|
||||
// destination.getBlock().setType(Material.GLOWSTONE);
|
||||
if (destination.distance(location) <= 1) {
|
||||
progressing = false;
|
||||
destination = null;
|
||||
} else {
|
||||
progressing = true;
|
||||
sourceblock.getWorld().playEffect(
|
||||
sourceblock.getLocation(), Effect.GHAST_SHOOT, 0,
|
||||
10);
|
||||
// direction = getDirection().normalize();
|
||||
if (sourcetype != Material.SAND
|
||||
&& sourcetype != Material.GRAVEL) {
|
||||
sourceblock.setType(sourcetype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// private Vector getDirection() {
|
||||
// double x1, y1, z1;
|
||||
// double x0, y0, z0;
|
||||
//
|
||||
// x1 = destination.getX();
|
||||
// y1 = destination.getY();
|
||||
// z1 = destination.getZ();
|
||||
//
|
||||
// x0 = (double) sourceblock.getX();
|
||||
// y0 = (double) sourceblock.getY();
|
||||
// z0 = (double) sourceblock.getZ();
|
||||
//
|
||||
// return new Vector(x1 - x0, y1 - y0, z1 - z0);
|
||||
//
|
||||
// }
|
||||
|
||||
public static EarthBlast getBlastFromSource(Block block) {
|
||||
for (int id : instances.keySet()) {
|
||||
EarthBlast blast = instances.get(id);
|
||||
if (blast.sourceblock.equals(block))
|
||||
return blast;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()
|
||||
|| !Methods.canBend(player.getName(), "EarthBlast")) {
|
||||
breakBlock();
|
||||
return false;
|
||||
}
|
||||
if (System.currentTimeMillis() - time >= interval) {
|
||||
time = System.currentTimeMillis();
|
||||
|
||||
if (falling) {
|
||||
breakBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Methods.isEarthbendable(player, sourceblock)
|
||||
&& sourceblock.getType() != Material.COBBLESTONE) {
|
||||
instances.remove(id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!progressing && !falling) {
|
||||
|
||||
if (Methods.getBoundAbility(player) == null) {
|
||||
unfocusBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Methods.getBoundAbility(player).equalsIgnoreCase("EarthBlast")) {
|
||||
unfocusBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sourceblock == null) {
|
||||
instances.remove(player.getEntityId());
|
||||
return false;
|
||||
}
|
||||
if (player.getWorld() != sourceblock.getWorld()) {
|
||||
unfocusBlock();
|
||||
return false;
|
||||
}
|
||||
if (sourceblock.getLocation().distance(player.getLocation()) > preparerange) {
|
||||
unfocusBlock();
|
||||
return false;
|
||||
}
|
||||
// if (sourceblock.getType() == Material.AIR) {
|
||||
// instances.remove(player.getEntityId());
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
if (falling) {
|
||||
// location = location.clone().add(0, -1, 0);
|
||||
//
|
||||
// if (location.getBlock().getType() == Material.SNOW
|
||||
// || Methods.isPlant(location.getBlock())) {
|
||||
// Methods.breakBlock(location.getBlock());
|
||||
// } else if (location.getBlock().getType() != Material.AIR) {
|
||||
// falling = false;
|
||||
// unfocusBlock();
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// for (Entity entity : Methods.getEntitiesAroundPoint(location,
|
||||
// 1)) {
|
||||
// if (entity instanceof LivingEntity
|
||||
// && (entity.getEntityId() != player.getEntityId() || hitself))
|
||||
// {
|
||||
// Methods.damageEntity(player, entity, damage);
|
||||
// falling = false;
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!falling) {
|
||||
// breakBlock();
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (revert) {
|
||||
// Methods.addTempEarthBlock(sourceblock, location.getBlock());
|
||||
// }
|
||||
//
|
||||
// location.getBlock().setType(sourceblock.getType());
|
||||
// sourceblock.setType(Material.AIR);
|
||||
//
|
||||
// sourceblock = location.getBlock();
|
||||
//
|
||||
// return true;
|
||||
breakBlock();
|
||||
|
||||
} else {
|
||||
if (!progressing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sourceblock.getY() == firstdestination.getBlockY())
|
||||
settingup = false;
|
||||
|
||||
Vector direction;
|
||||
if (settingup) {
|
||||
direction = Methods.getDirection(location, firstdestination)
|
||||
.normalize();
|
||||
} else {
|
||||
direction = Methods.getDirection(location, destination)
|
||||
.normalize();
|
||||
}
|
||||
|
||||
location = location.clone().add(direction);
|
||||
|
||||
Methods.removeSpouts(location, player);
|
||||
|
||||
Block block = location.getBlock();
|
||||
if (block.getLocation().equals(sourceblock.getLocation())) {
|
||||
location = location.clone().add(direction);
|
||||
block = location.getBlock();
|
||||
}
|
||||
|
||||
if (Methods.isTransparentToEarthbending(player, block)
|
||||
&& !block.isLiquid()) {
|
||||
Methods.breakBlock(block);
|
||||
} else if (!settingup) {
|
||||
breakBlock();
|
||||
return false;
|
||||
} else {
|
||||
location = location.clone().subtract(direction);
|
||||
direction = Methods.getDirection(location, destination)
|
||||
.normalize();
|
||||
location = location.clone().add(direction);
|
||||
|
||||
Methods.removeSpouts(location, player);
|
||||
double radius = FireBlast.affectingradius;
|
||||
Player source = player;
|
||||
if (EarthBlast.annihilateBlasts(location, radius, source)
|
||||
|| WaterManipulation.annihilateBlasts(location,
|
||||
radius, source)
|
||||
|| FireBlast.annihilateBlasts(location, radius,
|
||||
source)) {
|
||||
breakBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block2 = location.getBlock();
|
||||
if (block2.getLocation().equals(sourceblock.getLocation())) {
|
||||
location = location.clone().add(direction);
|
||||
block2 = location.getBlock();
|
||||
}
|
||||
|
||||
if (Methods.isTransparentToEarthbending(player, block)
|
||||
&& !block.isLiquid()) {
|
||||
Methods.breakBlock(block);
|
||||
} else {
|
||||
breakBlock();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (Entity entity : Methods.getEntitiesAroundPoint(location,
|
||||
FireBlast.affectingradius)) {
|
||||
// if (Methods.isRegionProtectedFromBuild(player,
|
||||
// Abilities.EarthBlast, entity.getLocation()))
|
||||
// continue;
|
||||
if (entity instanceof LivingEntity
|
||||
&& (entity.getEntityId() != player.getEntityId() || hitself)) {
|
||||
// Block testblock = location.getBlock();
|
||||
// Block block1 = entity.getLocation().getBlock();
|
||||
// Block block2 = ((LivingEntity)
|
||||
// entity).getEyeLocation()
|
||||
// .getBlock();
|
||||
//
|
||||
// if (testblock.equals(block1)
|
||||
// || testblock.equals(block2)) {
|
||||
// entity.setVelocity(entity.getVelocity().clone()
|
||||
// .add(direction));
|
||||
Location location = player.getEyeLocation();
|
||||
Vector vector = location.getDirection();
|
||||
entity.setVelocity(vector.normalize().multiply(pushfactor));
|
||||
Methods.damageEntity(player, entity, damage);
|
||||
progressing = false;
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
if (!progressing) {
|
||||
breakBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (revert) {
|
||||
// Methods.addTempEarthBlock(sourceblock, block);
|
||||
sourceblock.setType(sourcetype);
|
||||
Methods.moveEarthBlock(sourceblock, block);
|
||||
if (block.getType() == Material.SAND)
|
||||
block.setType(Material.SANDSTONE);
|
||||
if (block.getType() == Material.GRAVEL)
|
||||
block.setType(Material.STONE);
|
||||
} else {
|
||||
block.setType(sourceblock.getType());
|
||||
sourceblock.setType(Material.AIR);
|
||||
}
|
||||
|
||||
// block.setType(sourceblock.getType());
|
||||
// sourceblock.setType(Material.AIR);
|
||||
// if (block.getType() != Material.AIR) {
|
||||
// block.setType(Material.GLOWSTONE);
|
||||
// } else {
|
||||
// block.setType(Material.GLASS);
|
||||
// }
|
||||
sourceblock = block;
|
||||
|
||||
if (location.distance(destination) < 1) {
|
||||
if (sourcetype == Material.SAND
|
||||
|| sourcetype == Material.GRAVEL) {
|
||||
progressing = false;
|
||||
sourceblock.setType(sourcetype);
|
||||
}
|
||||
|
||||
falling = true;
|
||||
progressing = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private void breakBlock() {
|
||||
sourceblock.setType(sourcetype);
|
||||
if (revert) {
|
||||
Methods.addTempAirBlock(sourceblock);
|
||||
} else {
|
||||
sourceblock.breakNaturally();
|
||||
}
|
||||
|
||||
instances.remove(id);
|
||||
}
|
||||
|
||||
public static void throwEarth(Player player) {
|
||||
// if (prepared.containsKey(player)) {
|
||||
// prepared.get(player).throwEarth();
|
||||
// prepared.remove(player);
|
||||
// }
|
||||
|
||||
ArrayList<EarthBlast> ignore = new ArrayList<EarthBlast>();
|
||||
|
||||
if (cooldowns.containsKey(player.getName())) {
|
||||
if (cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
|
||||
return;
|
||||
} else {
|
||||
boolean cooldown = false;
|
||||
for (int id : instances.keySet()) {
|
||||
EarthBlast blast = instances.get(id);
|
||||
if (blast.player == player && !blast.progressing) {
|
||||
blast.throwEarth();
|
||||
cooldown = true;
|
||||
ignore.add(blast);
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown)
|
||||
cooldowns.put(player.getName(), System.currentTimeMillis());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
redirectTargettedBlasts(player, ignore);
|
||||
}
|
||||
|
||||
public static boolean progress(int ID) {
|
||||
if (instances.containsKey(ID))
|
||||
return instances.get(ID).progress();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (int id : instances.keySet()) {
|
||||
instances.get(id).breakBlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static void redirectTargettedBlasts(Player player,
|
||||
ArrayList<EarthBlast> ignore) {
|
||||
for (int id : instances.keySet()) {
|
||||
EarthBlast blast = instances.get(id);
|
||||
|
||||
if (!blast.progressing || ignore.contains(blast))
|
||||
continue;
|
||||
|
||||
if (!blast.location.getWorld().equals(player.getWorld()))
|
||||
continue;
|
||||
|
||||
// if (Methods.isRegionProtectedFromBuild(player, Abilities.EarthBlast,
|
||||
// blast.location))
|
||||
// continue;
|
||||
|
||||
if (blast.player.equals(player))
|
||||
blast.redirect(player, getTargetLocation(player));
|
||||
|
||||
Location location = player.getEyeLocation();
|
||||
Vector vector = location.getDirection();
|
||||
Location mloc = blast.location;
|
||||
if (mloc.distance(location) <= range
|
||||
&& Methods.getDistanceFromLine(vector, location,
|
||||
blast.location) < deflectrange
|
||||
&& mloc.distance(location.clone().add(vector)) < mloc
|
||||
.distance(location.clone().add(
|
||||
vector.clone().multiply(-1)))) {
|
||||
blast.redirect(player, getTargetLocation(player));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void redirect(Player player, Location targetlocation) {
|
||||
if (progressing) {
|
||||
if (location.distance(player.getLocation()) <= range) {
|
||||
// direction = Methods.getDirection(location, targetlocation)
|
||||
// .normalize();
|
||||
settingup = false;
|
||||
destination = targetlocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void block(Player player) {
|
||||
for (int id : instances.keySet()) {
|
||||
EarthBlast blast = instances.get(id);
|
||||
|
||||
if (blast.player.equals(player))
|
||||
continue;
|
||||
|
||||
if (!blast.location.getWorld().equals(player.getWorld()))
|
||||
continue;
|
||||
|
||||
if (!blast.progressing)
|
||||
continue;
|
||||
|
||||
// if (Methods.isRegionProtectedFromBuild(player, Abilities.EarthBlast,
|
||||
// blast.location))
|
||||
// continue;
|
||||
|
||||
Location location = player.getEyeLocation();
|
||||
Vector vector = location.getDirection();
|
||||
Location mloc = blast.location;
|
||||
if (mloc.distance(location) <= range
|
||||
&& Methods.getDistanceFromLine(vector, location,
|
||||
blast.location) < deflectrange
|
||||
&& mloc.distance(location.clone().add(vector)) < mloc
|
||||
.distance(location.clone().add(
|
||||
vector.clone().multiply(-1)))) {
|
||||
blast.breakBlock();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDescription() {
|
||||
return "To use, place your cursor over an earthbendable object (dirt, rock, ores, etc) "
|
||||
+ "and tap sneak (default: shift). The object will temporarily turn to stone, "
|
||||
+ "indicating that you have it focused as the source for your ability. "
|
||||
+ "After you have selected an origin (you no longer need to be sneaking), "
|
||||
+ "simply left-click in any direction and you will see your object launch "
|
||||
+ "off in that direction, smashing into any creature in its path. If you look "
|
||||
+ "towards a creature when you use this ability, it will target that creature. "
|
||||
+ "A collision from Earth Blast both knocks the target back and deals some damage. "
|
||||
+ "You cannot have multiple of these abilities flying at the same time.";
|
||||
}
|
||||
|
||||
public static void removeAroundPoint(Location location, double radius) {
|
||||
|
||||
for (int id : instances.keySet()) {
|
||||
EarthBlast blast = instances.get(id);
|
||||
if (blast.location.getWorld().equals(location.getWorld()))
|
||||
if (blast.location.distance(location) <= radius)
|
||||
blast.breakBlock();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean annihilateBlasts(Location location, double radius,
|
||||
Player source) {
|
||||
boolean broke = false;
|
||||
for (int id : instances.keySet()) {
|
||||
EarthBlast blast = instances.get(id);
|
||||
if (blast.location.getWorld().equals(location.getWorld())
|
||||
&& !source.equals(blast.player))
|
||||
if (blast.location.distance(location) <= radius) {
|
||||
blast.breakBlock();
|
||||
broke = true;
|
||||
}
|
||||
}
|
||||
return broke;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ import org.bukkit.util.Vector;
|
|||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.ProjectKorra.waterbending.Plantbending;
|
||||
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.projectkorra.ProjectKorra.Methods;
|
|||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.TempBlock;
|
||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.ProjectKorra.firebending.FireBlast;
|
||||
|
||||
public class WaterManipulation {
|
||||
|
|
|
@ -143,6 +143,16 @@ Abilities:
|
|||
Range: 20
|
||||
Radius: 7
|
||||
Speed: 8
|
||||
EarthBlast:
|
||||
Enabled: true
|
||||
Description: "To use, place your cursor over an earthbendable object and tap sneak (default: shift). The object will temporarily turn to stone, indicating that you have it focused as the source for your ability. After you have selected an origin (you no longer need to be sneaking), simply left-click in any direction and you will see your object launch off in that direction, smashing into any creature in its path. If you look towards a creature when you use this ability, it will target that creature. A collision from Earth Blast both knocks the target back and deals some damage. You cannot have multiple of these abilities flying at the same time."
|
||||
CanHitSelf: false
|
||||
PrepareRange: 7
|
||||
Range: 20
|
||||
Speed: 35
|
||||
Revert: true
|
||||
Damage: 4
|
||||
Push: 0.3
|
||||
RaiseEarth:
|
||||
Enabled: true
|
||||
Description: "To use, simply left-click on an earthbendable block. A column of earth will shoot upwards from that location. Anything in the way of the column will be brought up with it, leaving talented benders the ability to trap brainless entities up there. Additionally, simply sneak (default shift) looking at an earthbendable block. A wall of earth will shoot upwards from that location. Anything in the way of the wall will be brought up with it."
|
||||
|
|
Loading…
Reference in a new issue