Code Format Cleanup

This commit is contained in:
jack lin 2014-07-19 18:18:28 +12:00
parent dc70204fe5
commit e7e7eb622b
44 changed files with 485 additions and 844 deletions

View file

@ -19,6 +19,8 @@ import com.projectkorra.ProjectKorra.Ability.AvatarState;
public class AirBlast {
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static ConcurrentHashMap<Integer, AirBlast> instances = new ConcurrentHashMap<Integer, AirBlast>();
private static ConcurrentHashMap<Player, Location> origins = new ConcurrentHashMap<Player, Location>();
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
@ -29,8 +31,6 @@ public class AirBlast {
private static int ID = Integer.MIN_VALUE;
static final int maxticks = 10000;
static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static double speed = config.getDouble("Abilities.Air.AirBlast.Speed");
public static double defaultrange = config.getDouble("Abilities.Air.AirBlast.Range");
public static double affectingradius = config.getDouble("Abilities.Air.AirBlast.Radius");
@ -84,11 +84,9 @@ public class AirBlast {
origins.remove(player);
Entity entity = Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
if (entity != null) {
direction = Methods.getDirection(origin, entity.getLocation())
.normalize();
direction = Methods.getDirection(origin, entity.getLocation()).normalize();
} else {
direction = Methods.getDirection(origin,
Methods.getTargetedLocation(player, range)).normalize();
direction = Methods.getDirection(origin, Methods.getTargetedLocation(player, range)).normalize();
}
} else {
origin = player.getEyeLocation();
@ -105,8 +103,7 @@ public class AirBlast {
// timers.put(player, System.currentTimeMillis());
}
public AirBlast(Location location, Vector direction, Player player,
double factorpush, AirBurst burst) {
public AirBlast(Location location, Vector direction, Player player, double factorpush, AirBurst burst) {
if (location.getBlock().isLiquid()) {
return;
}
@ -126,14 +123,11 @@ public class AirBlast {
}
public static void setOrigin(Player player) {
Location location = Methods.getTargetedLocation(player,
originselectrange, Methods.nonOpaque);
if (location.getBlock().isLiquid()
|| Methods.isSolid(location.getBlock()))
Location location = Methods.getTargetedLocation(player, originselectrange, Methods.nonOpaque);
if (location.getBlock().isLiquid() || Methods.isSolid(location.getBlock()))
return;
if (Methods.isRegionProtectedFromBuild(player, "AirBlast",
location))
if (Methods.isRegionProtectedFromBuild(player, "AirBlast", location))
return;
if (origins.containsKey(player)) {
@ -149,8 +143,7 @@ public class AirBlast {
return false;
}
if (Methods.isRegionProtectedFromBuild(player, "AirBlast",
location)) {
if (Methods.isRegionProtectedFromBuild(player, "AirBlast", location)) {
instances.remove(id);
return false;
}
@ -170,12 +163,10 @@ public class AirBlast {
// }
Block block = location.getBlock();
for (Block testblock : Methods.getBlocksAroundPoint(location,
affectingradius)) {
for (Block testblock : Methods.getBlocksAroundPoint(location, affectingradius)) {
if (testblock.getType() == Material.FIRE) {
testblock.setType(Material.AIR);
testblock.getWorld().playEffect(testblock.getLocation(),
Effect.EXTINGUISH, 0);
testblock.getWorld().playEffect(testblock.getLocation(), Effect.EXTINGUISH, 0);
}
if (((block.getType() == Material.LEVER) || (block.getType() == Material.STONE_BUTTON))
&& !affectedlevers.contains(block)) {
@ -196,10 +187,8 @@ public class AirBlast {
affectedlevers.add(block);
}
}
if ((Methods.isSolid(block) || block.isLiquid())
&& !affectedlevers.contains(block)) {
if (block.getType() == Material.LAVA
|| block.getType() == Material.STATIONARY_LAVA) {
if ((Methods.isSolid(block) || block.isLiquid()) && !affectedlevers.contains(block)) {
if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) {
if (block.getData() == full) {
block.setType(Material.OBSIDIAN);
} else {
@ -217,8 +206,7 @@ public class AirBlast {
return false;
}
for (Entity entity : Methods.getEntitiesAroundPoint(location,
affectingradius)) {
for (Entity entity : Methods.getEntitiesAroundPoint(location, affectingradius)) {
// if (source == null) {
// if (affectedentities.contains(entity))
// continue;
@ -266,20 +254,14 @@ public class AirBlast {
factor *= 1 - location.distance(origin) / (2 * range);
if (isUser
&& Methods.isSolid(player.getLocation().add(0, -.5, 0)
.getBlock())) {
if (isUser && Methods.isSolid(player.getLocation().add(0, -.5, 0).getBlock())) {
factor *= .5;
}
double comp = velocity.dot(push.clone().normalize());
if (comp > factor) {
velocity.multiply(.5);
velocity.add(push
.clone()
.normalize()
.multiply(
velocity.clone().dot(push.clone().normalize())));
velocity.add(push.clone().normalize().multiply(velocity.clone().dot(push.clone().normalize())));
} else if (comp + factor * .5 > factor) {
velocity.add(push.clone().multiply(factor - comp));
} else {
@ -308,8 +290,7 @@ public class AirBlast {
new Flight((Player) entity, player);
}
if (entity.getFireTicks() > 0)
entity.getWorld().playEffect(entity.getLocation(),
Effect.EXTINGUISH, 0);
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
entity.setFireTicks(0);
}
}

View file

@ -19,6 +19,7 @@ public class AirPassive {
private static int speedPower = ProjectKorra.plugin.getConfig().getInt("Abilities.Air.Passive.Speed");
private static int jumpPower = ProjectKorra.plugin.getConfig().getInt("Abilities.Air.Passive.Jump");
public static float getExhaustion(Player player, float level) {
if (!food.keySet().contains(player)) {
food.put(player, level);

View file

@ -20,11 +20,10 @@ public class AirShield {
public static ConcurrentHashMap<Integer, AirShield> instances = new ConcurrentHashMap<Integer, AirShield>();
private static double maxradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Air.AirShield.Radius");
private static int numberOfStreams = (int) (.75 * (double) maxradius);
private static boolean isToggle = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Air.AirShield.IsAvatarStateToggle");
private static int numberOfStreams = (int) (.75 * (double) maxradius);
private double radius = 2;
private double speedfactor;
private Player player;

View file

@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -16,22 +17,24 @@ import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
public class AirSuction {
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static ConcurrentHashMap<Integer, AirSuction> instances = new ConcurrentHashMap<Integer, AirSuction>();
private static ConcurrentHashMap<Player, Location> origins = new ConcurrentHashMap<Player, Location>();
private static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static ConcurrentHashMap<Player, Location> origins = new ConcurrentHashMap<Player, Location>();
// private static ConcurrentHashMap<Player, Long> timers = new
// ConcurrentHashMap<Player, Long>();
static final long soonesttime = ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown");
static final long soonesttime = config.getLong("Properties.GlobalCooldown");
static final double maxspeed = AirBlast.maxspeed;
private static int ID = Integer.MIN_VALUE;
private static final int maxticks = AirBlast.maxticks;
static final double maxspeed = AirBlast.maxspeed;
private static double speed = ProjectKorra.plugin.getConfig().getDouble("Abilities.Air.AirSuction.Speed");
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Air.AirSuction.Range");
private static double affectingradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Air.AirSuction.Radius");
private static double pushfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Air.AirSuction.Push");
private static double speed = config.getDouble("Abilities.Air.AirSuction.Speed");
private static double range = config.getDouble("Abilities.Air.AirSuction.Range");
private static double affectingradius = config.getDouble("Abilities.Air.AirSuction.Radius");
private static double pushfactor = config.getDouble("Abilities.Air.AirSuction.Push");
private static double originselectrange = 10;
// private static long interval = AirBlast.interval;

View file

@ -27,26 +27,25 @@ import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
public class AirSwipe {
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static ConcurrentHashMap<Integer, AirSwipe> instances = new ConcurrentHashMap<Integer, AirSwipe>();
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
// private static ConcurrentHashMap<Player, Long> timers = new
// ConcurrentHashMap<Player, Long>();
// static final long soonesttime = ConfigManager.airSwipeCooldown;
public static FileConfiguration config = ProjectKorra.plugin.getConfig();
private static int ID = Integer.MIN_VALUE;
private static int defaultdamage = config.getInt("Abilities.Air.AirSwipe.Damage");
private static double affectingradius = config.getDouble("Abilities.Air.AirSwipe.Radius");
private static double defaultpushfactor = config.getDouble("Abilities.Air.AirSwipe.Push");
private static double range = config.getDouble("Abilities.Air.AirSwipe.Range");
private static int arc = config.getInt("Abilities.Air.AirSwipe.Arc");
private static int stepsize = 4;
private static int arc = config.getInt("Abilities.Air.AirSwipe.Arc");
private static int defaultdamage = config.getInt("Abilities.Air.AirSwipe.Damage");
private static double defaultpushfactor = config.getDouble("Abilities.Air.AirSwipe.Push");
private static double affectingradius = config.getDouble("Abilities.Air.AirSwipe.Radius");
private static double range = config.getDouble("Abilities.Air.AirSwipe.Range");
private static double speed = config.getDouble("Abilities.Air.AirSwipe.Speed");
private static double maxfactor = config.getDouble("Abilities.Air.AirSwipe.ChargeFactor");
private static byte full = AirBlast.full;
private static long maxchargetime = 3000;
private static double maxfactor = config.getDouble("Abilities.Air.AirSwipe.ChargeFactor");
private double speedfactor;
@ -167,8 +166,7 @@ public class AirSwipe {
player.getWorld().playEffect(
player.getEyeLocation(),
Effect.SMOKE,
Methods.getIntCardinalDirection(player.getEyeLocation()
.getDirection()), 3);
Methods.getIntCardinalDirection(player.getEyeLocation().getDirection()), 3);
}
}
return true;
@ -179,8 +177,7 @@ public class AirSwipe {
for (Vector direction : elements.keySet()) {
Location location = elements.get(direction);
if (direction != null && location != null) {
location = location.clone().add(
direction.clone().multiply(speedfactor));
location = location.clone().add(direction.clone().multiply(speedfactor));
elements.replace(direction, location);
if (location.distance(origin) > range || Methods.isRegionProtectedFromBuild(player, "AirSwipe", location)) {
@ -191,18 +188,15 @@ public class AirSwipe {
double radius = FireBlast.affectingradius;
Player source = player;
if (EarthBlast.annihilateBlasts(location, radius, source)
|| WaterManipulation.annihilateBlasts(location,
radius, source)
|| FireBlast.annihilateBlasts(location, radius,
source)) {
|| WaterManipulation.annihilateBlasts(location,radius, source)
|| FireBlast.annihilateBlasts(location, radius, source)) {
elements.remove(direction);
damage = 0;
continue;
}
Block block = location.getBlock();
for (Block testblock : Methods.getBlocksAroundPoint(location,
affectingradius)) {
for (Block testblock : Methods.getBlocksAroundPoint(location, affectingradius)) {
if (testblock.getType() == Material.FIRE) {
testblock.setType(Material.AIR);
}
@ -217,8 +211,7 @@ public class AirSwipe {
} else {
elements.remove(direction);
}
if (block.getType() == Material.LAVA
|| block.getType() == Material.STATIONARY_LAVA) {
if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) {
if (block.getData() == full) {
block.setType(Material.OBSIDIAN);
} else {
@ -244,15 +237,12 @@ public class AirSwipe {
private void affectPeople(Location location, Vector direction) {
Methods.removeSpouts(location, player);
for (Entity entity : Methods.getEntitiesAroundPoint(location,
affectingradius)) {
if (Methods.isRegionProtectedFromBuild(player, "AirSwipe",
entity.getLocation()))
for (Entity entity : Methods.getEntitiesAroundPoint(location, affectingradius)) {
if (Methods.isRegionProtectedFromBuild(player, "AirSwipe", entity.getLocation()))
continue;
if (entity.getEntityId() != player.getEntityId()) {
if (AvatarState.isAvatarState(player)) {
entity.setVelocity(direction.multiply(AvatarState
.getValue(pushfactor)));
entity.setVelocity(direction.multiply(AvatarState.getValue(pushfactor)));
} else {
entity.setVelocity(direction.multiply(pushfactor));
}

View file

@ -16,17 +16,17 @@ import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
public class Tornado {
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static ConcurrentHashMap<Integer, Tornado> instances = new ConcurrentHashMap<Integer, Tornado>();
static FileConfiguration config = ProjectKorra.plugin.getConfig();
private static double maxradius = config.getDouble("Abilities.Air.Tornado.Radius");
private static double maxheight = config.getDouble("Abilities.Air.Tornado.Height");
private static double range = config.getDouble("Abilities.Air.Tornado.Range");
private static int numberOfStreams = (int) (.3 * (double) maxheight);
private static double NPCpushfactor = config.getDouble("Abilities.Air.Tornado.MobPushFactor");
private static double PCpushfactor = config.getDouble("Abilities.Air.Tornado.PlayerPushFactor");
private static double maxradius = config.getDouble("Abilities.Air.Tornado.Radius");
private static double range = config.getDouble("Abilities.Air.Tornado.Range");
private static double NPCpushfactor = config.getDouble("Abilities.Air.Tornado.MobPushFactor");
private static int numberOfStreams = (int) (.3 * (double) maxheight);
// private static double speed = .75;
private double height = 2;
@ -69,8 +69,7 @@ public class Tornado {
instances.remove(player.getEntityId());
return false;
}
if (!Methods.canBend(player.getName(), "Tornado")
|| player.getEyeLocation().getBlock().isLiquid()) {
if (!Methods.canBend(player.getName(), "Tornado") || player.getEyeLocation().getBlock().isLiquid()) {
// player.setAllowFlight(canfly);
instances.remove(player.getEntityId());
return false;
@ -85,8 +84,7 @@ public class Tornado {
return false;
}
if (Methods
.isRegionProtectedFromBuild(player, "AirBlast", origin)) {
if (Methods.isRegionProtectedFromBuild(player, "AirBlast", origin)) {
instances.remove(player.getEntityId());
return false;
}
@ -104,17 +102,14 @@ public class Tornado {
origin.setY(origin.getY() - 1. / 10. * height);
for (Entity entity : Methods.getEntitiesAroundPoint(origin, height)) {
if (Methods.isRegionProtectedFromBuild(player,
"AirBlast", entity.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "AirBlast", entity.getLocation()))
continue;
double y = entity.getLocation().getY();
double factor;
if (y > origin.getY() && y < origin.getY() + height) {
factor = (y - origin.getY()) / height;
Location testloc = new Location(origin.getWorld(),
origin.getX(), y, origin.getZ());
if (testloc.distance(entity.getLocation()) < radius
* factor) {
Location testloc = new Location(origin.getWorld(), origin.getX(), y, origin.getZ());
if (testloc.distance(entity.getLocation()) < radius * factor) {
double x, z, vx, vz, mag;
double angle = 100;
double vy = 0.7 * NPCpushfactor;
@ -133,8 +128,7 @@ public class Tornado {
}
if (entity.getEntityId() == player.getEntityId()) {
Vector direction = player.getEyeLocation()
.getDirection().clone().normalize();
Vector direction = player.getEyeLocation().getDirection().clone().normalize();
vx = direction.getX();
vz = direction.getZ();
Location playerloc = player.getLocation();
@ -174,16 +168,12 @@ public class Tornado {
y = origin.getY() + timefactor * (double) i;
factor = (double) i / height;
x = origin.getX() + timefactor * factor * radius
* Math.cos(angle);
z = origin.getZ() + timefactor * factor * radius
* Math.sin(angle);
x = origin.getX() + timefactor * factor * radius * Math.cos(angle);
z = origin.getZ() + timefactor * factor * radius * Math.sin(angle);
Location effect = new Location(origin.getWorld(), x, y, z);
if (!Methods.isRegionProtectedFromBuild(player,
"AirBlast", effect))
origin.getWorld().playEffect(effect, Effect.SMOKE, 4,
(int) AirBlast.defaultrange);
if (!Methods.isRegionProtectedFromBuild(player, "AirBlast", effect))
origin.getWorld().playEffect(effect, Effect.SMOKE, 4, (int) AirBlast.defaultrange);
angles.put(i, angles.get(i) + 25 * (int) speedfactor);
}

View file

@ -3,6 +3,7 @@ package com.projectkorra.ProjectKorra.chiblocking;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -14,12 +15,13 @@ import com.projectkorra.ProjectKorra.ProjectKorra;
public class ChiPassive {
public static double FallReductionFactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Chi.Passive.FallReductionFactor");
public static int jumpPower = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.Jump");
public static int speedPower = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.Speed");
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static int dodgeChance = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.BlockChi.DodgeChance");
public static int duration = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.BlockChi.Duration");
public static double FallReductionFactor = config.getDouble("Abilities.Chi.Passive.FallReductionFactor");
public static int jumpPower = config.getInt("Abilities.Chi.Passive.Jump");
public static int speedPower = config.getInt("Abilities.Chi.Passive.Speed");
public static int dodgeChance = config.getInt("Abilities.Chi.Passive.BlockChi.DodgeChance");
public static int duration = config.getInt("Abilities.Chi.Passive.BlockChi.Duration");
public static boolean willChiBlock(Player player) {
Random rand = new Random();

View file

@ -15,17 +15,18 @@ import com.projectkorra.ProjectKorra.ProjectKorra;
public class RapidPunch {
private static int damage = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.RapidPunch.Damage");
private int distance = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.RapidPunch.Distance");
private long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Chi.RapidPunch.Cooldown");
private static int punches = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.RapidPunch.Punches");
private static Map<String, Long> cooldowns = new HashMap<String, Long>();
public static ConcurrentHashMap<Player, RapidPunch> instance = new ConcurrentHashMap<Player, RapidPunch>();
public static List<Player> punching = new ArrayList<Player>();
private static Map<String, Long> cooldowns = new HashMap<String, Long>();
private static int damage = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.RapidPunch.Damage");
private static int punches = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.RapidPunch.Punches");
private int distance = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.RapidPunch.Distance");
private long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Chi.RapidPunch.Cooldown");
private int numpunches;
// private long timers;
private Entity target;
public static List<Player> punching = new ArrayList<Player>();
public RapidPunch(Player p) {// , Entity t) {
if (instance.containsKey(p))

View file

@ -12,6 +12,8 @@ import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
public class Collapse {
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
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");
@ -19,9 +21,7 @@ public class Collapse {
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) {

View file

@ -13,16 +13,13 @@ 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 range = Collapse.range;
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;

View file

@ -19,10 +19,14 @@ import com.projectkorra.ProjectKorra.TempBlock;
import com.projectkorra.ProjectKorra.TempPotionEffect;
public class EarthArmor {
public static ConcurrentHashMap<Player, EarthArmor> instances = new ConcurrentHashMap<Player, EarthArmor>();
public static Map<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static long interval = 2000;
private static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.EarthArmor.Cooldown");
private static long duration = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.EarthArmor.Duration");
private static int strength = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.EarthArmor.Strength");
private static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.EarthArmor.Cooldown");
private static int range = 7;
private Player player;
@ -35,10 +39,6 @@ public class EarthArmor {
private boolean complete = false;
public ItemStack[] oldarmor;
private static long interval = 2000;
public static ConcurrentHashMap<Player, EarthArmor> instances = new ConcurrentHashMap<Player, EarthArmor>();
public static Map<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
public EarthArmor(Player player) {
if (instances.containsKey(player)) {
return;
@ -55,8 +55,7 @@ public class EarthArmor {
this.player = player;
headblock = player.getTargetBlock(Methods.getTransparentEarthbending(),
range);
if (Methods.getEarthbendableBlocksLength(player, headblock, new Vector(0,
-1, 0), 2) >= 2) {
if (Methods.getEarthbendableBlocksLength(player, headblock, new Vector(0,-1, 0), 2) >= 2) {
legsblock = headblock.getRelative(BlockFace.DOWN);
headtype = headblock.getType();
legstype = legsblock.getType();
@ -107,8 +106,7 @@ public class EarthArmor {
newlegsblock = legsblocklocation.getBlock();
}
if (Methods.isTransparentToEarthbending(player, newheadblock)
&& !newheadblock.isLiquid()) {
if (Methods.isTransparentToEarthbending(player, newheadblock) && !newheadblock.isLiquid()) {
Methods.breakBlock(newheadblock);
} else if (!Methods.isEarthbendable(player, newheadblock)
&& !newheadblock.isLiquid()
@ -117,8 +115,7 @@ public class EarthArmor {
return false;
}
if (Methods.isTransparentToEarthbending(player, newlegsblock)
&& !newlegsblock.isLiquid()) {
if (Methods.isTransparentToEarthbending(player, newlegsblock) && !newlegsblock.isLiquid()) {
Methods.breakBlock(newlegsblock);
} else if (!Methods.isEarthbendable(player, newlegsblock)
&& !newlegsblock.isLiquid()
@ -218,8 +215,7 @@ public class EarthArmor {
}
if (eartharmor.formed) {
if (System.currentTimeMillis() > eartharmor.starttime + duration
&& !eartharmor.complete) {
if (System.currentTimeMillis() > eartharmor.starttime + duration && !eartharmor.complete) {
eartharmor.complete = true;
eartharmor.removeEffect();
return;

View file

@ -13,18 +13,16 @@ import com.projectkorra.ProjectKorra.ProjectKorra;
public class EarthColumn {
public static ConcurrentHashMap<Integer, EarthColumn> instances = new ConcurrentHashMap<Integer, EarthColumn>();
public static final int standardheight = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.RaiseEarth.Column.Height");
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static ConcurrentHashMap<Block, Block> alreadydoneblocks = new ConcurrentHashMap<Block, Block>();
private static ConcurrentHashMap<Block, Integer> baseblocks = new ConcurrentHashMap<Block, Integer>();
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
public static final int standardheight = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.RaiseEarth.Column.Height");
private static int ID = Integer.MIN_VALUE;
private static double range = 20;
private static double speed = 8;
private static final Vector direction = new Vector(0, 1, 0);
private static long interval = (long) (1000. / speed);
private Location origin;
@ -52,8 +50,7 @@ public class EarthColumn {
return;
origin = block.getLocation();
location = origin.clone();
distance = Methods.getEarthbendableBlocksLength(player, block,
direction.clone().multiply(-1), height);
distance = Methods.getEarthbendableBlocksLength(player, block, direction.clone().multiply(-1), height);
} catch (IllegalStateException e) {
return;
}
@ -81,8 +78,7 @@ public class EarthColumn {
location = origin.clone();
block = location.getBlock();
this.player = player;
distance = Methods.getEarthbendableBlocksLength(player, block, direction
.clone().multiply(-1), height);
distance = Methods.getEarthbendableBlocksLength(player, block, direction.clone().multiply(-1), height);
loadAffectedBlocks();
@ -105,8 +101,7 @@ public class EarthColumn {
location = origin.clone();
block = location.getBlock();
this.player = player;
distance = Methods.getEarthbendableBlocksLength(player, block, direction
.clone().multiply(-1), height);
distance = Methods.getEarthbendableBlocksLength(player, block, direction.clone().multiply(-1), height);
loadAffectedBlocks();
@ -127,8 +122,7 @@ public class EarthColumn {
affectedblocks.clear();
Block thisblock;
for (int i = 0; i <= distance; i++) {
thisblock = block.getWorld().getBlockAt(
location.clone().add(direction.clone().multiply(-i)));
thisblock = block.getWorld().getBlockAt(location.clone().add(direction.clone().multiply(-i)));
affectedblocks.put(thisblock, thisblock);
if (CompactColumn.blockInAllAffectedBlocks(thisblock))
CompactColumn.revertBlock(thisblock);
@ -160,8 +154,7 @@ public class EarthColumn {
private boolean canInstantiate() {
for (Block block : affectedblocks.keySet()) {
if (blockInAllAffectedBlocks(block)
|| alreadydoneblocks.containsKey(block)) {
if (blockInAllAffectedBlocks(block) || alreadydoneblocks.containsKey(block)) {
return false;
}
}
@ -176,11 +169,8 @@ public class EarthColumn {
for (Block block : affectedblocks.keySet()) {
alreadydoneblocks.put(block, block);
}
baseblocks.put(
location.clone()
.add(direction.clone().multiply(
-1 * (distance - 1))).getBlock(),
(distance - 1));
baseblocks.put(location.clone().add(direction.clone().multiply(-1 * (distance - 1)))
.getBlock(), (distance - 1));
return false;
}

View file

@ -16,8 +16,9 @@ import com.projectkorra.ProjectKorra.ProjectKorra;
public class EarthGrab {
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthGrab.Range");
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthGrab.Range");
public EarthGrab(Player player) {
// Methods.verbose("initiating");
@ -34,8 +35,7 @@ public class EarthGrab {
double lowestdistance = range + 1;
Entity closestentity = null;
for (Entity entity : Methods.getEntitiesAroundPoint(origin, range)) {
if (Methods.getDistanceFromLine(direction, origin,
entity.getLocation()) <= 3
if (Methods.getDistanceFromLine(direction, origin, entity.getLocation()) <= 3
&& (entity instanceof LivingEntity)
&& (entity.getEntityId() != player.getEntityId())) {
double distance = origin.distance(entity.getLocation());

View file

@ -17,6 +17,7 @@ public class EarthPassive {
public static ConcurrentHashMap<Block, Long> sandblocks = new ConcurrentHashMap<Block, Long>();
public static ConcurrentHashMap<Block, Material> sandidentities = new ConcurrentHashMap<Block, Material>();
private static final long duration = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.Passive.Duration");
public static boolean softenLanding(Player player) {

View file

@ -20,7 +20,6 @@ public class EarthTunnel {
// private static final double speed = 10;
private static boolean revert = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth.EarthTunnel.Revert");
private static final long interval = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.EarthTunnel.Interval");
private Player player;

View file

@ -15,6 +15,7 @@ import com.projectkorra.ProjectKorra.ProjectKorra;
public class Extraction {
private static Map<String, Long> cooldowns = new HashMap<String, Long>();
private long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.Extraction.Cooldown");
private static int doublechance = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Extraction.DoubleLootChance");
private static int triplechance = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Extraction.TripleLootChance");

View file

@ -21,20 +21,17 @@ public class Ripple {
static final double radius = 15;
private static final int damage = 5;
private static int ID = Integer.MIN_VALUE;
private Player player;
private Vector direction;
private Location origin, location;
private ArrayList<Location> locations = new ArrayList<Location>();
private ArrayList<Entity> entities = new ArrayList<Entity>();
private Block block1, block2, block3, block4;
private int id;
private int step = 0;
private int maxstep;
private ArrayList<Location> locations = new ArrayList<Location>();
private ArrayList<Entity> entities = new ArrayList<Entity>();
public Ripple(Player player, Vector direction) {
this(player, getInitialLocation(player, direction), direction);

View file

@ -9,6 +9,7 @@ import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.BendingPlayer;
@ -17,21 +18,22 @@ import com.projectkorra.ProjectKorra.ProjectKorra;
public class Tremorsense {
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static ConcurrentHashMap<Player, Tremorsense> instances = new ConcurrentHashMap<Player, Tremorsense>();
public static ConcurrentHashMap<Block, Player> blocks = new ConcurrentHashMap<Block, Player>();
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
public static ConcurrentHashMap<Block, Player> blocks = new ConcurrentHashMap<Block, Player>();
// private static final long cooldown = ConfigManager.tremorsenseCooldown;
private static final int maxdepth = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Tremorsense.MaxDepth");
private static final int radius = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Tremorsense.Radius");
private static final byte lightthreshold = (byte) ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Tremorsense.LightThreshold");
private static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.Tremorsense.Cooldown");
private static final int maxdepth = config.getInt("Abilities.Earth.Tremorsense.MaxDepth");
private static final int radius = config.getInt("Abilities.Earth.Tremorsense.Radius");
private static final byte lightthreshold = (byte) config.getInt("Abilities.Earth.Tremorsense.LightThreshold");
private static long cooldown = config.getLong("Abilities.Earth.Tremorsense.Cooldown");
private Player player;
private Block block;
// private static ConcurrentHashMap<Player, Long> timers = new
// ConcurrentHashMap<Player, Long>();
// private static ConcurrentHashMap<Player, Long> timers = new ConcurrentHashMap<Player, Long>();
public Tremorsense(Player player) {
// if (timers.containsKey(player)) {

View file

@ -13,16 +13,14 @@ import com.projectkorra.ProjectKorra.Ability.AvatarState;
public class ArcOfFire {
// private static ConcurrentHashMap<Player, Long> timers = new
// ConcurrentHashMap<Player, Long>();
// private static ConcurrentHashMap<Player, Long> timers = new ConcurrentHashMap<Player, Long>();
// static final long soonesttime = Tools.timeinterval;
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
private static int defaultarc = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.Blaze.ArcOfFire.Arc");
private static int defaultrange = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.Blaze.ArcOfFire.Range");
private static int stepsize = 2;
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
public ArcOfFire(Player player) {
// if (timers.containsKey(player)) {
// if (System.currentTimeMillis() < timers.get(player) + soonesttime) {

View file

@ -43,8 +43,7 @@ public class Cook {
cancel();
return;
}
if (!player.isSneaking()
|| !Methods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) {
if (!player.isSneaking() || !Methods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) {
cancel();
return;
}
@ -64,8 +63,7 @@ public class Cook {
time = System.currentTimeMillis();
}
player.getWorld().playEffect(player.getEyeLocation(),
Effect.MOBSPAWNER_FLAMES, 0, 10);
player.getWorld().playEffect(player.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 0, 10);
}
private void cancel() {
@ -79,16 +77,13 @@ public class Cook {
private void cook() {
Material cooked = getCooked(items.getType());
ItemStack newitem = new ItemStack(cooked);
HashMap<Integer, ItemStack> cantfit = player.getInventory().addItem(
newitem);
HashMap<Integer, ItemStack> cantfit = player.getInventory().addItem(newitem);
for (int id : cantfit.keySet()) {
player.getWorld()
.dropItem(player.getEyeLocation(), cantfit.get(id));
player.getWorld().dropItem(player.getEyeLocation(), cantfit.get(id));
}
int amount = items.getAmount();
if (amount == 1) {
player.getInventory()
.clear(player.getInventory().getHeldItemSlot());
player.getInventory().clear(player.getInventory().getHeldItemSlot());
// items.setType(Material.AIR);
} else {
items.setAmount(amount - 1);

View file

@ -14,9 +14,10 @@ import com.projectkorra.ProjectKorra.airbending.AirBlast;
public class Extinguish {
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static double defaultrange = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.HeatControl.Extinguish.Range");
private static double defaultradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.HeatControl.Extinguish.Radius");
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static byte full = AirBlast.full;
@ -30,14 +31,12 @@ public class Extinguish {
}
}
double range = Methods.firebendingDayAugment(defaultrange,
player.getWorld());
double range = Methods.firebendingDayAugment(defaultrange, player.getWorld());
if (Methods.isMeltable(player.getTargetBlock(null, (int) range))) {
new HeatMelt(player);
return;
}
double radius = Methods.firebendingDayAugment(defaultradius,
player.getWorld());
double radius = Methods.firebendingDayAugment(defaultradius, player.getWorld());
for (Block block : Methods.getBlocksAroundPoint(
player.getTargetBlock(null, (int) range).getLocation(), radius)) {
if (Methods.isRegionProtectedFromBuild(player, "Blaze",
@ -45,20 +44,17 @@ public class Extinguish {
continue;
if (block.getType() == Material.FIRE) {
block.setType(Material.AIR);
block.getWorld().playEffect(block.getLocation(),
Effect.EXTINGUISH, 0);
block.getWorld().playEffect(block.getLocation(), Effect.EXTINGUISH, 0);
} else if (block.getType() == Material.STATIONARY_LAVA) {
block.setType(Material.OBSIDIAN);
block.getWorld().playEffect(block.getLocation(),
Effect.EXTINGUISH, 0);
block.getWorld().playEffect(block.getLocation(), Effect.EXTINGUISH, 0);
} else if (block.getType() == Material.LAVA) {
if (block.getData() == full) {
block.setType(Material.OBSIDIAN);
} else {
block.setType(Material.COBBLESTONE);
}
block.getWorld().playEffect(block.getLocation(),
Effect.EXTINGUISH, 0);
block.getWorld().playEffect(block.getLocation(), Effect.EXTINGUISH, 0);
}
}
@ -73,8 +69,7 @@ public class Extinguish {
}
}
if (player.getFireTicks() > 80
&& Methods.canBendPassive(player.getName(), Element.Fire)) {
if (player.getFireTicks() > 80 && Methods.canBendPassive(player.getName(), Element.Fire)) {
player.setFireTicks(80);
}

View file

@ -26,20 +26,23 @@ import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
public class FireBlast {
public static ConcurrentHashMap<Integer, FireBlast> instances = new ConcurrentHashMap<Integer, FireBlast>();
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
// private static ConcurrentHashMap<Player, Long> timers = new
// ConcurrentHashMap<Player, Long>();
// static final long soonesttime = ConfigManager.fireBlastCooldown;
private static int ID = Integer.MIN_VALUE;
static final int maxticks = 10000;
private static double speed = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Speed");
public static double affectingradius = 2;
private static double pushfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Push");
private static boolean canPowerFurnace = true;
static boolean dissipate = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire.FireBlast.Dissipate");
private int damage = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.FireBlast.Damage");
double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Range");
long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBlast.Cooldown");
public static double affectingradius = 2;
// public static long interval = 2000;
public static byte full = 0x0;
private static int ID = Integer.MIN_VALUE;
private static boolean canPowerFurnace = true;
static final int maxticks = 10000;
private Location location;
private List<Block> safe = new ArrayList<Block>();
@ -49,13 +52,7 @@ public class FireBlast {
private int id;
private double speedfactor;
private int ticks = 0;
private int damage = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.FireBlast.Damage");
double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Range");
long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBlast.Cooldown");
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
// private ArrayList<Block> affectedlevers = new ArrayList<Block>();
// private long time;
public FireBlast(Player player) {
@ -73,8 +70,7 @@ public class FireBlast {
}
}
if (player.getEyeLocation().getBlock().isLiquid()
|| Fireball.isCharging(player)) {
if (player.getEyeLocation().getBlock().isLiquid() || Fireball.isCharging(player)) {
return;
}
range = Methods.firebendingDayAugment(range, player.getWorld());
@ -94,8 +90,7 @@ public class FireBlast {
// timers.put(player, System.currentTimeMillis());
}
public FireBlast(Location location, Vector direction, Player player,
int damage, List<Block> safeblocks) {
public FireBlast(Location location, Vector direction, Player player, int damage, List<Block> safeblocks) {
if (location.getBlock().isLiquid()) {
return;
}
@ -174,8 +169,7 @@ public class FireBlast {
// inv.setSmelting(temp);
// state.update(true);
// }
} else if (FireStream.isIgnitable(player,
block.getRelative(BlockFace.UP))) {
} else if (FireStream.isIgnitable(player, block.getRelative(BlockFace.UP))) {
ignite(location);
}
instances.remove(id);
@ -198,8 +192,7 @@ public class FireBlast {
return false;
}
for (Entity entity : Methods.getEntitiesAroundPoint(location,
affectingradius)) {
for (Entity entity : Methods.getEntitiesAroundPoint(location, affectingradius)) {
// Block bblock = location.getBlock();
// Block block1 = entity.getLocation().getBlock();
// if (bblock.equals(block1))
@ -222,22 +215,19 @@ public class FireBlast {
}
private void advanceLocation() {
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 0,
(int) range);
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 0, (int) range);
location = location.add(direction.clone().multiply(speedfactor));
}
private void ignite(Location location) {
for (Block block : Methods
.getBlocksAroundPoint(location, affectingradius)) {
for (Block block : Methods.getBlocksAroundPoint(location, affectingradius)) {
if (FireStream.isIgnitable(player, block) && !safe.contains(block)) {
if (Methods.isPlant(block))
new Plantbending(block);
block.setType(Material.FIRE);
if (dissipate) {
FireStream.ignitedblocks.put(block, player);
FireStream.ignitedtimes.put(block,
System.currentTimeMillis());
FireStream.ignitedtimes.put(block, System.currentTimeMillis());
}
}
}
@ -258,24 +248,20 @@ public class FireBlast {
private void affect(Entity entity) {
if (entity.getEntityId() != player.getEntityId()) {
if (AvatarState.isAvatarState(player)) {
entity.setVelocity(direction.clone().multiply(
AvatarState.getValue(pushfactor)));
entity.setVelocity(direction.clone().multiply(AvatarState.getValue(pushfactor)));
} else {
entity.setVelocity(direction.clone().multiply(pushfactor));
}
if (entity instanceof LivingEntity) {
entity.setFireTicks(50);
Methods.damageEntity(player, entity, (int) Methods
.firebendingDayAugment((double) damage,
entity.getWorld()));
Methods.damageEntity(player, entity, (int) Methods.firebendingDayAugment((double) damage, entity.getWorld()));
new Enflamed(entity, player);
instances.remove(id);
}
}
}
public static void removeFireBlastsAroundPoint(Location location,
double radius) {
public static void removeFireBlastsAroundPoint(Location location, double radius) {
for (int id : instances.keySet()) {
Location fireblastlocation = instances.get(id).location;
if (location.getWorld() == fireblastlocation.getWorld()) {
@ -286,14 +272,12 @@ public class FireBlast {
Fireball.removeFireballsAroundPoint(location, radius);
}
public static boolean annihilateBlasts(Location location, double radius,
Player source) {
public static boolean annihilateBlasts(Location location, double radius, Player source) {
boolean broke = false;
for (int id : instances.keySet()) {
FireBlast blast = instances.get(id);
Location fireblastlocation = blast.location;
if (location.getWorld() == fireblastlocation.getWorld()
&& !blast.player.equals(source)) {
if (location.getWorld() == fireblastlocation.getWorld() && !blast.player.equals(source)) {
if (location.distance(fireblastlocation) <= radius) {
instances.remove(id);
broke = true;

View file

@ -75,8 +75,7 @@ public class FireBurst {
if (direction.angle(vector) <= angle) {
// Methods.verbose(direction.angle(vector));
// Methods.verbose(direction);
new FireBlast(location, direction.normalize(), player,
damage, safeblocks);
new FireBlast(location, direction.normalize(), player, damage, safeblocks);
}
}
}
@ -88,8 +87,7 @@ public class FireBurst {
private void sphereBurst() {
if (charged) {
Location location = player.getEyeLocation();
List<Block> safeblocks = Methods.getBlocksAroundPoint(
player.getLocation(), 2);
List<Block> safeblocks = Methods.getBlocksAroundPoint(player.getLocation(), 2);
double x, y, z;
double r = 1;
for (double theta = 0; theta <= 180; theta += deltheta) {
@ -101,8 +99,7 @@ public class FireBurst {
y = r * Math.sin(rphi) * Math.sin(rtheta);
z = r * Math.cos(rtheta);
Vector direction = new Vector(x, z, y);
new FireBlast(location, direction.normalize(), player,
damage, safeblocks);
new FireBlast(location, direction.normalize(), player, damage, safeblocks);
}
}
}
@ -138,8 +135,7 @@ public class FireBurst {
} else if (charged) {
Location location = player.getEyeLocation();
// location = location.add(location.getDirection().normalize());
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES,
4, 3);
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 4, 3);
}
}

View file

@ -19,6 +19,7 @@ public class FireJet {
public static ConcurrentHashMap<Player, FireJet> instances = new ConcurrentHashMap<Player, FireJet>();
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static final double defaultfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireJet.Speed");
private static final long defaultduration = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireJet.Duration");
private static boolean isToggle = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire.FireJet.IsAvatarStateToggle");
@ -56,11 +57,8 @@ public class FireJet {
factor = Methods.firebendingDayAugment(defaultfactor, player.getWorld());
Block block = player.getLocation().getBlock();
if (FireStream.isIgnitable(player, block)
|| block.getType() == Material.AIR
|| AvatarState.isAvatarState(player)) {
player.setVelocity(player.getEyeLocation().getDirection().clone()
.normalize().multiply(factor));
if (FireStream.isIgnitable(player, block) || block.getType() == Material.AIR || AvatarState.isAvatarState(player)) {
player.setVelocity(player.getEyeLocation().getDirection().clone().normalize().multiply(factor));
block.setType(Material.FIRE);
this.player = player;
// canfly = player.getAllowFlight();
@ -87,23 +85,19 @@ public class FireJet {
instances.remove(player);
return;
}
if ((Methods.isWater(player.getLocation().getBlock()) || System
.currentTimeMillis() > time + duration)
if ((Methods.isWater(player.getLocation().getBlock()) || System.currentTimeMillis() > time + duration)
&& (!AvatarState.isAvatarState(player) || !isToggle)) {
// player.setAllowFlight(canfly);
instances.remove(player);
} else {
player.getWorld().playEffect(player.getLocation(),
Effect.MOBSPAWNER_FLAMES, 1);
player.getWorld().playEffect(player.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
double timefactor;
if (AvatarState.isAvatarState(player) && isToggle) {
timefactor = 1;
} else {
timefactor = 1 - ((double) (System.currentTimeMillis() - time))
/ (2.0 * duration);
timefactor = 1 - ((double) (System.currentTimeMillis() - time)) / (2.0 * duration);
}
Vector velocity = player.getEyeLocation().getDirection().clone()
.normalize().multiply(factor * timefactor);
Vector velocity = player.getEyeLocation().getDirection().clone().normalize().multiply(factor * timefactor);
// Vector velocity = player.getVelocity().clone();
// velocity.add(player.getEyeLocation().getDirection().clone()
// .normalize().multiply(factor * timefactor));

View file

@ -24,9 +24,9 @@ public class FireShield {
private static Map<String, Long> cooldowns = new HashMap<String, Long>();
private static long interval = 100;
private static long duration = 1000;
private static double radius = 3;
private static double discradius = 1.5;
private static long duration = 1000;
private static boolean ignite = true;
private Player player;
@ -69,8 +69,7 @@ public class FireShield {
}
private void progress() {
if (((!player.isSneaking()) && shield)
|| !Methods.canBend(player.getName(), "FireShield")) {
if (((!player.isSneaking()) && shield) || !Methods.canBend(player.getName(), "FireShield")) {
remove();
return;
}
@ -97,29 +96,22 @@ public class FireShield {
for (double phi = 0; phi < 360; phi += 20) {
double rphi = Math.toRadians(phi);
double rtheta = Math.toRadians(theta);
Block block = location
.clone()
.add(radius * Math.cos(rphi) * Math.sin(rtheta),
radius * Math.cos(rtheta),
radius * Math.sin(rphi)
* Math.sin(rtheta)).getBlock();
if (!blocks.contains(block) && !Methods.isSolid(block)
&& !block.isLiquid())
Block block = location.clone().add(
radius * Math.cos(rphi) * Math.sin(rtheta),
radius * Math.cos(rtheta),
radius * Math.sin(rphi) * Math.sin(rtheta)).getBlock();
if (!blocks.contains(block) && !Methods.isSolid(block) && !block.isLiquid())
blocks.add(block);
}
}
for (Block block : blocks) {
if (!Methods.isRegionProtectedFromBuild(player,
"FireShield", block.getLocation()))
block.getWorld().playEffect(block.getLocation(),
Effect.MOBSPAWNER_FLAMES, 0, 20);
if (!Methods.isRegionProtectedFromBuild(player, "FireShield", block.getLocation()))
block.getWorld().playEffect(block.getLocation(), Effect.MOBSPAWNER_FLAMES, 0, 20);
}
for (Entity entity : Methods.getEntitiesAroundPoint(location,
radius)) {
if (Methods.isRegionProtectedFromBuild(player,
"FireShield", entity.getLocation()))
for (Entity entity : Methods.getEntitiesAroundPoint(location, radius)) {
if (Methods.isRegionProtectedFromBuild(player, "FireShield", entity.getLocation()))
continue;
if (player.getEntityId() != entity.getEntityId() && ignite) {
entity.setFireTicks(120);
@ -139,35 +131,26 @@ public class FireShield {
Vector direction = location.getDirection();
location = location.clone().add(direction.multiply(radius));
if (Methods.isRegionProtectedFromBuild(player,
"FireShield", location)) {
remove();
return;
}
if (Methods.isRegionProtectedFromBuild(player, "FireShield", location)) {
remove();
return;
}
for (double theta = 0; theta < 360; theta += 20) {
Vector vector = Methods.getOrthogonalVector(direction, theta,
discradius);
Vector vector = Methods.getOrthogonalVector(direction, theta, discradius);
Block block = location.clone().add(vector).getBlock();
if (!blocks.contains(block) && !Methods.isSolid(block)
&& !block.isLiquid())
if (!blocks.contains(block) && !Methods.isSolid(block) && !block.isLiquid())
blocks.add(block);
}
for (Block block : blocks) {
if (!Methods.isRegionProtectedFromBuild(player,
"FireShield", block.getLocation()))
block.getWorld().playEffect(block.getLocation(),
Effect.MOBSPAWNER_FLAMES, 0, 20);
if (!Methods.isRegionProtectedFromBuild(player, "FireShield", block.getLocation()))
block.getWorld().playEffect(block.getLocation(), Effect.MOBSPAWNER_FLAMES, 0, 20);
}
for (Entity entity : Methods.getEntitiesAroundPoint(location,
discradius)) {
if (Methods.isRegionProtectedFromBuild(player,
"FireShield", entity.getLocation()))
continue;
for (Entity entity : Methods.getEntitiesAroundPoint(location, discradius)) {
if (Methods.isRegionProtectedFromBuild(player, "FireShield", entity.getLocation()))
continue;
if (player.getEntityId() != entity.getEntityId() && ignite) {
entity.setFireTicks(120);
if (!(entity instanceof LivingEntity)) {
@ -180,9 +163,7 @@ public class FireShield {
WaterManipulation.removeAroundPoint(location, discradius);
EarthBlast.removeAroundPoint(location, discradius);
FireStream.removeAroundPoint(location, discradius);
}
}
}
@ -202,6 +183,5 @@ public class FireShield {
public static void removeAll() {
instances.clear();
}
}

View file

@ -30,7 +30,6 @@ public class FireStream {
private static int ID = Integer.MIN_VALUE;
private static double speed = 15;
private static long interval = (long) (1000. / speed);
private static long dissipateAfter = 400;
private Player player;
@ -41,8 +40,7 @@ public class FireStream {
private long time;
private double range;
public FireStream(Location location, Vector direction, Player player,
int range) {
public FireStream(Location location, Vector direction, Player player, int range) {
this.range = Methods.firebendingDayAugment(range, player.getWorld());
this.player = player;
origin = location.clone();
@ -112,7 +110,8 @@ public class FireStream {
return false;
}
Material[] ignitable = { Material.BEDROCK, Material.BOOKSHELF,
Material[] ignitable = {
Material.BEDROCK, Material.BOOKSHELF,
Material.BRICK, Material.CLAY, Material.CLAY_BRICK,
Material.COAL_ORE, Material.COBBLESTONE, Material.DIAMOND_ORE,
Material.DIAMOND_BLOCK, Material.DIRT, Material.ENDER_STONE,
@ -124,7 +123,8 @@ public class FireStream {
Material.OBSIDIAN, Material.REDSTONE_ORE, Material.SAND,
Material.SANDSTONE, Material.SMOOTH_BRICK, Material.STONE,
Material.SOUL_SAND, Material.SNOW_BLOCK, Material.WOOD,
Material.WOOL, Material.LEAVES };
Material.WOOL, Material.LEAVES
};
Block belowblock = block.getRelative(BlockFace.DOWN);
if (Arrays.asList(ignitable).contains(belowblock.getType())) {

View file

@ -24,23 +24,22 @@ public class Fireball {
private static long defaultchargetime = 2000;
private static long interval = 25;
private static double radius = 1.5;
private static int ID = Integer.MIN_VALUE;
private int id;
private double range = 20;
private int maxdamage = 4;
private double range = 20;
private double explosionradius = 6;
private double innerradius = 3;
private Player player;
private Location origin;
private Location location;
private Vector direction;
private long starttime;
private long time;
private long chargetime = defaultchargetime;
private boolean charged = false;
private boolean launched = false;
private Player player;
private Location origin;
private Location location;
private Vector direction;
private TNTPrimed explosion = null;
public Fireball(Player player) {
@ -100,8 +99,7 @@ public class Fireball {
if (System.currentTimeMillis() > time + interval) {
if (launched) {
if (Methods.isRegionProtectedFromBuild(player, "Blaze",
location)) {
if (Methods.isRegionProtectedFromBuild(player, "Blaze", location)) {
remove();
return;
}
@ -112,8 +110,7 @@ public class Fireball {
if (!launched && !charged)
return;
if (!launched) {
player.getWorld().playEffect(player.getEyeLocation(),
Effect.MOBSPAWNER_FLAMES, 0, 3);
player.getWorld().playEffect(player.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 0, 3);
return;
}
@ -150,8 +147,7 @@ public class Fireball {
// entity.getLocation())) {
// return 0;
// }
double distance = entity.getLocation()
.distance(explosion.getLocation());
double distance = entity.getLocation().distance(explosion.getLocation());
if (distance > explosionradius)
return;
if (distance < innerradius) {
@ -159,7 +155,6 @@ public class Fireball {
return;
}
double slope = -(maxdamage * .5) / (explosionradius - innerradius);
double damage = slope * (distance - innerradius) + maxdamage;
// Methods.verbose(damage);
Methods.damageEntity(player, entity, (int) damage);
@ -167,8 +162,7 @@ public class Fireball {
private void fireball() {
for (Block block : Methods.getBlocksAroundPoint(location, radius)) {
block.getWorld().playEffect(block.getLocation(),
Effect.MOBSPAWNER_FLAMES, 0, 20);
block.getWorld().playEffect(block.getLocation(), Effect.MOBSPAWNER_FLAMES, 0, 20);
}
for (Entity entity : Methods.getEntitiesAroundPoint(location, 2 * radius)) {
@ -198,8 +192,7 @@ public class Fireball {
// Methods.verbose("Fireball Explode!");
boolean explode = true;
for (Block block : Methods.getBlocksAroundPoint(location, 3)) {
if (Methods.isRegionProtectedFromBuild(player, "FireBlast",
block.getLocation())) {
if (Methods.isRegionProtectedFromBuild(player, "FireBlast", block.getLocation())) {
explode = false;
break;
}
@ -232,14 +225,12 @@ public class Fireball {
}
private void ignite(Location location) {
for (Block block : Methods.getBlocksAroundPoint(location,
FireBlast.affectingradius)) {
for (Block block : Methods.getBlocksAroundPoint(location, FireBlast.affectingradius)) {
if (FireStream.isIgnitable(player, block)) {
block.setType(Material.FIRE);
if (FireBlast.dissipate) {
FireStream.ignitedblocks.put(block, player);
FireStream.ignitedtimes.put(block,
System.currentTimeMillis());
FireStream.ignitedtimes.put(block, System.currentTimeMillis());
}
}
}
@ -259,8 +250,7 @@ public class Fireball {
instances.get(id).remove();
}
public static void removeFireballsAroundPoint(Location location,
double radius) {
public static void removeFireballsAroundPoint(Location location, double radius) {
for (int id : instances.keySet()) {
Fireball fireball = instances.get(id);
if (!fireball.launched)
@ -274,8 +264,7 @@ public class Fireball {
}
public static boolean annihilateBlasts(Location location, double radius,
Player source) {
public static boolean annihilateBlasts(Location location, double radius, Player source) {
boolean broke = false;
for (int id : instances.keySet()) {
Fireball fireball = instances.get(id);

View file

@ -25,9 +25,9 @@ public class Bloodbending {
private static final double factor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Bloodbending.ThrowFactor");
private static final boolean onlyUsableAtNight = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.Bloodbending.CanOnlyBeUsedAtNight");
private Player player;
private int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.Bloodbending.Range");
private Player player;
public Bloodbending(Player player) {
if (instances.containsKey(player)) {
@ -42,16 +42,13 @@ public class Bloodbending {
range = (int) Methods.waterbendingNightAugment(range, player.getWorld());
if (AvatarState.isAvatarState(player)) {
range = AvatarState.getValue(range);
for (Entity entity : Methods.getEntitiesAroundPoint(
player.getLocation(), range)) {
for (Entity entity : Methods.getEntitiesAroundPoint(player.getLocation(), range)) {
if (entity instanceof LivingEntity) {
if (entity instanceof Player) {
if (Methods.isRegionProtectedFromBuild(player,
"Bloodbending", entity.getLocation())
if (Methods.isRegionProtectedFromBuild(player, "Bloodbending", entity.getLocation())
|| (AvatarState.isAvatarState((Player) entity)
|| entity.getEntityId() == player.getEntityId()
|| Methods.canBend(((Player) entity).getName(),
"Bloodbending")))
|| Methods.canBend(((Player) entity).getName(), "Bloodbending")))
continue;
}
Methods.damageEntity(player, entity, 0);
@ -62,9 +59,8 @@ public class Bloodbending {
Entity target = Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
if (target == null)
return;
if (!(target instanceof LivingEntity)
|| Methods.isRegionProtectedFromBuild(player,
"Bloodbending", target.getLocation()))
if (!(target instanceof LivingEntity)|| Methods.isRegionProtectedFromBuild(player,
"Bloodbending", target.getLocation()))
return;
if (target instanceof Player) {
if (Methods.canBend(((Player) target).getName(), "Bloodbending")
@ -126,18 +122,15 @@ public class Bloodbending {
if (AvatarState.isAvatarState(player)) {
ArrayList<Entity> entities = new ArrayList<Entity>();
for (Entity entity : Methods.getEntitiesAroundPoint(
player.getLocation(), range)) {
if (Methods.isRegionProtectedFromBuild(player,
"Bloodbending", entity.getLocation()))
for (Entity entity : Methods.getEntitiesAroundPoint(player.getLocation(), range)) {
if (Methods.isRegionProtectedFromBuild(player, "Bloodbending", entity.getLocation()))
continue;
if (entity instanceof Player) {
if (!Methods.canBeBloodbent((Player) entity))
continue;
}
entities.add(entity);
if (!targetentities.containsKey(entity)
&& entity instanceof LivingEntity) {
if (!targetentities.containsKey(entity) && entity instanceof LivingEntity) {
Methods.damageEntity(player, entity, 0);
targetentities.put(entity, entity.getLocation().clone());
}
@ -175,10 +168,8 @@ public class Bloodbending {
}
}
Location newlocation = entity.getLocation();
Location location = Methods.getTargetedLocation(
player,
(int) targetentities.get(entity).distance(
player.getLocation()));
Location location = Methods.getTargetedLocation(player,
(int) targetentities.get(entity).distance(player.getLocation()));
double distance = location.distance(newlocation);
double dx, dy, dz;
dx = location.getX() - newlocation.getX();

View file

@ -25,10 +25,8 @@ public class FreezeMelt {
// if (bPlayer.isOnCooldown(Abilities.PhaseChange))
// return;
int range = (int) Methods.waterbendingNightAugment(defaultrange,
player.getWorld());
int radius = (int) Methods.waterbendingNightAugment(defaultradius,
player.getWorld());
int range = (int) Methods.waterbendingNightAugment(defaultrange, player.getWorld());
int radius = (int) Methods.waterbendingNightAugment(defaultradius, player.getWorld());
if (AvatarState.isAvatarState(player)) {
range = AvatarState.getValue(range);
// radius = AvatarState.getValue(radius);
@ -50,20 +48,16 @@ public class FreezeMelt {
}
private static boolean isFreezable(Player player, Block block) {
if (Methods.isRegionProtectedFromBuild(player, "PhaseChange",
block.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation()))
return false;
if (block.getType() == Material.WATER
|| block.getType() == Material.STATIONARY_WATER)
if (WaterManipulation.canPhysicsChange(block)
&& !TempBlock.isTempBlock(block))
if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)
if (WaterManipulation.canPhysicsChange(block) && !TempBlock.isTempBlock(block))
return true;
return false;
}
static void freeze(Player player, Block block) {
if (Methods.isRegionProtectedFromBuild(player, "PhaseChange",
block.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation()))
return;
if (TempBlock.isTempBlock(block))
return;
@ -99,8 +93,7 @@ public class FreezeMelt {
return false;
}
if (Methods.canBend(player.getName(), "PhaseChange")) {
double range = Methods.waterbendingNightAugment(defaultrange,
player.getWorld());
double range = Methods.waterbendingNightAugment(defaultrange, player.getWorld());
if (AvatarState.isAvatarState(player)) {
range = AvatarState.getValue(range);
}

View file

@ -78,10 +78,8 @@ public class HealingWaters {
}
private static void applyHealing(Player player) {
if (!Methods.isRegionProtectedFromBuild(player, "HealingWaters",
player.getLocation()))
player.addPotionEffect(new PotionEffect(
PotionEffectType.REGENERATION, 70, 1));
if (!Methods.isRegionProtectedFromBuild(player, "HealingWaters", player.getLocation()))
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 70, 1));
}
private static void applyHealingToEntity(LivingEntity le) {

View file

@ -25,22 +25,20 @@ import com.projectkorra.ProjectKorra.TempPotionEffect;
public class IceSpike {
public static ConcurrentHashMap<Integer, IceSpike> instances = new ConcurrentHashMap<Integer, IceSpike>();
public ConcurrentHashMap<Player, Long> removeTimers = new ConcurrentHashMap<Player, Long>();
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
public static final int standardheight = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.IceSpike.Height");
public static long removeTimer = 500;
public ConcurrentHashMap<Player, Long> removeTimers = new ConcurrentHashMap<Player, Long>();
private static ConcurrentHashMap<Block, Block> alreadydoneblocks = new ConcurrentHashMap<Block, Block>();
private static ConcurrentHashMap<Block, Integer> baseblocks = new ConcurrentHashMap<Block, Integer>();
public static long removeTimer = 500;
public static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.IceSpike.Cooldown");
public static final int standardheight = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.IceSpike.Height");
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.IceSpike.Range");
private static int ID = Integer.MIN_VALUE;
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.IceSpike.Range");
public static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.IceSpike.Cooldown");
private static double speed = 25;
private static final Vector direction = new Vector(0, 1, 0);
private static long interval = (long) (1000. / speed);
private static final Vector direction = new Vector(0, 1, 0);
private Location origin;
private Location location;
@ -48,8 +46,8 @@ public class IceSpike {
private Player player;
private int progress = 0;
private double damage = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.IceSpike.Damage");
int id;
private long time;
int id;
int height = 2;
private Vector thrown = new Vector(0, ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.IceSpike.ThrowingMult"), 0);
private ConcurrentHashMap<Block, Block> affectedblocks = new ConcurrentHashMap<Block, Block>();
@ -68,15 +66,11 @@ public class IceSpike {
double lowestdistance = range + 1;
Entity closestentity = null;
for (Entity entity : Methods.getEntitiesAroundPoint(
player.getLocation(), range)) {
if (Methods.getDistanceFromLine(player.getLocation()
.getDirection(), player.getLocation(), entity
.getLocation()) <= 2
for (Entity entity : Methods.getEntitiesAroundPoint(player.getLocation(), range)) {
if (Methods.getDistanceFromLine(player.getLocation().getDirection(), player.getLocation(), entity.getLocation()) <= 2
&& (entity instanceof LivingEntity)
&& (entity.getEntityId() != player.getEntityId())) {
double distance = player.getLocation().distance(
entity.getLocation());
double distance = player.getLocation().distance(entity.getLocation());
if (distance < lowestdistance) {
closestentity = entity;
lowestdistance = distance;
@ -84,8 +78,7 @@ public class IceSpike {
}
}
if (closestentity != null) {
Block temptestingblock = closestentity.getLocation().getBlock()
.getRelative(BlockFace.DOWN, 1);
Block temptestingblock = closestentity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1);
// if (temptestingblock.getType() == Material.ICE){
this.block = temptestingblock;
// }
@ -115,15 +108,14 @@ public class IceSpike {
}
}
public IceSpike(Player player, Location origin, int damage,
Vector throwing, long aoecooldown) {
public IceSpike(Player player, Location origin, int damage, Vector throwing, long aoecooldown) {
cooldown = aoecooldown;
this.player = player;
this.origin = origin;
location = origin.clone();
block = location.getBlock();
this.damage = damage;
this.thrown = throwing;
location = origin.clone();
block = location.getBlock();
loadAffectedBlocks();
@ -144,8 +136,7 @@ public class IceSpike {
affectedblocks.clear();
Block thisblock;
for (int i = 1; i <= height; i++) {
thisblock = block.getWorld().getBlockAt(
location.clone().add(direction.clone().multiply(i)));
thisblock = block.getWorld().getBlockAt(location.clone().add(direction.clone().multiply(i)));
affectedblocks.put(thisblock, thisblock);
}
}
@ -196,13 +187,8 @@ public class IceSpike {
moveEarth();
removeTimers.put(player, System.currentTimeMillis());
} else {
if (removeTimers.get(player) + removeTimer <= System
.currentTimeMillis()) {
baseblocks.put(
location.clone()
.add(direction.clone().multiply(
-1 * (height))).getBlock(),
(height - 1));
if (removeTimers.get(player) + removeTimer <= System.currentTimeMillis()) {
baseblocks.put(location.clone().add(direction.clone().multiply(-1 * (height))).getBlock(),(height - 1));
if (!revertblocks()) {
instances.remove(id);
}
@ -218,12 +204,10 @@ public class IceSpike {
progress++;
Block affectedblock = location.clone().add(direction).getBlock();
location = location.add(direction);
if (Methods.isRegionProtectedFromBuild(player, "IceSpike",
location))
if (Methods.isRegionProtectedFromBuild(player, "IceSpike", location))
return false;
for (Entity en : Methods.getEntitiesAroundPoint(location, 1.4)) {
if (en instanceof LivingEntity && en != player
&& !damaged.contains(((LivingEntity) en))) {
if (en instanceof LivingEntity && en != player && !damaged.contains(((LivingEntity) en))) {
LivingEntity le = (LivingEntity) en;
affect(le);
// le.setVelocity(thrown);
@ -251,14 +235,12 @@ public class IceSpike {
if (entity instanceof Player) {
BendingPlayer bPlayer = Methods.getBendingPlayer(player.getName());
if (bPlayer.canBeSlowed()) {
PotionEffect effect = new PotionEffect(PotionEffectType.SLOW,
70, mod);
PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, mod);
new TempPotionEffect(entity, effect);
bPlayer.slow(slowCooldown);
}
} else {
PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70,
mod);
PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, mod);
new TempPotionEffect(entity, effect);
}

View file

@ -33,20 +33,19 @@ public class IceSpike2 {
private static final double affectingradius = 2;
private static final double deflectrange = 3;
private Player player;
private int id;
private double range;
private boolean plantbending = false;
private Block sourceblock;
private TempBlock source;
private boolean prepared = false;
private boolean settingup = false;
private boolean progressing = false;
private long time;
private Location location;
private Location firstdestination;
private Location destination;
private Block sourceblock;
private Player player;
private TempBlock source;
public IceSpike2(Player player) {
block(player);
@ -54,8 +53,7 @@ public class IceSpike2 {
plantbending = true;
range = Methods.waterbendingNightAugment(defaultrange, player.getWorld());
this.player = player;
Block sourceblock = Methods.getWaterSourceBlock(player, range,
plantbending);
Block sourceblock = Methods.getWaterSourceBlock(player, range, plantbending);
if (sourceblock == null) {
new SpikeField(player);
@ -127,21 +125,16 @@ public class IceSpike2 {
private static void waterBottle(Player player) {
if (WaterReturn.hasWaterBottle(player)) {
Location eyeloc = player.getEyeLocation();
Block block = eyeloc.add(eyeloc.getDirection().normalize())
.getBlock();
Block block = eyeloc.add(eyeloc.getDirection().normalize()).getBlock();
if (Methods.isTransparentToEarthbending(player, block)
&& Methods.isTransparentToEarthbending(player,
eyeloc.getBlock())) {
&& Methods.isTransparentToEarthbending(player, eyeloc.getBlock())) {
LivingEntity target = (LivingEntity) Methods.getTargetedEntity(
player, defaultrange, new ArrayList<Entity>());
LivingEntity target = (LivingEntity) Methods.getTargetedEntity(player, defaultrange, new ArrayList<Entity>());
Location destination;
if (target == null) {
destination = Methods.getTargetedLocation(player,
defaultrange, Methods.transparentToEarthbending);
destination = Methods.getTargetedLocation(player, defaultrange, Methods.transparentToEarthbending);
} else {
destination = Methods.getPointOnLine(player.getEyeLocation(),
target.getEyeLocation(), defaultrange);
destination = Methods.getPointOnLine(player.getEyeLocation(), target.getEyeLocation(), defaultrange);
}
if (destination.distance(block.getLocation()) < 1)
@ -165,11 +158,9 @@ public class IceSpike2 {
private void throwIce() {
if (!prepared)
return;
LivingEntity target = (LivingEntity) Methods.getTargetedEntity(player,
range, new ArrayList<Entity>());
LivingEntity target = (LivingEntity) Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
if (target == null) {
destination = Methods.getTargetedLocation(player, range,
Methods.transparentToEarthbending);
destination = Methods.getTargetedLocation(player, range, Methods.transparentToEarthbending);
} else {
destination = target.getEyeLocation();
}
@ -183,8 +174,7 @@ public class IceSpike2 {
} else {
firstdestination.add(0, 2, 0);
}
destination = Methods
.getPointOnLine(firstdestination, destination, range);
destination = Methods.getPointOnLine(firstdestination, destination, range);
progressing = true;
settingup = true;
prepared = false;
@ -206,8 +196,7 @@ public class IceSpike2 {
}
private void progress() {
if (player.isDead() || !player.isOnline()
|| !Methods.canBend(player.getName(), "IceSpike")) {
if (player.isDead() || !player.isOnline() || !Methods.canBend(player.getName(), "IceSpike")) {
cancel();
return;
}
@ -251,11 +240,9 @@ public class IceSpike2 {
}
if (settingup) {
direction = Methods.getDirection(location, firstdestination)
.normalize();
direction = Methods.getDirection(location, firstdestination).normalize();
} else {
direction = Methods.getDirection(location, destination)
.normalize();
direction = Methods.getDirection(location, destination).normalize();
}
location.add(direction);
@ -268,8 +255,7 @@ public class IceSpike2 {
source.revertBlock();
source = null;
if (Methods.isTransparentToEarthbending(player, block)
&& !block.isLiquid()) {
if (Methods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
Methods.breakBlock(block);
} else if (!Methods.isWater(block)) {
cancel();
@ -277,17 +263,14 @@ public class IceSpike2 {
return;
}
if (Methods.isRegionProtectedFromBuild(player, "IceSpike",
location)) {
if (Methods.isRegionProtectedFromBuild(player, "IceSpike", location)) {
cancel();
returnWater();
return;
}
for (Entity entity : Methods.getEntitiesAroundPoint(location,
affectingradius)) {
if (entity.getEntityId() != player.getEntityId()
&& entity instanceof LivingEntity) {
for (Entity entity : Methods.getEntitiesAroundPoint(location, affectingradius)) {
if (entity.getEntityId() != player.getEntityId() && entity instanceof LivingEntity) {
affect((LivingEntity) entity);
progressing = false;
returnWater();
@ -308,22 +291,18 @@ public class IceSpike2 {
}
private void affect(LivingEntity entity) {
int mod = (int) Methods.waterbendingNightAugment(defaultmod,
player.getWorld());
int damage = (int) Methods.waterbendingNightAugment(defaultdamage,
player.getWorld());
int mod = (int) Methods.waterbendingNightAugment(defaultmod, player.getWorld());
int damage = (int) Methods.waterbendingNightAugment(defaultdamage, player.getWorld());
if (entity instanceof Player) {
BendingPlayer bPlayer = Methods.getBendingPlayer(player.getName());
if (bPlayer.canBeSlowed()) {
PotionEffect effect = new PotionEffect(PotionEffectType.SLOW,
70, mod);
PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, mod);
new TempPotionEffect(entity, effect);
bPlayer.slow(slowCooldown);
entity.damage(damage, player);
}
} else {
PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70,
mod);
PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, mod);
new TempPotionEffect(entity, effect);
entity.damage(damage, player);
}
@ -349,22 +328,19 @@ public class IceSpike2 {
} else {
location = ((LivingEntity) target).getEyeLocation();
}
location = Methods.getPointOnLine(ice.location, location,
defaultrange * 2);
location = Methods.getPointOnLine(ice.location, location, defaultrange * 2);
ice.redirect(location, player);
}
Location location = player.getEyeLocation();
Vector vector = location.getDirection();
Location mloc = ice.location;
if (Methods.isRegionProtectedFromBuild(player, "IceSpike",
mloc))
if (Methods.isRegionProtectedFromBuild(player, "IceSpike", mloc))
continue;
if (mloc.distance(location) <= defaultrange
&& Methods.getDistanceFromLine(vector, location, ice.location) < deflectrange
&& mloc.distance(location.clone().add(vector)) < mloc
.distance(location.clone().add(
vector.clone().multiply(-1)))) {
&& mloc.distance(location.clone().add(vector)) <
mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
Location loc;
Entity target = Methods.getTargetedEntity(player, defaultrange, new ArrayList<Entity>());
if (target == null) {
@ -401,9 +377,8 @@ public class IceSpike2 {
Location mloc = ice.location;
if (mloc.distance(location) <= defaultrange
&& Methods.getDistanceFromLine(vector, location, ice.location) < deflectrange
&& mloc.distance(location.clone().add(vector)) < mloc
.distance(location.clone().add(
vector.clone().multiply(-1)))) {
&& mloc.distance(location.clone().add(vector)) <
mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
ice.cancel();
}

View file

@ -13,10 +13,11 @@ import com.projectkorra.ProjectKorra.Ability.AvatarState;
public class Melt {
private static final int seaLevel = ProjectKorra.plugin.getConfig().getInt("Properties.SeaLevel");
private static final int defaultrange = FreezeMelt.defaultrange;
private static final int defaultradius = FreezeMelt.defaultradius;
private static final int defaultevaporateradius = 3;
private static final int seaLevel = ProjectKorra.plugin.getConfig().getInt("Properties.SeaLevel");
private static final byte full = 0x0;
@ -26,10 +27,8 @@ public class Melt {
// if (bPlayer.isOnCooldown(Abilities.PhaseChange))
// return;
int range = (int) Methods.waterbendingNightAugment(defaultrange,
player.getWorld());
int radius = (int) Methods.waterbendingNightAugment(defaultradius,
player.getWorld());
int range = (int) Methods.waterbendingNightAugment(defaultrange, player.getWorld());
int radius = (int) Methods.waterbendingNightAugment(defaultradius, player.getWorld());
if (AvatarState.isAvatarState(player)) {
range = AvatarState.getValue(range);
@ -37,11 +36,9 @@ public class Melt {
}
boolean evaporate = false;
Location location = Methods.getTargetedLocation(player, range);
if (Methods.isWater(player.getTargetBlock(null, range))
&& !(player.getEyeLocation().getBlockY() <= 62)) {
if (Methods.isWater(player.getTargetBlock(null, range)) && !(player.getEyeLocation().getBlockY() <= 62)) {
evaporate = true;
radius = (int) Methods.waterbendingNightAugment(
defaultevaporateradius, player.getWorld());
radius = (int) Methods.waterbendingNightAugment(defaultevaporateradius, player.getWorld());
}
for (Block block : Methods.getBlocksAroundPoint(location, radius)) {
if (evaporate) {
@ -56,8 +53,7 @@ public class Melt {
}
public static void melt(Player player, Block block) {
if (Methods.isRegionProtectedFromBuild(player, "PhaseChange",
block.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation()))
return;
if (!Wave.canThaw(block)) {
Wave.thaw(block);
@ -67,8 +63,7 @@ public class Melt {
Torrent.thaw(block);
return;
}
if (Methods.isMeltable(block) && !TempBlock.isTempBlock(block)
&& WaterManipulation.canPhysicsChange(block)) {
if (Methods.isMeltable(block) && !TempBlock.isTempBlock(block) && WaterManipulation.canPhysicsChange(block)) {
if (block.getType() == Material.SNOW) {
block.setType(Material.AIR);
return;
@ -83,11 +78,9 @@ public class Melt {
}
public static void evaporate(Player player, Block block) {
if (Methods.isRegionProtectedFromBuild(player, "PhaseChange",
block.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation()))
return;
if (Methods.isWater(block) && !TempBlock.isTempBlock(block)
&& WaterManipulation.canPhysicsChange(block)) {
if (Methods.isWater(block) && !TempBlock.isTempBlock(block) && WaterManipulation.canPhysicsChange(block)) {
block.setType(Material.AIR);
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
}

View file

@ -20,10 +20,10 @@ public class OctopusForm {
static ConcurrentHashMap<Player, OctopusForm> instances = new ConcurrentHashMap<Player, OctopusForm>();
private static int range = 10;
private static int damage = 3;
private static long interval = 50;
static double radius = 3;
private static final byte full = 0x0;
private static long interval = 50;
private static int damage = 3;
private Player player;
private Block sourceblock;
@ -33,8 +33,8 @@ public class OctopusForm {
private double startangle;
private double angle;
private double y = 0;
private int animstep = 1, step = 1, inc = 3;
private double dta = 45;
private int animstep = 1, step = 1, inc = 3;
private ArrayList<TempBlock> blocks = new ArrayList<TempBlock>();
private ArrayList<TempBlock> newblocks = new ArrayList<TempBlock>();
// private static ArrayList<TempBlock> water = new ArrayList<TempBlock>();
@ -80,11 +80,9 @@ public class OctopusForm {
instances.get(player).form();
} else if (WaterReturn.hasWaterBottle(player)) {
Location eyeloc = player.getEyeLocation();
Block block = eyeloc.add(eyeloc.getDirection().normalize())
.getBlock();
Block block = eyeloc.add(eyeloc.getDirection().normalize()).getBlock();
if (Methods.isTransparentToEarthbending(player, block)
&& Methods.isTransparentToEarthbending(player,
eyeloc.getBlock())) {
&& Methods.isTransparentToEarthbending(player, eyeloc.getBlock())) {
block.setType(Material.WATER);
block.setData(full);
OctopusForm form = new OctopusForm(player);
@ -112,16 +110,12 @@ public class OctopusForm {
private void attack() {
if (!formed)
return;
double tentacleangle = (new Vector(1, 0, 0)).angle(player
.getEyeLocation().getDirection()) + dta / 2;
double tentacleangle = (new Vector(1, 0, 0)).angle(player.getEyeLocation().getDirection()) + dta / 2;
for (double tangle = tentacleangle; tangle < tentacleangle + 360; tangle += dta) {
double phi = Math.toRadians(tangle);
affect(player
.getLocation()
.clone()
.add(new Vector(radius * Math.cos(phi), 1, radius
* Math.sin(phi))));
affect(player.getLocation().clone().add(
new Vector(radius * Math.cos(phi), 1, radius * Math.sin(phi))));
}
}
@ -129,17 +123,14 @@ public class OctopusForm {
for (Entity entity : Methods.getEntitiesAroundPoint(location, 2.5)) {
if (entity.getEntityId() == player.getEntityId())
continue;
if (Methods.isRegionProtectedFromBuild(player, "OctopusForm",
entity.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "OctopusForm", entity.getLocation()))
continue;
// if (Torrent.canThaw(entity.getLocation().getBlock())
// || Wave.canThaw(entity.getLocation().getBlock()))
// continue;
if (Methods.isObstructed(location, entity.getLocation()))
continue;
entity.setVelocity(Methods
.getDirection(player.getLocation(), location).normalize()
.multiply(1.75));
entity.setVelocity(Methods.getDirection(player.getLocation(), location).normalize().multiply(1.75));
if (entity instanceof LivingEntity)
Methods.damageEntity(player, entity, damage);
}
@ -176,8 +167,7 @@ public class OctopusForm {
return;
}
if (sourceblock.getLocation().distance(player.getLocation()) > range
&& sourceselected) {
if (sourceblock.getLocation().distance(player.getLocation()) > range && sourceselected) {
remove();
return;
}
@ -215,16 +205,14 @@ public class OctopusForm {
returnWater();
}
} else if (sourcelocation.distance(location) > radius) {
Vector vector = Methods.getDirection(sourcelocation,
location.getBlock().getLocation()).normalize();
Vector vector = Methods.getDirection(sourcelocation, location.getBlock().getLocation()).normalize();
sourcelocation.add(vector);
Block newblock = sourcelocation.getBlock();
if (!newblock.equals(sourceblock)) {
source.revertBlock();
source = null;
if (!Methods.isSolid(newblock)) {
source = new TempBlock(newblock, Material.STATIONARY_WATER,
(byte) 8);
source = new TempBlock(newblock, Material.STATIONARY_WATER, (byte) 8);
sourceblock = newblock;
}
}
@ -233,8 +221,7 @@ public class OctopusForm {
source.revertBlock();
source = null;
Vector vector = new Vector(1, 0, 0);
startangle = vector.angle(Methods.getDirection(
sourceblock.getLocation(), location));
startangle = vector.angle(Methods.getDirection( sourceblock.getLocation(), location));
angle = startangle;
}
} else if (forming) {
@ -269,10 +256,8 @@ public class OctopusForm {
for (double theta = startangle; theta < startangle + angle; theta += 10) {
double rtheta = Math.toRadians(theta);
Block block = location
.clone()
.add(new Vector(radius * Math.cos(rtheta), 0, radius
* Math.sin(rtheta))).getBlock();
Block block = location.clone().add(
new Vector(radius * Math.cos(rtheta), 0, radius * Math.sin(rtheta))).getBlock();
if (!doneblocks.contains(block)) {
addWater(block);
doneblocks.add(block);
@ -282,17 +267,12 @@ public class OctopusForm {
Vector eyedir = player.getEyeLocation().getDirection();
eyedir.setY(0);
double tentacleangle = Math.toDegrees((new Vector(1, 0, 0))
.angle(eyedir)) + dta / 2;
double tentacleangle = Math.toDegrees((new Vector(1, 0, 0)).angle(eyedir)) + dta / 2;
int astep = animstep;
for (double tangle = tentacleangle; tangle < tentacleangle + 360; tangle += dta) {
astep += 1;
double phi = Math.toRadians(tangle);
tentacle(
location.clone().add(
new Vector(radius * Math.cos(phi), 0, radius
* Math.sin(phi))), astep);
tentacle(location.clone().add(new Vector(radius * Math.cos(phi), 0, radius * Math.sin(phi))), astep);
}
for (TempBlock block : blocks) {
@ -331,8 +311,7 @@ public class OctopusForm {
} else if (animationstep == 2 || animationstep == 8) {
addWater(baseblock);
} else {
addWater(base.clone()
.add(direction.getX(), 1, direction.getZ()).getBlock());
addWater(base.clone().add(direction.getX(), 1, direction.getZ()).getBlock());
}
}
@ -342,19 +321,13 @@ public class OctopusForm {
Block baseblock = base.clone().add(0, 2, 0).getBlock();
if (animationstep == 1) {
addWater(base.clone()
.add(-direction.getX(), 2, -direction.getZ())
.getBlock());
} else if (animationstep == 3 || animationstep == 7
|| animationstep == 2 || animationstep == 8) {
addWater(base.clone().add(-direction.getX(), 2, -direction.getZ()).getBlock());
} else if (animationstep == 3 || animationstep == 7 || animationstep == 2 || animationstep == 8) {
addWater(baseblock);
} else if (animationstep == 4 || animationstep == 6) {
addWater(base.clone()
.add(direction.getX(), 2, direction.getZ()).getBlock());
addWater(base.clone().add(direction.getX(), 2, direction.getZ()).getBlock());
} else {
addWater(base.clone()
.add(2 * direction.getX(), 2, 2 * direction.getZ())
.getBlock());
addWater(base.clone().add(2 * direction.getX(), 2, 2 * direction.getZ()).getBlock());
}
}
@ -362,8 +335,7 @@ public class OctopusForm {
private void addWater(Block block) {
clearNearbyWater(block);
if (Methods.isRegionProtectedFromBuild(player, "OctopusForm",
block.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "OctopusForm", block.getLocation()))
return;
if (TempBlock.isTempBlock(block)) {
TempBlock tblock = TempBlock.get(block);
@ -372,9 +344,7 @@ public class OctopusForm {
tblock.setType(Material.WATER, full);
newblocks.add(tblock);
}
} else if (Methods.isWaterbendable(block, player)
|| block.getType() == Material.FIRE
|| block.getType() == Material.AIR) {
} else if (Methods.isWaterbendable(block, player) || block.getType() == Material.FIRE || block.getType() == Material.AIR) {
newblocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
}
}
@ -400,8 +370,7 @@ public class OctopusForm {
// }
private void clearNearbyWater(Block block) {
BlockFace[] faces = { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST,
BlockFace.WEST, BlockFace.DOWN };
BlockFace[] faces = { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.DOWN };
for (BlockFace face : faces) {
Block rel = block.getRelative(face);
if (Methods.isWater(rel) && !TempBlock.isTempBlock(rel)) {
@ -449,10 +418,7 @@ public class OctopusForm {
} else {
Location location = player.getLocation();
double rtheta = Math.toRadians(startangle);
Block block = location
.clone()
.add(new Vector(radius * Math.cos(rtheta), 0, radius
* Math.sin(rtheta))).getBlock();
Block block = location.clone().add(new Vector(radius * Math.cos(rtheta), 0, radius * Math.sin(rtheta))).getBlock();
new WaterReturn(player, block);
}
}

View file

@ -10,9 +10,9 @@ import com.projectkorra.ProjectKorra.ProjectKorra;
public class Plantbending {
private static final long regrowtime = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.Plantbending.RegrowTime");
private static ConcurrentHashMap<Integer, Plantbending> instances = new ConcurrentHashMap<Integer, Plantbending>();
private static final long regrowtime = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.Plantbending.RegrowTime");
private static int ID = Integer.MIN_VALUE;
private Block block;
@ -26,8 +26,7 @@ public class Plantbending {
this.block = block;
type = block.getType();
data = block.getData();
time = System.currentTimeMillis() + regrowtime / 2
+ (long) (Math.random() * (double) regrowtime) / 2;
time = System.currentTimeMillis() + regrowtime / 2 + (long) (Math.random() * (double) regrowtime) / 2;
id = ID;
instances.put(id, this);
if (ID >= Integer.MAX_VALUE) {

View file

@ -18,11 +18,13 @@ import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
public class SpikeField {
public static Map<Player, Long> cooldowns = new HashMap<Player, Long>();
private static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.IceSpike.Cooldown");
private static int radius = 6;
public static int numofspikes = ((radius * 2) * (radius * 2)) / 16;
private static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.IceSpike.Cooldown");
public static Map<Player, Long> cooldowns = new HashMap<Player, Long>();
Random ran = new Random();
private int damage = 2;
@ -40,8 +42,7 @@ public class SpikeField {
for (int x = -(radius - 1); x <= (radius - 1); x++) {
for (int z = -(radius - 1); z <= (radius - 1); z++) {
for (int y = -1; y <= 1; y++) {
Block testblock = p.getWorld().getBlockAt(locX + x,
locY + y, locZ + z);
Block testblock = p.getWorld().getBlockAt(locX + x, locY + y, locZ + z);
if (testblock.getType() == Material.ICE
&& testblock.getRelative(BlockFace.UP).getType() == Material.AIR
&& !(testblock.getX() == p.getEyeLocation()
@ -56,8 +57,7 @@ public class SpikeField {
}
}
List<Entity> entities = Methods.getEntitiesAroundPoint(p.getLocation(),
radius);
List<Entity> entities = Methods.getEntitiesAroundPoint(p.getLocation(), radius);
for (int i = 0; i < numofspikes; i++) {
if (iceblocks.isEmpty())
@ -66,12 +66,9 @@ public class SpikeField {
Entity target = null;
Block targetblock = null;
for (Entity entity : entities) {
if (entity instanceof LivingEntity
&& entity.getEntityId() != p.getEntityId()) {
if (entity instanceof LivingEntity && entity.getEntityId() != p.getEntityId()) {
for (Block block : iceblocks) {
if (block.getX() == entity.getLocation().getBlockX()
&& block.getZ() == entity.getLocation()
.getBlockZ()) {
if (block.getX() == entity.getLocation().getBlockX() && block.getZ() == entity.getLocation().getBlockZ()) {
target = entity;
targetblock = block;
break;

View file

@ -24,32 +24,26 @@ public class Torrent {
private static ConcurrentHashMap<TempBlock, Player> frozenblocks = new ConcurrentHashMap<TempBlock, Player>();
static long interval = 30;
static double range = 25;
private static int defaultrange = 20;
private static int selectrange = 10;
private static double radius = 3;
static double range = 25;
private static int damage = 2;
private static int deflectdamage = 1;
private static double factor = 1;
private static int maxlayer = 3;
private static double factor = 1;
private static double radius = 3;
private static double ylimit = 0.2;
private static final byte full = 0x0;
private double startangle = 0;
private Block sourceblock;
private TempBlock source;
private Location location;
private Player player;
private long time;
private double startangle = 0;
private double angle = 20;
private int layer = 0;
private ArrayList<TempBlock> blocks = new ArrayList<TempBlock>();
private ArrayList<TempBlock> launchblocks = new ArrayList<TempBlock>();
private ArrayList<Entity> hurtentities = new ArrayList<Entity>();
private boolean sourceselected = false;
private boolean settingup = false;
private boolean forming = false;
@ -58,6 +52,10 @@ public class Torrent {
private boolean launching = false;
private boolean freeze = false;
private ArrayList<TempBlock> blocks = new ArrayList<TempBlock>();
private ArrayList<TempBlock> launchblocks = new ArrayList<TempBlock>();
private ArrayList<Entity> hurtentities = new ArrayList<Entity>();
public Torrent(Player player) {
if (instances.containsKey(player)) {
Torrent torrent = instances.get(player);
@ -68,8 +66,7 @@ public class Torrent {
}
this.player = player;
time = System.currentTimeMillis();
sourceblock = Methods.getWaterSourceBlock(player, selectrange,
Methods.canPlantbend(player));
sourceblock = Methods.getWaterSourceBlock(player, selectrange, Methods.canPlantbend(player));
if (sourceblock != null) {
sourceselected = true;
instances.put(player, this);
@ -83,8 +80,7 @@ public class Torrent {
return;
List<Block> ice = Methods.getBlocksAroundPoint(location, layer);
for (Block block : ice) {
if (Methods.isTransparentToEarthbending(player, block)
&& block.getType() != Material.ICE) {
if (Methods.isTransparentToEarthbending(player, block) && block.getType() != Material.ICE) {
TempBlock tblock = new TempBlock(block, Material.ICE, (byte) 0);
frozenblocks.put(tblock, player);
}
@ -153,8 +149,7 @@ public class Torrent {
return;
}
Location eyeloc = player.getEyeLocation();
double startangle = player.getEyeLocation().getDirection()
.angle(new Vector(1, 0, 0));
double startangle = player.getEyeLocation().getDirection().angle(new Vector(1, 0, 0));
double dx = radius * Math.cos(startangle);
double dy = 0;
double dz = radius * Math.sin(startangle);
@ -177,8 +172,7 @@ public class Torrent {
Vector direction = new Vector(0, 1, 0);
location = location.clone().add(direction);
} else {
Vector direction = Methods.getDirection(location, setup)
.normalize();
Vector direction = Methods.getDirection(location, setup).normalize();
location = location.clone().add(direction);
}
@ -188,18 +182,15 @@ public class Torrent {
source = null;
forming = true;
} else {
if (!location.getBlock().equals(
source.getLocation().getBlock())) {
if (!location.getBlock().equals(source.getLocation().getBlock())) {
source.revertBlock();
source = null;
Block block = location.getBlock();
if (!Methods.isTransparentToEarthbending(player, block)
|| block.isLiquid()) {
if (!Methods.isTransparentToEarthbending(player, block) || block.isLiquid()) {
remove();
return;
}
source = new TempBlock(location.getBlock(),
Material.STATIONARY_WATER, (byte) 8);
source = new TempBlock(location.getBlock(), Material.STATIONARY_WATER, (byte) 8);
}
}
}
@ -276,13 +267,10 @@ public class Torrent {
location = blockloc.clone();
Block block = blockloc.getBlock();
if (!doneblocks.contains(block) && !Methods.isRegionProtectedFromBuild(player, "Torrent", blockloc)) {
if (Methods.isTransparentToEarthbending(player, block)
&& !block.isLiquid()) {
launchblocks.add(new TempBlock(block, Material.STATIONARY_WATER,
(byte) 8));
if (Methods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
launchblocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
doneblocks.add(block);
} else if (!Methods
.isTransparentToEarthbending(player, block))
} else if (!Methods.isTransparentToEarthbending(player, block))
break;
}
}
@ -294,8 +282,7 @@ public class Torrent {
}
Entity target = Methods.getTargetedEntity(player, range, hurtentities);
Location targetloc = player.getTargetBlock(
Methods.getTransparentEarthbending(), (int) range).getLocation();
Location targetloc = player.getTargetBlock(Methods.getTransparentEarthbending(), (int) range).getLocation();
// Location targetloc = Methods.getTargetedLocation(player, range,
// Methods.transparentEarthbending);
if (target != null) {
@ -304,8 +291,7 @@ public class Torrent {
ArrayList<TempBlock> newblocks = new ArrayList<TempBlock>();
List<Entity> entities = Methods.getEntitiesAroundPoint(
player.getLocation(), range + 5);
List<Entity> entities = Methods.getEntitiesAroundPoint(player.getLocation(), range + 5);
List<Entity> affectedentities = new ArrayList<Entity>();
Block realblock = launchblocks.get(0).getBlock();
@ -378,16 +364,11 @@ public class Torrent {
for (Entity entity : entities) {
if (entity.getWorld() != block.getBlock().getWorld())
continue;
if (entity.getLocation().distance(block.getLocation()) <= 1.5
&& !affectedentities.contains(entity)) {
if (entity.getLocation().distance(block.getLocation()) <= 1.5 && !affectedentities.contains(entity)) {
if (i == 0) {
affect(entity, dir);
} else {
affect(entity,
Methods.getDirection(
block.getLocation(),
launchblocks.get(i - 1)
.getLocation()).normalize());
affect(entity, Methods.getDirection(block.getLocation(), launchblocks.get(i - 1).getLocation()).normalize());
}
affectedentities.add(entity);
}
@ -421,15 +402,13 @@ public class Torrent {
Location blockloc = loc.clone().add(dx, dy, dz);
Block block = blockloc.getBlock();
if (!doneblocks.contains(block)) {
if (Methods.isTransparentToEarthbending(player, block)
&& !block.isLiquid()) {
if (Methods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
blocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
doneblocks.add(block);
for (Entity entity : entities) {
if (entity.getWorld() != blockloc.getWorld())
continue;
if (!affectedentities.contains(entity)
&& entity.getLocation().distance(blockloc) <= 1.5) {
if (!affectedentities.contains(entity) && entity.getLocation().distance(blockloc) <= 1.5) {
deflect(entity);
}
}
@ -470,11 +449,8 @@ public class Torrent {
return;
if (WaterReturn.hasWaterBottle(player)) {
Location eyeloc = player.getEyeLocation();
Block block = eyeloc.add(eyeloc.getDirection().normalize())
.getBlock();
if (Methods.isTransparentToEarthbending(player, block)
&& Methods.isTransparentToEarthbending(player,
eyeloc.getBlock())) {
Block block = eyeloc.add(eyeloc.getDirection().normalize()).getBlock();
if (Methods.isTransparentToEarthbending(player, block) && Methods.isTransparentToEarthbending(player, eyeloc.getBlock())) {
block.setType(Material.WATER);
block.setData(full);
Torrent tor = new Torrent(player);
@ -569,8 +545,7 @@ public class Torrent {
thaw(block);
continue;
}
if (block.getLocation().distance(player.getLocation()) > range
|| !Methods.canBend(player.getName(), "Torrent")) {
if (block.getLocation().distance(player.getLocation()) > range || !Methods.canBend(player.getName(), "Torrent")) {
thaw(block);
}
}

View file

@ -24,16 +24,16 @@ public class TorrentBurst {
private static double defaultfactor = 1.5;
private static long interval = Torrent.interval;
// private static final byte full = 0x0;
// private static final byte full = 0x0;
// private static final Vector reference = new Vector(1, 0, 0);
private Player player;
private int id;
private long time;
private Location origin;
private double radius = dr;
private double maxradius = defaultmaxradius;
private double factor = defaultfactor;
private Location origin;
private Player player;
private ConcurrentHashMap<Integer, ConcurrentHashMap<Integer, Double>> heights = new ConcurrentHashMap<Integer, ConcurrentHashMap<Integer, Double>>();
private ArrayList<TempBlock> blocks = new ArrayList<TempBlock>();
private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
@ -135,10 +135,8 @@ public class TorrentBurst {
Block block = location.getBlock();
if (torrentblocks.contains(block))
continue;
if (Methods.isTransparentToEarthbending(player,
block)) {
TempBlock tempBlock = new TempBlock(block, Material.STATIONARY_WATER,
(byte) 8);
if (Methods.isTransparentToEarthbending(player, block)) {
TempBlock tempBlock = new TempBlock(block, Material.STATIONARY_WATER, (byte) 8);
blocks.add(tempBlock);
torrentblocks.add(block);
} else {
@ -165,8 +163,7 @@ public class TorrentBurst {
Vector direction = Methods.getDirection(origin, entity.getLocation());
direction.setY(0);
direction.normalize();
entity.setVelocity(entity.getVelocity().clone()
.add(direction.multiply(factor)));
entity.setVelocity(entity.getVelocity().clone().add(direction.multiply(factor)));
}
private void remove() {
@ -177,8 +174,7 @@ public class TorrentBurst {
}
private void returnWater() {
Location location = new Location(origin.getWorld(), origin.getX()
+ radius, origin.getY(), origin.getZ());
Location location = new Location(origin.getWorld(), origin.getX() + radius, origin.getY(), origin.getZ());
if (!location.getWorld().equals(player.getWorld()))
return;
if (location.distance(player.getLocation()) > maxradius + 5)

View file

@ -10,6 +10,7 @@ import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -23,46 +24,45 @@ import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
import com.projectkorra.ProjectKorra.firebending.FireBlast;
public class WaterManipulation {
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
public static ConcurrentHashMap<Integer, WaterManipulation> instances = new ConcurrentHashMap<Integer, WaterManipulation>();
private static Map<String, Long> cooldowns = new HashMap<String, Long>();
public static ConcurrentHashMap<Block, Block> affectedblocks = new ConcurrentHashMap<Block, Block>();
public static ConcurrentHashMap<Player, Integer> prepared = new ConcurrentHashMap<Player, Integer>();
static double range = config.getDouble("Abilities.Water.WaterManipulation.Range");
private static double pushfactor = config.getDouble("Abilities.Water.WaterManipulation.Push");
private static double defaultdamage = config.getDouble("Abilities.Water.WaterManipulation.Damage");
private static double speed = config.getDouble("Abilities.Water.WaterManipulation.Speed");
private static long cooldown = config.getLong("Properties.GlobalCooldown");
private static long interval = (long) (1000. / speed);
private static final double deflectrange = 3;
// private static double speed = 1.5;
private static int ID = Integer.MIN_VALUE;
private static final byte full = 0x0;
private static HashSet<Byte> water = new HashSet<Byte>();
// private static final byte half = 0x4;
static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.WaterManipulation.Range");
private static double pushfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.WaterManipulation.Push");
private static double defaultdamage = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.WaterManipulation.Damage");
private static double speed = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.WaterManipulation.Speed");
private static long cooldown = ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown");
private static Map<String, Long> cooldowns = new HashMap<String, Long>();
private static final double deflectrange = 3;
// private static double speed = 1.5;
private static HashSet<Byte> water = new HashSet<Byte>();
private static long interval = (long) (1000. / speed);
Player player;
private long time;
private double damage = defaultdamage;
private int displrange;
private int id;
private Location location = null;
private Block sourceblock = null;
private TempBlock trail, trail2;
private boolean progressing = false;
private Location firstdestination = null;
private Location targetdestination = null;
private Vector firstdirection = null;
private Vector targetdirection = null;
private boolean progressing = false;
private boolean falling = false;
private boolean settingup = false;
// private boolean targetting = false;
private final boolean displacing = false;
private long time;
private double damage = defaultdamage;
private int displrange;
public WaterManipulation(Player player) {
if (water.isEmpty()) {
@ -84,8 +84,7 @@ public class WaterManipulation {
public boolean prepare() {
// Block block = player.getTargetBlock(null, (int) range);
Block block = Methods.getWaterSourceBlock(player, range,
Methods.canPlantbend(player));
Block block = Methods.getWaterSourceBlock(player, range, Methods.canPlantbend(player));
// if (prepared.containsKey(player)
// && !Methods.isWaterbendable(block, player)) {
// instances.get(prepared.get(player)).displacing = true;
@ -137,13 +136,9 @@ public class WaterManipulation {
progressing = true;
settingup = true;
firstdestination = getToEyeLevel();
firstdirection = Methods.getDirection(
sourceblock.getLocation(), firstdestination)
.normalize();
targetdestination = Methods.getPointOnLine(firstdestination,
targetdestination, range);
targetdirection = Methods.getDirection(firstdestination,
targetdestination).normalize();
firstdirection = Methods.getDirection(sourceblock.getLocation(), firstdestination).normalize();
targetdestination = Methods.getPointOnLine(firstdestination, targetdestination, range);
targetdirection = Methods.getDirection(firstdestination, targetdestination).normalize();
if (Methods.isPlant(sourceblock))
new Plantbending(sourceblock);
@ -161,8 +156,7 @@ public class WaterManipulation {
Entity target = Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
Location location;
if (target == null) {
location = Methods.getTargetedLocation(player, range,
Methods.transparentToEarthbending);
location = Methods.getTargetedLocation(player, range, Methods.transparentToEarthbending);
} else {
// targetting = true;
location = ((LivingEntity) target).getEyeLocation();
@ -194,8 +188,7 @@ public class WaterManipulation {
private void redirect(Player player, Location targetlocation) {
if (progressing && !settingup) {
if (location.distance(player.getLocation()) <= range)
targetdirection = Methods.getDirection(location, targetlocation)
.normalize();
targetdirection = Methods.getDirection(location, targetlocation).normalize();
targetdestination = targetlocation;
this.player = player;
}
@ -209,8 +202,7 @@ public class WaterManipulation {
}
if (System.currentTimeMillis() - time >= interval) {
// removeWater(oldwater);
if (Methods.isRegionProtectedFromBuild(player,
"WaterManipulation", location)) {
if (Methods.isRegionProtectedFromBuild(player, "WaterManipulation", location)) {
breakBlock();
return false;
}
@ -221,9 +213,7 @@ public class WaterManipulation {
unfocusBlock();
return false;
}
if (!progressing
&& !falling
&& !Methods.getBoundAbility(player).equalsIgnoreCase("WaterManipulation")) {
if (!progressing && !falling && !Methods.getBoundAbility(player).equalsIgnoreCase("WaterManipulation")) {
unfocusBlock();
return false;
}
@ -269,8 +259,7 @@ public class WaterManipulation {
} else {
if (!progressing) {
sourceblock.getWorld().playEffect(location, Effect.SMOKE,
4, (int) range);
sourceblock.getWorld().playEffect(location, Effect.SMOKE, 4, (int) range);
return false;
}
@ -296,14 +285,12 @@ public class WaterManipulation {
Block block = location.getBlock();
if (displacing) {
Block targetblock = player.getTargetBlock(null, displrange);
direction = Methods.getDirection(location,
targetblock.getLocation()).normalize();
direction = Methods.getDirection(location, targetblock.getLocation()).normalize();
if (!location.getBlock().equals(targetblock.getLocation())) {
location = location.clone().add(direction);
block = location.getBlock();
if (block.getLocation().equals(
sourceblock.getLocation())) {
if (block.getLocation().equals( sourceblock.getLocation())) {
location = location.clone().add(direction);
block = location.getBlock();
}
@ -315,10 +302,8 @@ public class WaterManipulation {
double radius = FireBlast.affectingradius;
Player source = player;
if (EarthBlast.annihilateBlasts(location, radius, source)
|| WaterManipulation.annihilateBlasts(location,
radius, source)
|| FireBlast.annihilateBlasts(location, radius,
source)) {
|| WaterManipulation.annihilateBlasts(location, radius, source)
|| FireBlast.annihilateBlasts(location, radius, source)) {
breakBlock();
new WaterReturn(player, sourceblock);
return false;
@ -351,21 +336,17 @@ public class WaterManipulation {
}
}
if (Methods.isTransparentToEarthbending(player, block)
&& !block.isLiquid()) {
if (Methods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
Methods.breakBlock(block);
} else if (block.getType() != Material.AIR
&& !Methods.isWater(block)) {
} else if (block.getType() != Material.AIR && !Methods.isWater(block)) {
breakBlock();
new WaterReturn(player, sourceblock);
return false;
}
if (!displacing) {
for (Entity entity : Methods.getEntitiesAroundPoint(location,
FireBlast.affectingradius)) {
if (entity instanceof LivingEntity
&& entity.getEntityId() != player.getEntityId()) {
for (Entity entity : Methods.getEntitiesAroundPoint(location, FireBlast.affectingradius)) {
if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId()) {
// Block testblock = location.getBlock();
// Block block1 = entity.getLocation().getBlock();
@ -382,9 +363,7 @@ public class WaterManipulation {
// .add(direction));
if (AvatarState.isAvatarState(player))
damage = AvatarState.getValue(damage);
Methods.damageEntity(player, entity, (int) Methods
.waterbendingNightAugment(damage,
player.getWorld()));
Methods.damageEntity(player, entity, (int) Methods.waterbendingNightAugment(damage, player.getWorld()));
progressing = false;
// }
}
@ -416,8 +395,7 @@ public class WaterManipulation {
trail = new TempBlock(sourceblock, Material.WATER, (byte) 1);
sourceblock = block;
if (location.distance(targetdestination) <= 1
|| location.distance(firstdestination) > range) {
if (location.distance(targetdestination) <= 1 || location.distance(firstdestination) > range) {
falling = true;
progressing = false;
@ -516,17 +494,14 @@ public class WaterManipulation {
prepared.remove(player);
} else if (WaterReturn.hasWaterBottle(player)) {
Location eyeloc = player.getEyeLocation();
Block block = eyeloc.add(eyeloc.getDirection().normalize())
.getBlock();
Block block = eyeloc.add(eyeloc.getDirection().normalize()).getBlock();
if (Methods.isTransparentToEarthbending(player, block)
&& Methods.isTransparentToEarthbending(player,
eyeloc.getBlock())) {
&& Methods.isTransparentToEarthbending(player, eyeloc.getBlock())) {
if (getTargetLocation(player).distance(block.getLocation()) > 1) {
block.setType(Material.WATER);
block.setData(full);
WaterManipulation watermanip = new WaterManipulation(
player);
WaterManipulation watermanip = new WaterManipulation(player);
watermanip.moveWater();
if (!watermanip.progressing) {
block.setType(Material.AIR);
@ -551,8 +526,7 @@ public class WaterManipulation {
if (!manip.location.getWorld().equals(player.getWorld()))
continue;
if (Methods.isRegionProtectedFromBuild(player,
"WaterManipulation", manip.location))
if (Methods.isRegionProtectedFromBuild(player, "WaterManipulation", manip.location))
continue;
if (manip.player.equals(player))
@ -562,11 +536,9 @@ public class WaterManipulation {
Vector vector = location.getDirection();
Location mloc = manip.location;
if (mloc.distance(location) <= range
&& Methods.getDistanceFromLine(vector, location,
manip.location) < deflectrange
&& mloc.distance(location.clone().add(vector)) < mloc
.distance(location.clone().add(
vector.clone().multiply(-1)))) {
&& Methods.getDistanceFromLine(vector, location, manip.location) < deflectrange
&& mloc.distance(location.clone().add(vector)) <
mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
manip.redirect(player, getTargetLocation(player));
}
@ -586,19 +558,16 @@ public class WaterManipulation {
if (!manip.progressing)
continue;
if (Methods.isRegionProtectedFromBuild(player,
"WaterManipulation", manip.location))
if (Methods.isRegionProtectedFromBuild(player, "WaterManipulation", manip.location))
continue;
Location location = player.getEyeLocation();
Vector vector = location.getDirection();
Location mloc = manip.location;
if (mloc.distance(location) <= range
&& Methods.getDistanceFromLine(vector, location,
manip.location) < deflectrange
&& mloc.distance(location.clone().add(vector)) < mloc
.distance(location.clone().add(
vector.clone().multiply(-1)))) {
&& Methods.getDistanceFromLine(vector, location, manip.location) < deflectrange
&& mloc.distance(location.clone().add(vector)) <
mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
manip.breakBlock();
}
@ -699,13 +668,11 @@ public class WaterManipulation {
}
}
public static boolean annihilateBlasts(Location location, double radius,
Player source) {
public static boolean annihilateBlasts(Location location, double radius, Player source) {
boolean broke = false;
for (int id : instances.keySet()) {
WaterManipulation manip = instances.get(id);
if (manip.location.getWorld().equals(location.getWorld())
&& !source.equals(manip.player))
if (manip.location.getWorld().equals(location.getWorld()) && !source.equals(manip.player))
if (manip.location.distance(location) <= radius) {
manip.breakBlock();
broke = true;

View file

@ -30,8 +30,7 @@ public class WaterPassive {
if (Methods.canBendPassive(player.getName(), Element.Water)) {
if (WaterSpout.instances.containsKey(player)) {
continue;
}
else if (ability == null || !AbilityModuleManager.shiftabilities.contains(ability)) {
} else if (ability == null || !AbilityModuleManager.shiftabilities.contains(ability)) {
if (player.isSneaking() && Methods.isWater(player.getLocation().getBlock())) {
player.setVelocity(player.getEyeLocation().getDirection().clone().normalize().multiply(swimFactor));
}

View file

@ -19,9 +19,9 @@ public class WaterReturn {
private static ConcurrentHashMap<Player, WaterReturn> instances = new ConcurrentHashMap<Player, WaterReturn>();
// private static int ID = Integer.MIN_VALUE;
private static long interval = 50;
private static double range = 30;
private static final byte full = 0x0;
private static double range = 30;
private Player player;
// private int id;
@ -35,11 +35,9 @@ public class WaterReturn {
this.player = player;
location = block.getLocation();
if (Methods.canBend(player.getName(), "WaterManipulation")) {
if (!Methods.isRegionProtectedFromBuild(player,
"WaterManipulation", location)
if (!Methods.isRegionProtectedFromBuild(player, "WaterManipulation", location)
&& Methods.canBend(player.getName(), "WaterManipulation")) {
if (Methods.isTransparentToEarthbending(player, block)
&& !block.isLiquid())
if (Methods.isTransparentToEarthbending(player, block) && !block.isLiquid())
this.block = new TempBlock(block, Material.WATER, full);
}
}
@ -71,8 +69,7 @@ public class WaterReturn {
time = System.currentTimeMillis();
Vector direction = Methods
.getDirection(location, player.getEyeLocation()).normalize();
Vector direction = Methods.getDirection(location, player.getEyeLocation()).normalize();
location = location.clone().add(direction);
if (location == null || block == null) {
@ -83,14 +80,12 @@ public class WaterReturn {
if (location.getBlock().equals(block.getLocation().getBlock()))
return;
if (Methods.isRegionProtectedFromBuild(player,
"WaterManipulation", location)) {
if (Methods.isRegionProtectedFromBuild(player, "WaterManipulation", location)) {
remove();
return;
}
if (location.distance(player.getEyeLocation()) > Methods
.waterbendingNightAugment(range, player.getWorld())) {
if (location.distance(player.getEyeLocation()) > Methods.waterbendingNightAugment(range, player.getWorld())) {
remove();
return;
}
@ -101,8 +96,7 @@ public class WaterReturn {
}
Block newblock = location.getBlock();
if (Methods.isTransparentToEarthbending(player, newblock)
&& !newblock.isLiquid()) {
if (Methods.isTransparentToEarthbending(player, newblock) && !newblock.isLiquid()) {
block.revertBlock();
block = new TempBlock(newblock, Material.WATER, full);
} else {
@ -138,11 +132,9 @@ public class WaterReturn {
} else {
item.setAmount(item.getAmount() - 1);
inventory.setItem(index, item);
HashMap<Integer, ItemStack> leftover = inventory
.addItem(new ItemStack(Material.POTION));
HashMap<Integer, ItemStack> leftover = inventory.addItem(new ItemStack(Material.POTION));
for (int left : leftover.keySet()) {
player.getWorld().dropItemNaturally(player.getLocation(),
leftover.get(left));
player.getWorld().dropItemNaturally(player.getLocation(), leftover.get(left));
}
}
}
@ -194,11 +186,9 @@ public class WaterReturn {
} else {
item.setAmount(item.getAmount() - 1);
inventory.setItem(index, item);
HashMap<Integer, ItemStack> leftover = inventory
.addItem(new ItemStack(Material.GLASS_BOTTLE));
HashMap<Integer, ItemStack> leftover = inventory.addItem(new ItemStack(Material.GLASS_BOTTLE));
for (int left : leftover.keySet()) {
player.getWorld().dropItemNaturally(player.getLocation(),
leftover.get(left));
player.getWorld().dropItemNaturally(player.getLocation(), leftover.get(left));
}
}
}

View file

@ -145,18 +145,15 @@ public class WaterSpout {
WaterSpout spout = instances.get(player);
int height = defaultheight;
if (Methods.isNight(player.getWorld()))
height = (int) Methods.waterbendingNightAugment((double) height,
player.getWorld());
height = (int) Methods.waterbendingNightAugment((double) height, player.getWorld());
int maxheight = (int) ((double) defaultheight * ProjectKorra.plugin.getConfig().getDouble("Properties.Water.NightFactor")) + 5;
Block blocki;
for (int i = 0; i < maxheight; i++) {
blocki = location.clone().add(0, -i, 0).getBlock();
if (Methods.isRegionProtectedFromBuild(player, "WaterSpout",
blocki.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "WaterSpout", blocki.getLocation()))
return -1;
if (!affectedblocks.contains(blocki)) {
if (blocki.getType() == Material.WATER
|| blocki.getType() == Material.STATIONARY_WATER) {
if (blocki.getType() == Material.WATER || blocki.getType() == Material.STATIONARY_WATER) {
if (!TempBlock.isTempBlock(blocki)) {
revertBaseBlock(player);
}
@ -165,13 +162,10 @@ public class WaterSpout {
return height;
return i;
}
if (blocki.getType() == Material.ICE
|| blocki.getType() == Material.SNOW
|| blocki.getType() == Material.SNOW_BLOCK) {
if (blocki.getType() == Material.ICE || blocki.getType() == Material.SNOW || blocki.getType() == Material.SNOW_BLOCK) {
if (!TempBlock.isTempBlock(blocki)) {
revertBaseBlock(player);
instances.get(player).baseblock = new TempBlock(blocki,
Material.STATIONARY_WATER, (byte) 8);
instances.get(player).baseblock = new TempBlock(blocki, Material.STATIONARY_WATER, (byte) 8);
}
// blocki.setType(Material.WATER);
// blocki.setData(full);
@ -180,8 +174,7 @@ public class WaterSpout {
return height;
return i;
}
if ((blocki.getType() != Material.AIR && (!Methods
.isPlant(blocki) || !Methods.canPlantbend(player)))) {
if ((blocki.getType() != Material.AIR && (!Methods.isPlant(blocki) || !Methods.canPlantbend(player)))) {
revertBaseBlock(player);
return -1;
}
@ -218,8 +211,7 @@ public class WaterSpout {
return players;
}
public static void removeSpouts(Location loc0, double radius,
Player sourceplayer) {
public static void removeSpouts(Location loc0, double radius, Player sourceplayer) {
for (Player player : instances.keySet()) {
if (!player.equals(sourceplayer)) {
Location loc1 = player.getLocation().getBlock().getLocation();

View file

@ -19,29 +19,26 @@ import com.projectkorra.ProjectKorra.firebending.FireBlast;
public class WaterWall {
public static ConcurrentHashMap<Integer, WaterWall> instances = new ConcurrentHashMap<Integer, WaterWall>();
private static final long interval = 30;
public static ConcurrentHashMap<Block, Block> affectedblocks = new ConcurrentHashMap<Block, Block>();
public static ConcurrentHashMap<Block, Player> wallblocks = new ConcurrentHashMap<Block, Player>();
private static final byte full = 0x0;
// private static final byte half = 0x4;
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wall.Range");
private static final double defaultradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wall.Radius");
// private static double speed = 1.5;
private static final long interval = 30;
private static final byte full = 0x0;
// private static final byte half = 0x4;
Player player;
private Location location = null;
private Block sourceblock = null;
// private Block oldwater = null;
private boolean progressing = false;
private Location firstdestination = null;
private Location targetdestination = null;
private Vector firstdirection = null;
private Vector targetdirection = null;
// private boolean falling = false;
private boolean progressing = false;
private boolean settingup = false;
private boolean forming = false;
private boolean frozen = false;
@ -91,15 +88,12 @@ public class WaterWall {
}
}
if (!instances.containsKey(player.getEntityId())
&& WaterReturn.hasWaterBottle(player)) {
if (!instances.containsKey(player.getEntityId()) && WaterReturn.hasWaterBottle(player)) {
Location eyeloc = player.getEyeLocation();
Block block = eyeloc.add(eyeloc.getDirection().normalize())
.getBlock();
Block block = eyeloc.add(eyeloc.getDirection().normalize()).getBlock();
if (Methods.isTransparentToEarthbending(player, block)
&& Methods.isTransparentToEarthbending(player,
eyeloc.getBlock())) {
&& Methods.isTransparentToEarthbending(player, eyeloc.getBlock())) {
block.setType(Material.WATER);
block.setData(full);
Wave wave = new Wave(player);
@ -150,8 +144,7 @@ public class WaterWall {
public boolean prepare() {
cancelPrevious();
// Block block = player.getTargetBlock(null, (int) range);
Block block = Methods.getWaterSourceBlock(player, range,
Methods.canPlantbend(player));
Block block = Methods.getWaterSourceBlock(player, range, Methods.canPlantbend(player));
if (block != null) {
sourceblock = block;
focusBlock();
@ -185,9 +178,7 @@ public class WaterWall {
public void moveWater() {
if (sourceblock != null) {
targetdestination = player.getTargetBlock(
Methods.getTransparentEarthbending(), (int) range)
.getLocation();
targetdestination = player.getTargetBlock(Methods.getTransparentEarthbending(), (int) range).getLocation();
if (targetdestination.distance(location) <= 1) {
progressing = false;
@ -196,10 +187,8 @@ public class WaterWall {
progressing = true;
settingup = true;
firstdestination = getToEyeLevel();
firstdirection = getDirection(sourceblock.getLocation(),
firstdestination);
targetdirection = getDirection(firstdestination,
targetdestination);
firstdirection = getDirection(sourceblock.getLocation(), firstdestination);
targetdirection = getDirection(firstdestination, targetdestination);
if (Methods.isPlant(sourceblock))
new Plantbending(sourceblock);
if (!Methods.isAdjacentToThreeOrMoreSources(sourceblock)) {
@ -272,34 +261,30 @@ public class WaterWall {
}
if (!progressing) {
sourceblock.getWorld().playEffect(location, Effect.SMOKE, 4,
(int) range);
sourceblock.getWorld().playEffect(location, Effect.SMOKE, 4, (int) range);
return false;
}
if (forming) {
ArrayList<Block> blocks = new ArrayList<Block>();
Location loc = Methods.getTargetedLocation(player, (int) range,
8, 9, 79);
Location loc = Methods.getTargetedLocation(player, (int) range, 8, 9, 79);
location = loc.clone();
Vector dir = player.getEyeLocation().getDirection();
Vector vec;
Block block;
for (double i = 0; i <= Methods.waterbendingNightAugment(radius,
player.getWorld()); i += 0.5) {
for (double i = 0; i <= Methods.waterbendingNightAugment(radius, player.getWorld()); i += 0.5) {
for (double angle = 0; angle < 360; angle += 10) {
// loc.getBlock().setType(Material.GLOWSTONE);
vec = Methods.getOrthogonalVector(dir.clone(), angle, i);
block = loc.clone().add(vec).getBlock();
if (Methods.isRegionProtectedFromBuild(player,
"Surge", block.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "Surge", block.getLocation()))
continue;
if (wallblocks.containsKey(block)) {
blocks.add(block);
} else if (!blocks.contains(block)
&& (block.getType() == Material.AIR
|| block.getType() == Material.FIRE || Methods
.isWaterbendable(block, player))) {
|| block.getType() == Material.FIRE
|| Methods.isWaterbendable(block, player))) {
wallblocks.put(block, player);
addWallBlock(block);
// if (frozen) {
@ -310,16 +295,14 @@ public class WaterWall {
// }
// block.setType(Material.GLASS);
blocks.add(block);
FireBlast.removeFireBlastsAroundPoint(
block.getLocation(), 2);
FireBlast.removeFireBlastsAroundPoint(block.getLocation(), 2);
// Methods.verbose(wallblocks.size());
}
}
}
for (Block blocki : wallblocks.keySet()) {
if (wallblocks.get(blocki) == player
&& !blocks.contains(blocki)) {
if (wallblocks.get(blocki) == player && !blocks.contains(blocki)) {
finalRemoveWater(blocki);
}
}
@ -327,8 +310,7 @@ public class WaterWall {
return true;
}
if (sourceblock.getLocation().distance(firstdestination) < .5
&& settingup) {
if (sourceblock.getLocation().distance(firstdestination) < .5 && settingup) {
settingup = false;
}
@ -440,8 +422,7 @@ public class WaterWall {
private void addWater(Block block) {
if (Methods.isRegionProtectedFromBuild(player, "Surge",
block.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "Surge", block.getLocation()))
return;
if (!TempBlock.isTempBlock(block)) {
@ -465,9 +446,8 @@ public class WaterWall {
if (!instances.containsKey(player.getEntityId())) {
if (!Wave.instances.containsKey(player.getEntityId())
&& Methods.getWaterSourceBlock(player,
(int) Wave.defaultrange, Methods.canPlantbend(player)) == null
&& WaterReturn.hasWaterBottle(player)) {
&& Methods.getWaterSourceBlock(player, (int) Wave.defaultrange, Methods.canPlantbend(player)) == null
&& WaterReturn.hasWaterBottle(player)) {
if (Wave.cooldowns.containsKey(player.getName())) {
if (Wave.cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
@ -478,11 +458,9 @@ public class WaterWall {
}
Location eyeloc = player.getEyeLocation();
Block block = eyeloc.add(eyeloc.getDirection().normalize())
.getBlock();
Block block = eyeloc.add(eyeloc.getDirection().normalize()).getBlock();
if (Methods.isTransparentToEarthbending(player, block)
&& Methods.isTransparentToEarthbending(player,
eyeloc.getBlock())) {
&& Methods.isTransparentToEarthbending(player, eyeloc.getBlock())) {
block.setType(Material.WATER);
block.setData(full);
WaterWall wall = new WaterWall(player);
@ -500,9 +478,7 @@ public class WaterWall {
new Wave(player);
return;
} else {
if (Methods.isWaterbendable(
player.getTargetBlock(null, (int) Wave.defaultrange),
player)) {
if (Methods.isWaterbendable(player.getTargetBlock(null, (int) Wave.defaultrange), player)) {
new Wave(player);
return;
}

View file

@ -21,21 +21,17 @@ import com.projectkorra.ProjectKorra.firebending.FireBlast;
public class Wave {
public static ConcurrentHashMap<Integer, Wave> instances = new ConcurrentHashMap<Integer, Wave>();
private static final long interval = 30;
// public static ConcurrentHashMap<Block, Block> affectedblocks = new
// ConcurrentHashMap<Block, Block>();
private static final byte full = 0x0;
// private static final byte half = 0x4;
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static final double defaultmaxradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wave.Radius");
private static final double defaultfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wave.HorizontalPush");
private static final double upfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wave.VerticalPush");
private static final double maxfreezeradius = 7;
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
private static final long interval = 30;
// public static ConcurrentHashMap<Block, Block> affectedblocks = new ConcurrentHashMap<Block, Block>();
private static final byte full = 0x0;
// private static final byte half = 0x4;
static double defaultrange = 20;
// private static int damage = 5;
// private static double speed = 1.5;
@ -43,27 +39,26 @@ public class Wave {
Player player;
private Location location = null;
private Block sourceblock = null;
boolean progressing = false;
private Location targetdestination = null;
private Vector targetdirection = null;
private ConcurrentHashMap<Block, Block> wave = new ConcurrentHashMap<Block, Block>();
private ConcurrentHashMap<Block, Block> frozenblocks = new ConcurrentHashMap<Block, Block>();
private double radius = 1;
private long time;
private double radius = 1;
private double maxradius = defaultmaxradius;
private double factor = defaultfactor;
private boolean freeze = false;
private boolean activatefreeze = false;
private Location frozenlocation;
double range = defaultrange;
private double factor = defaultfactor;
boolean progressing = false;
boolean canhitself = true;
public Wave(Player player) {
this.player = player;
if (instances.containsKey(player.getEntityId())) {
if (instances.get(player.getEntityId()).progressing
&& !instances.get(player.getEntityId()).freeze) {
if (instances.get(player.getEntityId()).progressing && !instances.get(player.getEntityId()).freeze) {
instances.get(player.getEntityId()).freeze = true;
return;
}
@ -72,8 +67,7 @@ public class Wave {
if (AvatarState.isAvatarState(player)) {
maxradius = AvatarState.getValue(maxradius);
}
maxradius = Methods
.waterbendingNightAugment(maxradius, player.getWorld());
maxradius = Methods.waterbendingNightAugment(maxradius, player.getWorld());
if (prepare()) {
if (instances.containsKey(player.getEntityId())) {
instances.get(player.getEntityId()).cancel();
@ -87,8 +81,7 @@ public class Wave {
public boolean prepare() {
cancelPrevious();
// Block block = player.getTargetBlock(null, (int) range);
Block block = Methods.getWaterSourceBlock(player, range,
Methods.canPlantbend(player));
Block block = Methods.getWaterSourceBlock(player, range, Methods.canPlantbend(player));
if (block != null) {
sourceblock = block;
focusBlock();
@ -141,9 +134,7 @@ public class Wave {
factor = AvatarState.getValue(factor);
Entity target = Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
if (target == null) {
targetdestination = player.getTargetBlock(
Methods.getTransparentEarthbending(), (int) range)
.getLocation();
targetdestination = player.getTargetBlock(Methods.getTransparentEarthbending(), (int) range).getLocation();
} else {
targetdestination = ((LivingEntity) target).getEyeLocation();
}
@ -152,10 +143,8 @@ public class Wave {
targetdestination = null;
} else {
progressing = true;
targetdirection = getDirection(sourceblock.getLocation(),
targetdestination).normalize();
targetdestination = location.clone().add(
targetdirection.clone().multiply(range));
targetdirection = getDirection(sourceblock.getLocation(), targetdestination).normalize();
targetdestination = location.clone().add(targetdirection.clone().multiply(range));
if (Methods.isPlant(sourceblock))
new Plantbending(sourceblock);
if (!Methods.isAdjacentToThreeOrMoreSources(sourceblock)) {
@ -185,8 +174,7 @@ public class Wave {
}
public boolean progress() {
if (player.isDead() || !player.isOnline()
|| !Methods.canBend(player.getName(), "Surge")) {
if (player.isDead() || !player.isOnline() || !Methods.canBend(player.getName(), "Surge")) {
breakBlock();
thaw();
// instances.remove(player.getEntityId());
@ -206,8 +194,7 @@ public class Wave {
}
if (!progressing) {
sourceblock.getWorld().playEffect(location, Effect.SMOKE, 4,
(int) range);
sourceblock.getWorld().playEffect(location, Effect.SMOKE, 4, (int) range);
return false;
}
@ -251,22 +238,18 @@ public class Wave {
if (!Methods.isRegionProtectedFromBuild(player, "Surge", location) && (((blockl.getType() == Material.AIR
|| blockl.getType() == Material.FIRE
|| Methods.isPlant(blockl)
|| Methods.isWater(blockl) || Methods
.isWaterbendable(blockl, player))) && blockl
.getType() != Material.LEAVES)) {
|| Methods.isWater(blockl)
|| Methods.isWaterbendable(blockl, player))) && blockl.getType() != Material.LEAVES)) {
for (double i = 0; i <= radius; i += .5) {
for (double angle = 0; angle < 360; angle += 10) {
Vector vec = Methods.getOrthogonalVector(
targetdirection, angle, i);
Vector vec = Methods.getOrthogonalVector(targetdirection, angle, i);
Block block = location.clone().add(vec).getBlock();
if (!blocks.contains(block)
&& (block.getType() == Material.AIR || block
.getType() == Material.FIRE)
if (!blocks.contains(block) && (block.getType() == Material.AIR
|| block.getType() == Material.FIRE)
|| Methods.isWaterbendable(block, player)) {
blocks.add(block);
FireBlast.removeFireBlastsAroundPoint(
block.getLocation(), 2);
FireBlast.removeFireBlastsAroundPoint(block.getLocation(), 2);
}
// if (!blocks.contains(block)
// && (Methods.isPlant(block) && block.getType() !=
@ -295,39 +278,31 @@ public class Wave {
return false;
}
for (Entity entity : Methods.getEntitiesAroundPoint(location,
2 * radius)) {
for (Entity entity : Methods.getEntitiesAroundPoint(location, 2 * radius)) {
boolean knockback = false;
for (Block block : wave.keySet()) {
if (entity.getLocation().distance(block.getLocation()) <= 2) {
if (entity instanceof LivingEntity
&& freeze
&& entity.getEntityId() != player
.getEntityId()) {
&& entity.getEntityId() != player.getEntityId()) {
activatefreeze = true;
frozenlocation = entity.getLocation();
freeze();
break;
}
if (entity.getEntityId() != player.getEntityId()
|| canhitself)
if (entity.getEntityId() != player.getEntityId() || canhitself)
knockback = true;
}
}
if (knockback) {
Vector dir = direction.clone();
dir.setY(dir.getY() * upfactor);
entity.setVelocity(entity
.getVelocity()
.clone()
.add(dir.clone().multiply(
Methods.waterbendingNightAugment(factor,
player.getWorld()))));
entity.setVelocity(entity.getVelocity().clone()
.add(dir.clone().multiply(Methods.waterbendingNightAugment(factor, player.getWorld()))));
entity.setFallDistance(0);
if (entity.getFireTicks() > 0)
entity.getWorld().playEffect(entity.getLocation(),
Effect.EXTINGUISH, 0);
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
entity.setFireTicks(0);
}
@ -376,8 +351,7 @@ public class Wave {
}
private void addWater(Block block) {
if (Methods.isRegionProtectedFromBuild(player, "Surge",
block.getLocation()))
if (Methods.isRegionProtectedFromBuild(player, "Surge", block.getLocation()))
return;
if (!TempBlock.isTempBlock(block)) {
new TempBlock(block, Material.STATIONARY_WATER, (byte) 8);
@ -439,12 +413,9 @@ public class Wave {
freezeradius = maxfreezeradius;
}
for (Block block : Methods.getBlocksAroundPoint(frozenlocation,
freezeradius)) {
if (Methods.isRegionProtectedFromBuild(player, "Surge",
block.getLocation())
|| Methods.isRegionProtectedFromBuild(player,
"PhaseChange", block.getLocation()))
for (Block block : Methods.getBlocksAroundPoint(frozenlocation, freezeradius)) {
if (Methods.isRegionProtectedFromBuild(player, "Surge", block.getLocation())
|| Methods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation()))
continue;
if (TempBlock.isTempBlock(block))
continue;