This commit is contained in:
MistPhizzle 2014-06-25 12:14:46 -04:00
parent 9a9dbf2db8
commit b24a818c8d
6 changed files with 323 additions and 4 deletions

View file

@ -20,6 +20,7 @@ import com.projectkorra.ProjectKorra.airbending.AirSpout;
import com.projectkorra.ProjectKorra.airbending.Tornado;
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
import com.projectkorra.ProjectKorra.earthbending.Catapult;
import com.projectkorra.ProjectKorra.earthbending.CompactColumn;
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
import com.projectkorra.ProjectKorra.firebending.FireJet;
@ -95,6 +96,10 @@ public class BendingManager implements Runnable {
EarthColumn.progress(ID);
}
for (int ID: CompactColumn.instances.keySet()) {
CompactColumn.progress(ID);
}
FireStream.dissipateAll();
} catch (Exception e) {
Methods.stopBending();

View file

@ -135,9 +135,9 @@ public class ConfigManager {
+ "will remain on. If you try to spout over an area with no water, snow or ice, "
+ "the spout will dissipate and you will fall. Click again with this ability selected to deactivate it.");
config.addDefault("Abilities.Water.WaterSpout.Height", 20);
plugin.getConfig().addDefault("Abilities.Earth.Passive.Duration", 2500);
config.addDefault("Abilities.Earth.Catapult.Enabled", true);
config.addDefault("Abilities.Earth.Catapult.Description", "To use, left-click while looking in the direction you want to be launched. "
+ "A pillar of earth will jut up from under you and launch you in that direction - "
@ -149,6 +149,20 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.Catapult.Speed", 12);
config.addDefault("Abilities.Earth.Catapult.Push", 5);
config.addDefault("Abilities.Earth.Collapse.Enabled", true);
config.addDefault("Abilities.Earth.Collapse.Description", " To use, simply left-click on an earthbendable block. "
+ "That block and the earthbendable blocks above it will be shoved "
+ "back into the earth below them, if they can. "
+ "This ability does have the capacity to trap something inside of it, "
+ "although it is incredibly difficult to do so. "
+ "Additionally, press sneak with this ability to affect an area around your targetted location - "
+ "all earth that can be moved downwards will be moved downwards. "
+ "This ability is especially risky or deadly in caves, depending on the "
+ "earthbender's goal and technique.");
config.addDefault("Abilities.Earth.Collapse.Range", 20);
config.addDefault("Abilities.Earth.Collapse.Radius", 7);
config.addDefault("Abilities.Earth.Collapse.Speed", 8);
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. "
@ -161,7 +175,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.RaiseEarth.Wall.Range", 15);
config.addDefault("Abilities.Earth.RaiseEarth.Wall.Height", 6);
config.addDefault("Abilities.Earth.RaiseEarth.Wall.Width", 6);
config.addDefault("Abilities.Fire.FireJet.Enabled", true);
config.addDefault("Abilities.Fire.FireJet.Description", "This ability is used for a limited burst of flight for firebenders. Clicking with this "
+ "ability selected will launch you in the direction you're looking, granting you "

View file

@ -50,8 +50,11 @@ import com.projectkorra.ProjectKorra.airbending.Tornado;
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
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.EarthColumn;
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
import com.projectkorra.ProjectKorra.earthbending.EarthWall;
import com.projectkorra.ProjectKorra.firebending.Enflamed;
import com.projectkorra.ProjectKorra.firebending.FireJet;
import com.projectkorra.ProjectKorra.firebending.FireStream;
@ -175,6 +178,9 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("RaiseEarth")) {
new EarthWall(player);
}
if (abil.equalsIgnoreCase("Collapse")) {
new Collapse(player);
}
}
}
}
@ -336,6 +342,10 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("RaiseEarth")) {
new EarthColumn(player);
}
if (abil.equalsIgnoreCase("Collapse")) {
new CompactColumn(player);
}
}
if (Methods.isFireAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {

View file

@ -0,0 +1,97 @@
package com.projectkorra.ProjectKorra.earthbending;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
public class Collapse {
public static final int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Collapse.Range");
private static final double defaultradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.Collapse.Radius");
private static final int height = EarthColumn.standardheight;
private ConcurrentHashMap<Block, Block> blocks = new ConcurrentHashMap<Block, Block>();
private ConcurrentHashMap<Block, Integer> baseblocks = new ConcurrentHashMap<Block, Integer>();
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private double radius = defaultradius;
private Player player;
public Collapse(Player player) {
if (cooldowns.containsKey(player.getName())) {
if (cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
return;
} else {
cooldowns.remove(player.getName());
}
}
// if (AvatarState.isAvatarState(player))
// radius = AvatarState.getValue(defaultradius);
this.player = player;
Block sblock = Methods.getEarthSourceBlock(player, range);
Location location;
if (sblock == null) {
location = player.getTargetBlock(
Methods.getTransparentEarthbending(), range).getLocation();
} else {
location = sblock.getLocation();
}
for (Block block : Methods.getBlocksAroundPoint(location, radius)) {
if (Methods.isEarthbendable(player, block)
&& !blocks.containsKey(block)
&& block.getY() >= location.getBlockY()) {
getAffectedBlocks(block);
}
}
if (!baseblocks.isEmpty()) {
cooldowns.put(player.getName(), System.currentTimeMillis());
}
for (Block block : baseblocks.keySet()) {
new CompactColumn(player, block.getLocation());
}
}
private void getAffectedBlocks(Block block) {
Block baseblock = block;
int tall = 0;
ArrayList<Block> bendableblocks = new ArrayList<Block>();
bendableblocks.add(block);
for (int i = 1; i <= height; i++) {
Block blocki = block.getRelative(BlockFace.DOWN, i);
if (Methods.isEarthbendable(player, blocki)) {
baseblock = blocki;
bendableblocks.add(blocki);
tall++;
} else {
break;
}
}
baseblocks.put(baseblock, tall);
for (Block blocki : bendableblocks) {
blocks.put(blocki, baseblock);
}
}
public static String getDescription() {
return " To use, simply left-click on an earthbendable block. "
+ "That block and the earthbendable blocks above it will be shoved "
+ "back into the earth below them, if they can. "
+ "This ability does have the capacity to trap something inside of it, "
+ "although it is incredibly difficult to do so. "
+ "Additionally, press sneak with this ability to affect an area around your targetted location - "
+ "all earth that can be moved downwards will be moved downwards. "
+ "This ability is especially risky or deadly in caves, depending on the "
+ "earthbender's goal and technique.";
}
}

View file

@ -0,0 +1,187 @@
package com.projectkorra.ProjectKorra.earthbending;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
public class CompactColumn {
public static ConcurrentHashMap<Integer, CompactColumn> instances = new ConcurrentHashMap<Integer, CompactColumn>();
private static ConcurrentHashMap<Block, Block> alreadydoneblocks = new ConcurrentHashMap<Block, Block>();
private static int ID = Integer.MIN_VALUE;
private static double range = Collapse.range;
private static int height = EarthColumn.standardheight;
private static double speed = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.Collapse.Speed");
private static final Vector direction = new Vector(0, -1, 0);
private static long interval = (long) (1000. / speed);
private Location origin;
private Location location;
private Block block;
private Player player;
private int distance;
private int id;
private long time;
private ConcurrentHashMap<Block, Block> affectedblocks = new ConcurrentHashMap<Block, Block>();
public CompactColumn(Player player) {
if (Collapse.cooldowns.containsKey(player.getName())) {
if (Collapse.cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
return;
} else {
Collapse.cooldowns.remove(player.getName());
}
}
block = Methods.getEarthSourceBlock(player, range);
if (block == null)
return;
origin = block.getLocation();
location = origin.clone();
this.player = player;
distance = Methods.getEarthbendableBlocksLength(player, block, direction
.clone().multiply(-1), height);
loadAffectedBlocks();
if (distance != 0) {
if (canInstantiate()) {
id = ID;
instances.put(id, this);
Collapse.cooldowns.put(player.getName(), System.currentTimeMillis());
if (ID >= Integer.MAX_VALUE) {
ID = Integer.MIN_VALUE;
}
ID++;
time = System.currentTimeMillis() - interval;
}
}
}
public CompactColumn(Player player, Location origin) {
// Methods.verbose("New compact column");
this.origin = origin;
this.player = player;
block = origin.getBlock();
// Methods.verbose(block);
// Methods.verbose(origin);
location = origin.clone();
distance = Methods.getEarthbendableBlocksLength(player, block, direction
.clone().multiply(-1), height);
loadAffectedBlocks();
if (distance != 0) {
if (canInstantiate()) {
for (Block blocki : affectedblocks.keySet()) {
EarthColumn.resetBlock(blocki);
}
id = ID;
instances.put(id, this);
if (ID >= Integer.MAX_VALUE) {
ID = Integer.MIN_VALUE;
}
ID++;
time = System.currentTimeMillis() - interval;
}
}
}
private void loadAffectedBlocks() {
affectedblocks.clear();
Block thisblock;
for (int i = 0; i <= distance; i++) {
thisblock = block.getWorld().getBlockAt(
location.clone().add(direction.clone().multiply(-i)));
affectedblocks.put(thisblock, thisblock);
if (EarthColumn.blockInAllAffectedBlocks(thisblock))
EarthColumn.revertBlock(thisblock);
}
}
private boolean blockInAffectedBlocks(Block block) {
if (affectedblocks.containsKey(block)) {
return true;
}
return false;
}
public static boolean blockInAllAffectedBlocks(Block block) {
for (int ID : instances.keySet()) {
if (instances.get(ID).blockInAffectedBlocks(block))
return true;
}
return false;
}
public static void revertBlock(Block block) {
for (int ID : instances.keySet()) {
if (instances.get(ID).blockInAffectedBlocks(block)) {
instances.get(ID).affectedblocks.remove(block);
}
}
}
private boolean canInstantiate() {
for (Block block : affectedblocks.keySet()) {
if (blockInAllAffectedBlocks(block)
|| alreadydoneblocks.containsKey(block)) {
return false;
}
}
return true;
}
public boolean progress() {
if (System.currentTimeMillis() - time >= interval) {
time = System.currentTimeMillis();
if (!moveEarth()) {
for (Block blocki : affectedblocks.keySet()) {
EarthColumn.resetBlock(blocki);
}
instances.remove(id);
// for (Block block : affectedblocks.keySet()) {
// alreadydoneblocks.put(block, block);
// }
return false;
}
}
return true;
}
private boolean moveEarth() {
Block block = location.getBlock();
location = location.add(direction);
if (block == null || location == null || distance == 0) {
return false;
}
Methods.moveEarth(player, block, direction, distance);
loadAffectedBlocks();
if (location.distance(origin) >= distance) {
return false;
}
return true;
}
public static boolean progress(int ID) {
return instances.get(ID).progress();
}
public static void removeAll() {
for (int id : instances.keySet()) {
instances.remove(id);
}
}
}

View file

@ -64,7 +64,7 @@ Abilities:
Height: 20
Tornado:
Enabled: true
Description: "To use, simply sneak (default: shift). This will create a swirling vortex at the targeted lcoation. Any creature or object caught in the vortex will be launched up and out in some random direction. If another player gets caught in the vortex, the launching effect is minimal. Tornado can also be used to transport the user. If the user gets caught in his/her own tornado, his/her movements are much more manageable. Provided the user doesn't fall out of the vortex, it will take him to a maximum height and move him in the general direction he/she is looking. Skilled airbenders can scale anything with this ability."
Description: "To use, simply sneak (default: shift). This will create a swirling vortex at the targeted location. Any creature or object caught in the vortex will be launched up and out in some random direction. If another player gets caught in the vortex, the launching effect is minimal. Tornado can also be used to transport the user. If the user gets caught in his/her own tornado, his/her movements are much more manageable. Provided the user doesn't fall out of the vortex, it will take him to a maximum height and move him in the general direction he/she is looking. Skilled airbenders can scale anything with this ability."
Radius: 10
Height: 25
Range: 25
@ -93,6 +93,12 @@ Abilities:
Length: 7
Speed: 12
Push: 5
Collapse:
Enabled: true
Description: "To use, simply left-click an earthbendable block. That block and the earthbendable blocks above it will be shoved back into the earth below, if they can. This ability does have the capacity to trap something inside of it, although it is incredibly difficult to do so. Additionally, press sneak with this ability to affect an area around your targeted location - all earth that can be moved downwards will be moved downwards. This ability is especially risky or deadly in caves, depending on the earthbender's goal and technique."
Range: 20
Radius: 7
Speed: 8
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."