This commit is contained in:
Simp 2019-01-02 21:34:00 -05:00
parent a543e13acf
commit 89de7a3a36
9 changed files with 163 additions and 196 deletions

View file

@ -1145,7 +1145,7 @@ public class GeneralMethods {
} }
public static Location getTargetedLocation(final Player player, final double range, final Material... nonOpaque2) { public static Location getTargetedLocation(final Player player, final double range, final Material... nonOpaque2) {
return getTargetedLocation(player, range, true, nonOpaque2); return getTargetedLocation(player, range, false, nonOpaque2);
} }
public static Location getTargetedLocation(final Player player, final int range) { public static Location getTargetedLocation(final Player player, final int range) {

View file

@ -1357,7 +1357,7 @@ public class PKListener implements Listener {
} else if (abil.equalsIgnoreCase("AirBurst")) { } else if (abil.equalsIgnoreCase("AirBurst")) {
new AirBurst(player, false); new AirBurst(player, false);
} else if (abil.equalsIgnoreCase("AirSuction")) { } else if (abil.equalsIgnoreCase("AirSuction")) {
AirSuction.setOrigin(player); new AirSuction(player);
} else if (abil.equalsIgnoreCase("AirSwipe")) { } else if (abil.equalsIgnoreCase("AirSwipe")) {
new AirSwipe(player, true); new AirSwipe(player, true);
} else if (abil.equalsIgnoreCase("AirShield")) { } else if (abil.equalsIgnoreCase("AirShield")) {
@ -1561,7 +1561,7 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("AirBlast")) { if (abil.equalsIgnoreCase("AirBlast")) {
new AirBlast(player); new AirBlast(player);
} else if (abil.equalsIgnoreCase("AirSuction")) { } else if (abil.equalsIgnoreCase("AirSuction")) {
new AirSuction(player); AirSuction.shoot(player);
} else if (abil.equalsIgnoreCase("AirBurst")) { } else if (abil.equalsIgnoreCase("AirBurst")) {
AirBurst.coneBurst(player); AirBurst.coneBurst(player);
} else if (abil.equalsIgnoreCase("AirScooter")) { } else if (abil.equalsIgnoreCase("AirScooter")) {

View file

@ -229,7 +229,7 @@ public abstract class ElementalAbility extends CoreAbility {
} }
public static boolean isWater(final Material material) { public static boolean isWater(final Material material) {
return material == Material.WATER || material == Material.SEAGRASS || material == Material.TALL_SEAGRASS || material == Material.KELP_PLANT || material == Material.KELP; return material == Material.WATER || material == Material.SEAGRASS || material == Material.TALL_SEAGRASS || material == Material.KELP_PLANT || material == Material.KELP || material == Material.BUBBLE_COLUMN;
} }
} }

View file

@ -1,14 +1,10 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import com.projectkorra.projectkorra.BendingPlayer; import java.util.ArrayList;
import com.projectkorra.projectkorra.GeneralMethods; import java.util.Arrays;
import com.projectkorra.projectkorra.ProjectKorra; import java.util.List;
import com.projectkorra.projectkorra.ability.AirAbility; import java.util.Random;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -20,17 +16,21 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.*; import com.projectkorra.projectkorra.GeneralMethods;
import java.util.concurrent.ConcurrentHashMap; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
public class AirSuction extends AirAbility { public class AirSuction extends AirAbility {
private static final int MAX_TICKS = 10000;
private static final Map<Player, Location> ORIGINS = new ConcurrentHashMap<>();
private final List<Block> affectedDoors = new ArrayList<>(); private final List<Block> affectedDoors = new ArrayList<>();
private boolean hasOtherOrigin; private boolean progressing;
private int ticks;
private int particleCount; private int particleCount;
@Attribute(Attribute.COOLDOWN) @Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@ -58,8 +58,19 @@ public class AirSuction extends AirAbility {
return; return;
} }
this.hasOtherOrigin = false; if (hasAbility(player, AirSuction.class)) {
this.ticks = 0; AirSuction suc = getAbility(player, AirSuction.class);
if (!suc.isProgressing()) {
Location loc = getTargetLocation();
if (!GeneralMethods.isRegionProtectedFromBuild(player, this.getName(), loc)) {
suc.setOrigin(loc);
}
}
return;
}
this.progressing = false;
this.particleCount = getConfig().getInt("Abilities.Air.AirSuction.Particles"); this.particleCount = getConfig().getInt("Abilities.Air.AirSuction.Particles");
this.speed = getConfig().getDouble("Abilities.Air.AirSuction.Speed"); this.speed = getConfig().getDouble("Abilities.Air.AirSuction.Speed");
this.range = getConfig().getDouble("Abilities.Air.AirSuction.Range"); this.range = getConfig().getDouble("Abilities.Air.AirSuction.Range");
@ -67,81 +78,21 @@ public class AirSuction extends AirAbility {
this.pushFactor = getConfig().getDouble("Abilities.Air.AirSuction.Push"); this.pushFactor = getConfig().getDouble("Abilities.Air.AirSuction.Push");
this.cooldown = getConfig().getLong("Abilities.Air.AirSuction.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Air.AirSuction.Cooldown");
this.random = new Random(); this.random = new Random();
this.origin = getTargetLocation();
if (ORIGINS.containsKey(player)) { if (GeneralMethods.isRegionProtectedFromBuild(player, this.getName(), origin)) {
this.origin = ORIGINS.get(player); return;
this.hasOtherOrigin = true;
ORIGINS.remove(player);
} else {
this.origin = player.getEyeLocation();
} }
this.location = GeneralMethods.getTargetedLocation(player, this.range, getTransparentMaterials()); this.location = null;
this.direction = GeneralMethods.getDirection(this.location, this.origin).normalize();
final Entity entity = GeneralMethods.getTargetedEntity(player, this.range);
if (entity != null) {
this.direction = GeneralMethods.getDirection(entity.getLocation(), this.origin).normalize();
this.location = this.getLocation(this.origin, this.direction.clone().multiply(-1));
}
this.bPlayer.addCooldown(this);
if (this.bPlayer.isAvatarState()) { if (this.bPlayer.isAvatarState()) {
this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSuction.Push"); this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSuction.Push");
} }
this.start(); this.start();
} }
private static void playOriginEffect(final Player player) {
if (!ORIGINS.containsKey(player)) {
return;
}
final Location origin = ORIGINS.get(player);
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null || player.isDead() || !player.isOnline()) {
return;
} else if (!origin.getWorld().equals(player.getWorld())) {
ORIGINS.remove(player);
return;
} else if (!bPlayer.canBendIgnoreCooldowns(getAbility("AirSuction"))) {
ORIGINS.remove(player);
return;
} else if (origin.distanceSquared(player.getEyeLocation()) > getSelectRange() * getSelectRange()) {
ORIGINS.remove(player);
return;
}
playAirbendingParticles(origin, getSelectParticles());
}
public static void progressOrigins() {
for (final Player player : ORIGINS.keySet()) {
playOriginEffect(player);
}
}
public static void setOrigin(final Player player) {
final Material[] ignore = new Material[getTransparentMaterials().length + AirBlast.DOORS.length + AirBlast.TDOORS.length];
for (int i = 0; i < ignore.length; i++) {
if (i < getTransparentMaterials().length) {
ignore[i] = getTransparentMaterials()[i];
} else if (i < getTransparentMaterials().length + AirBlast.DOORS.length){
ignore[i] = AirBlast.DOORS[i - getTransparentMaterials().length];
} else {
ignore[i] = AirBlast.TDOORS[i - getTransparentMaterials().length - AirBlast.DOORS.length];
}
}
final Location location = GeneralMethods.getTargetedLocation(player, getSelectRange(), false, ignore);
if (location.getBlock().isLiquid() || GeneralMethods.isSolid(location.getBlock())) {
return;
} else if (GeneralMethods.isRegionProtectedFromBuild(player, "AirSuction", location)) {
return;
} else {
ORIGINS.put(player, location);
}
}
private void advanceLocation() { private void advanceLocation() {
playAirbendingParticles(this.location, this.particleCount, 0.275F, 0.275F, 0.275F); playAirbendingParticles(this.location, this.particleCount, 0.275F, 0.275F, 0.275F);
if (this.random.nextInt(4) == 0) { if (this.random.nextInt(4) == 0) {
@ -209,15 +160,20 @@ public class AirSuction extends AirAbility {
this.affectedDoors.add(block); this.affectedDoors.add(block);
} }
private Location getLocation(final Location origin, final Vector direction) { private Location getTargetLocation() {
Location location = origin.clone(); final Material[] ignore = new Material[getTransparentMaterials().length + AirBlast.DOORS.length + AirBlast.TDOORS.length];
for (double i = 1; i <= this.range; i++) {
location = origin.clone().add(direction.clone().multiply(i)); for (int i = 0; i < ignore.length; i++) {
if ((!this.isTransparent(location.getBlock()) && !(Arrays.asList(AirBlast.DOORS).contains(location.getBlock().getType()) && Arrays.asList(AirBlast.TDOORS).contains(location.getBlock().getType()))) || GeneralMethods.isRegionProtectedFromBuild(this, location)) { if (i < getTransparentMaterials().length) {
return origin.clone().add(direction.clone().multiply(i - 1)); ignore[i] = getTransparentMaterials()[i];
} else if (i < getTransparentMaterials().length + AirBlast.DOORS.length){
ignore[i] = AirBlast.DOORS[i - getTransparentMaterials().length];
} else {
ignore[i] = AirBlast.TDOORS[i - getTransparentMaterials().length - AirBlast.DOORS.length];
} }
} }
return location;
return GeneralMethods.getTargetedLocation(player, getSelectRange(), ignore);
} }
@Override @Override
@ -225,75 +181,110 @@ public class AirSuction extends AirAbility {
if (this.player.isDead() || !this.player.isOnline()) { if (this.player.isDead() || !this.player.isOnline()) {
this.remove(); this.remove();
return; return;
} else if (GeneralMethods.isRegionProtectedFromBuild(this.player, "AirSuction", this.location)) {
this.remove();
return;
} }
this.ticks++; if (this.progressing) {
if (this.ticks > MAX_TICKS) { if (GeneralMethods.isRegionProtectedFromBuild(this.player, "AirSuction", this.location)) {
this.remove(); this.remove();
return; return;
} else if ((this.location.distanceSquared(this.origin) > this.range * this.range) || (this.location.distanceSquared(this.origin) <= 1)) { } else if (this.location.distanceSquared(this.origin) > this.range * this.range || this.location.distanceSquared(this.origin) <= 1) {
this.remove(); this.remove();
return; return;
}
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.radius)) {
if (entity.getEntityId() != this.player.getEntityId() || this.hasOtherOrigin) {
if (entity instanceof Player) {
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || Commands.invincible.contains(((Player) entity).getName())){
continue;
}
}
final Vector velocity = entity.getVelocity();
final double max = this.speed;
double factor = this.pushFactor;
final Vector push = this.direction.clone();
if (Math.abs(push.getY()) > max && entity.getEntityId() != this.player.getEntityId()) {
if (push.getY() < 0) {
push.setY(-max);
} else {
push.setY(max);
}
}
if (this.location.getWorld().equals(this.origin.getWorld())) {
factor *= 1 - this.location.distance(this.origin) / (2 * this.range);
}
final 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())));
} else if (comp + factor * .5 > factor) {
velocity.add(push.clone().multiply(factor - comp));
} else {
velocity.add(push.clone().multiply(factor * .5));
}
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) {
continue;
}
}
GeneralMethods.setVelocity(entity, velocity);
new HorizontalVelocityTracker(entity, this.player, 200l, this);
entity.setFallDistance(0);
if (entity.getEntityId() != this.player.getEntityId() && entity instanceof Player) {
flightHandler.createInstance((Player) entity, this.player, 5000L, this.getName());
}
if (entity.getFireTicks() > 0) {
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
}
entity.setFireTicks(0);
breakBreathbendingHold(entity);
} }
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.radius)) {
if (entity.getEntityId() != this.player.getEntityId()) {
if (entity instanceof Player) {
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || Commands.invincible.contains(((Player) entity).getName())){
continue;
}
}
final Vector velocity = entity.getVelocity();
final double max = this.speed;
final Vector push = this.direction.clone();
double factor = this.pushFactor;
if (Math.abs(push.getY()) > max && entity.getEntityId() != this.player.getEntityId()) {
if (push.getY() < 0) {
push.setY(-max);
} else {
push.setY(max);
}
}
if (this.location.getWorld().equals(this.origin.getWorld())) {
factor *= 1 - this.location.distance(this.origin) / (2 * this.range);
}
final 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())));
} else if (comp + factor * .5 > factor) {
velocity.add(push.clone().multiply(factor - comp));
} else {
velocity.add(push.clone().multiply(factor * .5));
}
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) {
continue;
}
}
GeneralMethods.setVelocity(entity, velocity);
new HorizontalVelocityTracker(entity, this.player, 200l, this);
entity.setFallDistance(0);
if (entity.getEntityId() != this.player.getEntityId() && entity instanceof Player) {
flightHandler.createInstance((Player) entity, this.player, 5000L, this.getName());
}
if (entity.getFireTicks() > 0) {
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
}
entity.setFireTicks(0);
breakBreathbendingHold(entity);
}
}
this.advanceLocation();
} else {
playAirbendingParticles(origin, 5, 0.5, 0.5, 0.5);
}
}
public void shoot() {
Location target;
Entity entity = GeneralMethods.getTargetedEntity(player, this.range);
if (entity != null) {
target = entity.getLocation();
} else {
target = getTargetLocation();
} }
this.advanceLocation(); this.location = target.clone();
this.direction = GeneralMethods.getDirection(this.location, this.origin).normalize();
this.progressing = true;
this.bPlayer.addCooldown(this);
}
public static void shoot(Player player) {
AirSuction suc = null;
if (CoreAbility.hasAbility(player, AirSuction.class)) {
suc = CoreAbility.getAbility(player, AirSuction.class);
if (suc.isProgressing()) {
return;
}
} else {
suc = new AirSuction(player);
suc.setOrigin(player.getEyeLocation().clone());
}
if (suc.getOrigin() != null) {
suc.shoot();
}
} }
/** /**
@ -345,6 +336,10 @@ public class AirSuction extends AirAbility {
return this.getRadius(); return this.getRadius();
} }
public boolean isProgressing() {
return progressing;
}
public Location getOrigin() { public Location getOrigin() {
return this.origin; return this.origin;
} }
@ -361,22 +356,6 @@ public class AirSuction extends AirAbility {
this.direction = direction; this.direction = direction;
} }
public boolean isHasOtherOrigin() {
return this.hasOtherOrigin;
}
public void setHasOtherOrigin(final boolean hasOtherOrigin) {
this.hasOtherOrigin = hasOtherOrigin;
}
public int getTicks() {
return this.ticks;
}
public void setTicks(final int ticks) {
this.ticks = ticks;
}
public int getParticleCount() { public int getParticleCount() {
return this.particleCount; return this.particleCount;
} }
@ -425,10 +404,6 @@ public class AirSuction extends AirAbility {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
public static Map<Player, Location> getOrigins() {
return ORIGINS;
}
public static int getSelectParticles() { public static int getSelectParticles() {
return getConfig().getInt("Abilities.Air.AirSuction.SelectParticles"); return getConfig().getInt("Abilities.Air.AirSuction.SelectParticles");
} }

View file

@ -2,7 +2,6 @@ package com.projectkorra.projectkorra.airbending.util;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.airbending.AirBlast; import com.projectkorra.projectkorra.airbending.AirBlast;
import com.projectkorra.projectkorra.airbending.AirSuction;
public class AirbendingManager implements Runnable { public class AirbendingManager implements Runnable {
@ -15,7 +14,6 @@ public class AirbendingManager implements Runnable {
@Override @Override
public void run() { public void run() {
AirBlast.progressOrigins(); AirBlast.progressOrigins();
AirSuction.progressOrigins();
} }
} }

View file

@ -145,7 +145,7 @@ public class EarthBlast extends EarthAbility {
} }
if (target == null) { if (target == null) {
location = GeneralMethods.getTargetedLocation(this.player, this.range, trans); location = GeneralMethods.getTargetedLocation(this.player, this.range, true, trans);
} else { } else {
location = ((LivingEntity) target).getEyeLocation(); location = ((LivingEntity) target).getEyeLocation();
} }
@ -455,7 +455,6 @@ public class EarthBlast extends EarthAbility {
if (mloc.distanceSquared(location) <= blast.range * blast.range && GeneralMethods.getDistanceFromLine(vector, location, blast.location) < blast.deflectRange && mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) { if (mloc.distanceSquared(location) <= blast.range * blast.range && GeneralMethods.getDistanceFromLine(vector, location, blast.location) < blast.deflectRange && mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
blast.redirect(player, blast.getTargetLocation()); blast.redirect(player, blast.getTargetLocation());
} }
} }
} }

View file

@ -535,7 +535,7 @@ public class EarthSmash extends EarthAbility {
return null; return null;
} }
final List<Block> blocks = GeneralMethods.getBlocksAroundPoint(GeneralMethods.getTargetedLocation(player, this.grabRange, false, getTransparentMaterials()), 1); final List<Block> blocks = GeneralMethods.getBlocksAroundPoint(GeneralMethods.getTargetedLocation(player, this.grabRange, getTransparentMaterials()), 1);
for (final EarthSmash smash : getAbilities(EarthSmash.class)) { for (final EarthSmash smash : getAbilities(EarthSmash.class)) {
if (reqState == null || smash.state == reqState) { if (reqState == null || smash.state == reqState) {
for (final Block block : blocks) { for (final Block block : blocks) {

View file

@ -28,7 +28,6 @@ import com.projectkorra.projectkorra.ability.FireAbility;
import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.earthbending.lava.LavaFlow; import com.projectkorra.projectkorra.earthbending.lava.LavaFlow;
import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ReflectionHandler.PackageType;
import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.SurgeWave; import com.projectkorra.projectkorra.waterbending.SurgeWave;
import com.projectkorra.projectkorra.waterbending.Torrent; import com.projectkorra.projectkorra.waterbending.Torrent;
@ -221,7 +220,7 @@ public class HeatControl extends FireAbility {
final Location targetLocation = GeneralMethods.getTargetedLocation(this.player, this.solidifyRange); final Location targetLocation = GeneralMethods.getTargetedLocation(this.player, this.solidifyRange);
this.resetLocation(targetLocation); this.resetLocation(targetLocation);
final List<Location> area = GeneralMethods.getCircle(this.solidifyLocation, this.solidifyRadius, 3, true, true, 0); final List<Location> area = GeneralMethods.getCircle(this.solidifyLocation, this.solidifyRadius, 3, false, true, 0);
this.solidify(area); this.solidify(area);
} }
@ -363,11 +362,7 @@ public class HeatControl extends FireAbility {
final Block b = lava.get(this.randy.nextInt(lava.size())); final Block b = lava.get(this.randy.nextInt(lava.size()));
Material tempRevertMaterial = Material.STONE; Material tempRevertMaterial = Material.MAGMA_BLOCK;
if (Integer.parseInt(PackageType.getServerVersion().split("_")[1]) > 9) {
tempRevertMaterial = Material.valueOf("MAGMA");
}
final TempBlock tempBlock; final TempBlock tempBlock;
if (TempBlock.isTempBlock(b)) { if (TempBlock.isTempBlock(b)) {

View file

@ -255,7 +255,7 @@ public class IceSpikeBlast extends IceAbility {
final LivingEntity target = (LivingEntity) GeneralMethods.getTargetedEntity(this.player, this.range); final LivingEntity target = (LivingEntity) GeneralMethods.getTargetedEntity(this.player, this.range);
if (target == null) { if (target == null) {
this.destination = GeneralMethods.getTargetedLocation(this.player, this.range, getTransparentMaterials()); this.destination = GeneralMethods.getTargetedLocation(this.player, this.range, true, getTransparentMaterials());
} else { } else {
this.destination = target.getEyeLocation(); this.destination = target.getEyeLocation();
} }
@ -376,7 +376,7 @@ public class IceSpikeBlast extends IceAbility {
Location loc; Location loc;
final Entity target = GeneralMethods.getTargetedEntity(player, iceSpike.range); final Entity target = GeneralMethods.getTargetedEntity(player, iceSpike.range);
if (target == null) { if (target == null) {
loc = GeneralMethods.getTargetedLocation(player, iceSpike.range); loc = GeneralMethods.getTargetedLocation(player, iceSpike.range, true);
} else { } else {
loc = ((LivingEntity) target).getEyeLocation(); loc = ((LivingEntity) target).getEyeLocation();
} }