From 563775016686ce21897c5570182a0d8d8ebe629b Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 22 Aug 2019 17:04:04 -0400 Subject: [PATCH 01/11] Change AirSweep and FireJet + Lightning (#1007) ## Additions * Adds HorizontalVelocityTracker to AirSweep * Adds GeneralMethods#getMainHandLocation(final Player player) ## Changes * Changed AirSweep and AirSwipe to originate from a Player's main hand location * Changed the knockback caused by AirSweep more consistent in the air and on the ground * Disable Lightning use when using FireJet --- .../projectkorra/GeneralMethods.java | 11 +++++++ .../projectkorra/airbending/AirSwipe.java | 2 +- .../airbending/combo/AirSweep.java | 30 ++++++++++--------- .../firebending/lightning/Lightning.java | 5 ++++ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 7c86931c..1c7c24d8 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -81,6 +81,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.MainHand; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -1107,6 +1108,16 @@ public class GeneralMethods { return location.clone().subtract(new Vector(Math.cos(angle), 0, Math.sin(angle)).normalize().multiply(distance)); } + public static Location getMainHandLocation(final Player player) { + Location loc; + if (player.getMainHand() == MainHand.LEFT) { + loc = GeneralMethods.getLeftSide(player.getLocation(), .55).add(0, 1.2, 0); + } else { + loc = GeneralMethods.getRightSide(player.getLocation(), .55).add(0, 1.2, 0); + } + return loc; + } + public static Plugin getProbending() { if (hasProbending()) { return Bukkit.getServer().getPluginManager().getPlugin("Probending"); diff --git a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java index bc10f48a..999bfa45 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java @@ -77,7 +77,7 @@ public class AirSwipe extends AirAbility { } this.charging = charging; - this.origin = player.getEyeLocation(); + this.origin = GeneralMethods.getMainHandLocation(player); this.particles = getConfig().getInt("Abilities.Air.AirSwipe.Particles"); this.arc = getConfig().getInt("Abilities.Air.AirSwipe.Arc"); this.arcIncrement = getConfig().getInt("Abilities.Air.AirSwipe.StepSize"); diff --git a/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java b/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java index 2c2cc797..5bbfd83d 100644 --- a/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java +++ b/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java @@ -3,6 +3,7 @@ package com.projectkorra.projectkorra.airbending.combo; import java.util.ArrayList; import java.util.List; +import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -131,22 +132,23 @@ public class AirSweep extends AirAbility implements ComboAbility { if (this.origin == null) { this.direction = this.player.getEyeLocation().getDirection().normalize(); - this.origin = this.player.getLocation().add(this.direction.clone().multiply(10)); + this.origin = GeneralMethods.getMainHandLocation(player).add(this.direction.clone().multiply(10)); } if (this.progressCounter < 8) { return; } if (this.destination == null) { - this.destination = this.player.getLocation().add(this.player.getEyeLocation().getDirection().normalize().multiply(10)); + this.destination = GeneralMethods.getMainHandLocation(player).add(GeneralMethods.getMainHandLocation(player).getDirection().normalize().multiply(10)); final Vector origToDest = GeneralMethods.getDirection(this.origin, this.destination); + final Location hand = GeneralMethods.getMainHandLocation(player); for (double i = 0; i < 30; i++) { final Location endLoc = this.origin.clone().add(origToDest.clone().multiply(i / 30)); - if (GeneralMethods.locationEqualsIgnoreDirection(this.player.getLocation(), endLoc)) { + if (GeneralMethods.locationEqualsIgnoreDirection(hand, endLoc)) { continue; } - final Vector vec = GeneralMethods.getDirection(this.player.getLocation(), endLoc); + final Vector vec = GeneralMethods.getDirection(hand, endLoc); - final FireComboStream fs = new FireComboStream(this.player, this, vec, this.player.getLocation(), this.range, this.speed); + final FireComboStream fs = new FireComboStream(this.player, this, vec, hand, this.range, this.speed); fs.setDensity(1); fs.setSpread(0F); fs.setUseNewParticles(true); @@ -191,17 +193,17 @@ public class AirSweep extends AirAbility implements ComboAbility { this.remove(); return; } - if (!entity.equals(this.player) && !this.affectedEntities.contains(entity) && !(entity instanceof Player && Commands.invincible.contains(((Player) entity).getName()))) { - this.affectedEntities.add(entity); + if (!entity.equals(this.player) && !(entity instanceof Player && Commands.invincible.contains(((Player) entity).getName()))) { if (this.knockback != 0) { - final Vector force = fstream.getDirection(); - entity.setVelocity(force.multiply(this.knockback)); + final Vector force = fstream.getLocation().getDirection(); + GeneralMethods.setVelocity(entity, force.clone().multiply(this.knockback)); + new HorizontalVelocityTracker(entity, this.player, 200l, this); + entity.setFallDistance(0); } - if (this.damage != 0) { - if (entity instanceof LivingEntity) { - if (fstream.getAbility().getName().equalsIgnoreCase("AirSweep")) { - DamageHandler.damageEntity(entity, this.damage, this); - } else { + if(!this.affectedEntities.contains(entity)) { + this.affectedEntities.add(entity); + if (this.damage != 0) { + if (entity instanceof LivingEntity) { DamageHandler.damageEntity(entity, this.damage, this); } } diff --git a/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java b/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java index ed0c15d7..93393abc 100644 --- a/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java +++ b/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java @@ -3,6 +3,8 @@ package com.projectkorra.projectkorra.firebending.lightning; import java.util.ArrayList; import java.util.List; +import com.projectkorra.projectkorra.ability.CoreAbility; +import com.projectkorra.projectkorra.firebending.FireJet; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -180,6 +182,9 @@ public class Lightning extends LightningAbility { } else if (!this.bPlayer.canBendIgnoreCooldowns(this)) { this.remove(); return; + } else if (CoreAbility.hasAbility(player, FireJet.class)){ + this.removeWithTasks(); + return; } this.locations.clear(); From 3972104586793a384e87e4bad823a53280800458 Mon Sep 17 00:00:00 2001 From: Benford Whitaker Date: Thu, 22 Aug 2019 17:45:23 -0400 Subject: [PATCH 02/11] Fix config issues in AirBlast, AirSuction, and EarthSmash (#1008) ## Additions * Adds self/others options for AirSuction ## Fixes * Fixes AirBlast push self and others being mixed up * Fixes AirBlast not using self push at all * #1006 * Fixes EarthSmash using nonexistent AvatarState config options ## Removals * Removes unnecessary arithmetic from AirBlast and AirSuction in determining knockback power * Defaults in config have been changed to make up for removing the arithmetic --- .../projectkorra/airbending/AirBlast.java | 98 ++++++++++--------- .../projectkorra/airbending/AirSuction.java | 34 ++++--- .../configuration/ConfigManager.java | 7 +- .../projectkorra/earthbending/EarthSmash.java | 8 +- 4 files changed, 77 insertions(+), 70 deletions(-) diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java index c31ed585..938f841b 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java @@ -141,8 +141,8 @@ public class AirBlast extends AirAbility { this.speed = getConfig().getDouble("Abilities.Air.AirBlast.Speed"); this.range = getConfig().getDouble("Abilities.Air.AirBlast.Range"); this.radius = getConfig().getDouble("Abilities.Air.AirBlast.Radius"); - this.pushFactor = getConfig().getDouble("Abilities.Air.AirBlast.Push.Entities"); - this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirBlast.Push.Self"); + this.pushFactor = getConfig().getDouble("Abilities.Air.AirBlast.Push.Self"); + this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirBlast.Push.Entities"); this.canFlickLevers = getConfig().getBoolean("Abilities.Air.AirBlast.CanFlickLevers"); this.canOpenDoors = getConfig().getBoolean("Abilities.Air.AirBlast.CanOpenDoors"); this.canPressButtons = getConfig().getBoolean("Abilities.Air.AirBlast.CanPressButtons"); @@ -212,14 +212,26 @@ public class AirBlast extends AirAbility { } private void affect(final Entity entity) { - final boolean isUser = entity.getUniqueId() == this.player.getUniqueId(); - - if (!isUser || this.isFromOtherOrigin) { - this.pushFactor = this.pushFactorForOthers; - final Vector velocity = entity.getVelocity(); + if (entity instanceof Player) { + if (Commands.invincible.contains(((Player) entity).getName())) { + return; + } + } + + if (!affectedEntities.contains(entity)) { + final boolean isUser = entity.getUniqueId() == this.player.getUniqueId(); + double knockback = this.pushFactorForOthers; + + if (isUser) { + if (isFromOtherOrigin) { + knockback = this.pushFactor; + } else { + return; + } + } + final double max = this.speed / this.speedFactor; - double factor = this.pushFactor; - + final Vector push = this.direction.clone(); if (Math.abs(push.getY()) > max && !isUser) { if (push.getY() < 0) { @@ -228,56 +240,46 @@ public class AirBlast extends AirAbility { push.setY(max); } } + if (this.location.getWorld().equals(this.origin.getWorld())) { - factor *= 1 - this.location.distance(this.origin) / (2 * this.range); + knockback *= 1 - this.location.distance(this.origin) / (2 * this.range); } - - if (isUser && GeneralMethods.isSolid(this.player.getLocation().add(0, -.5, 0).getBlock())) { - factor *= .5; + + if (GeneralMethods.isSolid(entity.getLocation().add(0, -.5, 0).getBlock())) { + knockback *= .5; } - - 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)); + + push.normalize().multiply(knockback); + + if (Math.abs(entity.getVelocity().dot(push)) > knockback) { + push.normalize().add(entity.getVelocity()).multiply(knockback); } - - if (entity instanceof Player) { - if (Commands.invincible.contains(((Player) entity).getName())) { - return; - } - } - - if (Double.isNaN(velocity.length())) { - return; - } - - GeneralMethods.setVelocity(entity, velocity); + + GeneralMethods.setVelocity(entity, push); + if (this.source != null) { new HorizontalVelocityTracker(entity, this.player, 200l, this.source); } else { new HorizontalVelocityTracker(entity, this.player, 200l, this); } - - if (entity.getFireTicks() > 0) { - entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0); - } - - entity.setFireTicks(0); - breakBreathbendingHold(entity); - - if (this.source != null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player) && !this.affectedEntities.contains(entity))) { - DamageHandler.damageEntity(entity, this.damage, this.source); - this.affectedEntities.add(entity); - } else if (this.source == null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player) && !this.affectedEntities.contains(entity))) { - DamageHandler.damageEntity(entity, this.damage, this); - this.affectedEntities.add(entity); + + if (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player)) { + if (this.source != null) { + DamageHandler.damageEntity(entity, this.damage, this.source); + } else { + DamageHandler.damageEntity(entity, this.damage, this); + } } + + this.affectedEntities.add(entity); } + + if (entity.getFireTicks() > 0) { + entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0); + } + + entity.setFireTicks(0); + breakBreathbendingHold(entity); } @Override diff --git a/src/com/projectkorra/projectkorra/airbending/AirSuction.java b/src/com/projectkorra/projectkorra/airbending/AirSuction.java index 8a494387..3aff0212 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSuction.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSuction.java @@ -42,6 +42,8 @@ public class AirSuction extends AirAbility { private double radius; @Attribute(Attribute.KNOCKBACK) private double pushFactor; + @Attribute(Attribute.KNOCKBACK + "Others") + private double pushFactorForOthers; private Random random; private Location location; private Location origin; @@ -76,7 +78,8 @@ public class AirSuction extends AirAbility { this.speed = getConfig().getDouble("Abilities.Air.AirSuction.Speed"); this.range = getConfig().getDouble("Abilities.Air.AirSuction.Range"); this.radius = getConfig().getDouble("Abilities.Air.AirSuction.Radius"); - this.pushFactor = getConfig().getDouble("Abilities.Air.AirSuction.Push"); + this.pushFactor = getConfig().getDouble("Abilities.Air.AirSuction.Push.Self"); + this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirSuction.Push.Others"); this.cooldown = getConfig().getLong("Abilities.Air.AirSuction.Cooldown"); this.random = new Random(); this.origin = this.getTargetLocation(); @@ -201,10 +204,15 @@ public class AirSuction extends AirAbility { if ((entity.getEntityId() == this.player.getEntityId()) && !this.canAffectSelf) { continue; } - final Vector velocity = entity.getVelocity(); + + double knockback = this.pushFactor; + + if (entity.getEntityId() != player.getEntityId()) { + knockback = this.pushFactorForOthers; + } + final double max = this.speed; final Vector push = this.direction.clone(); - double factor = this.pushFactor; if (Math.abs(push.getY()) > max) { if (push.getY() < 0) { @@ -215,20 +223,16 @@ public class AirSuction extends AirAbility { } if (this.location.getWorld().equals(this.origin.getWorld())) { - factor *= 1 - this.location.distance(this.origin) / (2 * this.range); + knockback *= 1 - this.location.distance(this.origin) / (2 * this.range); + } + + push.normalize().multiply(knockback); + + if (Math.abs(entity.getVelocity().dot(push)) > knockback) { + push.normalize().add(entity.getVelocity()).multiply(knockback); } - 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)); - } - - GeneralMethods.setVelocity(entity, velocity); + GeneralMethods.setVelocity(entity, push.normalize().multiply(knockback)); new HorizontalVelocityTracker(entity, this.player, 200l, this); entity.setFallDistance(0); diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 7a0b08a3..e90002d9 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -802,8 +802,8 @@ public class ConfigManager { config.addDefault("Abilities.Air.AirBlast.SelectParticles", 4); config.addDefault("Abilities.Air.AirBlast.Particles", 6); config.addDefault("Abilities.Air.AirBlast.Cooldown", 500); - config.addDefault("Abilities.Air.AirBlast.Push.Self", 2.5); - config.addDefault("Abilities.Air.AirBlast.Push.Entities", 3.5); + config.addDefault("Abilities.Air.AirBlast.Push.Self", 2.0); + config.addDefault("Abilities.Air.AirBlast.Push.Entities", 1.6); config.addDefault("Abilities.Air.AirBlast.CanFlickLevers", true); config.addDefault("Abilities.Air.AirBlast.CanOpenDoors", true); config.addDefault("Abilities.Air.AirBlast.CanPressButtons", true); @@ -850,7 +850,8 @@ public class ConfigManager { config.addDefault("Abilities.Air.AirSuction.Range", 20); config.addDefault("Abilities.Air.AirSuction.SelectRange", 10); config.addDefault("Abilities.Air.AirSuction.Radius", 2); - config.addDefault("Abilities.Air.AirSuction.Push", 2.5); + config.addDefault("Abilities.Air.AirSuction.Push.Self", 2.0); + config.addDefault("Abilities.Air.AirSuction.Push.Others", 1.3); config.addDefault("Abilities.Air.AirSuction.Cooldown", 500); config.addDefault("Abilities.Air.AirSuction.Particles", 6); config.addDefault("Abilities.Air.AirSuction.SelectParticles", 6); diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java b/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java index 88cd0df3..e71a0d9e 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java @@ -163,14 +163,14 @@ public class EarthSmash extends EarthAbility { if (bPlayer.isAvatarState()) { this.selectRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.SelectRange"); - this.grabRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Grab.Range"); + this.grabRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.GrabRange"); this.chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthSmash.ChargeTime"); this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthSmash.Cooldown"); this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Damage"); this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Knockback"); - this.flightSpeed = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Flight.Speed"); - this.flightDuration = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthSmash.Flight.Duration"); - this.shootRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Shoot.Range"); + this.flightSpeed = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.FlightSpeed"); + this.flightDuration = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthSmash.FlightTimer"); + this.shootRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.ShootRange"); } } From cd9968a1c15c227bd48f702b3acc1c710c7139c0 Mon Sep 17 00:00:00 2001 From: Benford Whitaker Date: Mon, 26 Aug 2019 00:18:41 -0400 Subject: [PATCH 03/11] Fix EarthBlast and Suffocate, and clean up RaiseEarth (#1009) ## Additions * Adds logic for EarthBlast being used on ceilings * Adds default cooldown to Suffocate ## Changes * Fixes Suffocate being usable through walls * Improves logic for EarthBlast pathing in general ## Removals * `ALL_AFFECTED_BLOCKS` in RaiseEarth isn't actually used, removes it. --- .../projectkorra/projectkorra/GeneralMethods.java | 15 ++++++++++++--- .../projectkorra/airbending/Suffocate.java | 4 ++-- .../projectkorra/configuration/ConfigManager.java | 2 +- .../projectkorra/earthbending/EarthBlast.java | 8 ++++++-- .../projectkorra/earthbending/RaiseEarth.java | 14 ++++++++------ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 1c7c24d8..ccf82892 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1187,8 +1187,8 @@ public class GeneralMethods { public static Entity getTargetedEntity(final Player player, final double range) { return getTargetedEntity(player, range, new ArrayList()); } - - public static Location getTargetedLocation(final Player player, final double range, final boolean ignoreTempBlocks, final Material... nonOpaque2) { + + public static Location getTargetedLocation(final Player player, final double range, final boolean ignoreTempBlocks, final boolean checkDiagonals, final Material... nonOpaque2) { final Location origin = player.getEyeLocation(); final Vector direction = origin.getDirection(); @@ -1208,6 +1208,11 @@ public class GeneralMethods { for (double i = 0; i < range; i += 0.2) { location.add(vec); + + if (checkDiagonals && checkDiagonalWall(location, vec)) { + location.subtract(vec); + break; + } final Block block = location.getBlock(); @@ -1224,12 +1229,16 @@ public class GeneralMethods { return location; } + public static Location getTargetedLocation(final Player player, final double range, final boolean ignoreTempBlocks, final Material... nonOpaque2) { + return getTargetedLocation(player, range, ignoreTempBlocks, true, nonOpaque2); + } + public static Location getTargetedLocation(final Player player, final double range, final Material... nonOpaque2) { return getTargetedLocation(player, range, false, nonOpaque2); } public static Location getTargetedLocation(final Player player, final int range) { - return getTargetedLocation(player, range, Material.AIR); + return getTargetedLocation(player, range); } public static Block getTopBlock(final Location loc, final int range) { diff --git a/src/com/projectkorra/projectkorra/airbending/Suffocate.java b/src/com/projectkorra/projectkorra/airbending/Suffocate.java index 81623b49..a42abeae 100644 --- a/src/com/projectkorra/projectkorra/airbending/Suffocate.java +++ b/src/com/projectkorra/projectkorra/airbending/Suffocate.java @@ -142,7 +142,6 @@ public class Suffocate extends AirAbility { } } - this.bPlayer.addCooldown(this); this.start(); } @@ -171,7 +170,7 @@ public class Suffocate extends AirAbility { if (this.player.getWorld().equals(this.targets.get(0).getWorld())) { dist = this.player.getEyeLocation().distance(this.targets.get(0).getEyeLocation()); } - final Location targetLoc = this.player.getEyeLocation().clone().add(this.player.getEyeLocation().getDirection().normalize().multiply(dist)); + final Location targetLoc = GeneralMethods.getTargetedLocation(player, dist, false, getTransparentMaterials()); final List ents = GeneralMethods.getEntitiesAroundPoint(targetLoc, this.constantAimRadius); for (int i = 0; i < this.targets.size(); i++) { @@ -336,6 +335,7 @@ public class Suffocate extends AirAbility { @Override public void remove() { super.remove(); + this.bPlayer.addCooldown(this); for (int i = 0; i < this.tasks.size(); i++) { this.tasks.get(i).cancel(); this.tasks.remove(i); diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index e90002d9..871f4ada 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -876,7 +876,7 @@ public class ConfigManager { config.addDefault("Abilities.Air.Suffocate.Enabled", true); config.addDefault("Abilities.Air.Suffocate.ChargeTime", 500); - config.addDefault("Abilities.Air.Suffocate.Cooldown", 0); + config.addDefault("Abilities.Air.Suffocate.Cooldown", 6500); config.addDefault("Abilities.Air.Suffocate.Range", 20); config.addDefault("Abilities.Air.Suffocate.Damage", 2); config.addDefault("Abilities.Air.Suffocate.DamageInitialDelay", 2); diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java b/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java index b00cf9ad..6157139e 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -71,7 +72,6 @@ public class EarthBlast extends EarthAbility { if (this.bPlayer.isAvatarState()) { this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthBlast.Cooldown"); this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthBlast.Damage"); - } if (this.prepare()) { @@ -380,8 +380,12 @@ public class EarthBlast extends EarthAbility { this.firstDestination = this.location.clone(); if (this.destination.getY() - this.location.getY() > 2) { this.firstDestination.setY(this.destination.getY() - 1); - } else { + } else if (this.location.getY() > player.getEyeLocation().getY() && this.location.getBlock().getRelative(BlockFace.UP).isPassable()) { + this.firstDestination.subtract(0, 2, 0); + } else if (this.location.getBlock().getRelative(BlockFace.UP).isPassable() && this.location.getBlock().getRelative(BlockFace.UP, 2).isPassable()) { this.firstDestination.add(0, 2, 0); + } else { + this.firstDestination.add(GeneralMethods.getDirection(this.location, this.destination).normalize().setY(0)); } if (this.destination.distanceSquared(this.location) <= 1) { diff --git a/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java b/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java index fbc88f19..12330e89 100644 --- a/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java +++ b/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java @@ -2,7 +2,6 @@ package com.projectkorra.projectkorra.earthbending; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Location; @@ -15,11 +14,10 @@ import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; +import com.projectkorra.projectkorra.util.TempBlock; public class RaiseEarth extends EarthAbility { - private static final Map ALL_AFFECTED_BLOCKS = new ConcurrentHashMap<>(); - private int distance; @Attribute(Attribute.HEIGHT) private int height; @@ -104,7 +102,7 @@ public class RaiseEarth extends EarthAbility { private boolean canInstantiate() { for (final Block block : this.affectedBlocks.keySet()) { - if (!this.isEarthbendable(block) || ALL_AFFECTED_BLOCKS.containsKey(block)) { + if (!this.isEarthbendable(block) || TempBlock.isTempBlock(block)) { return false; } } @@ -143,11 +141,15 @@ public class RaiseEarth extends EarthAbility { } public static boolean blockInAllAffectedBlocks(final Block block) { - return ALL_AFFECTED_BLOCKS.containsKey(block); + for (RaiseEarth raiseEarth : getAbilities(RaiseEarth.class)) { + if (raiseEarth.affectedBlocks.contains(block)) { + return true; + } + } + return false; } public static void revertAffectedBlock(final Block block) { - ALL_AFFECTED_BLOCKS.remove(block); for (final RaiseEarth raiseEarth : getAbilities(RaiseEarth.class)) { raiseEarth.affectedBlocks.remove(block); } From 5d9e1d5b058facc033a70c2cac4e6406cb4424d8 Mon Sep 17 00:00:00 2001 From: Benford Whitaker Date: Mon, 26 Aug 2019 03:18:58 -0400 Subject: [PATCH 04/11] Fix infinite recursion in GeneralMethods from incorrect method call (#1014) ## Fixes * Fixes infinite recursion in `GeneralMethods#getTargetedLocation(Player, int)` --- src/com/projectkorra/projectkorra/GeneralMethods.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index ccf82892..59cf232e 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1238,7 +1238,7 @@ public class GeneralMethods { } public static Location getTargetedLocation(final Player player, final int range) { - return getTargetedLocation(player, range); + return getTargetedLocation(player, range, false); } public static Block getTopBlock(final Location loc, final int range) { From 34fa6d08b82b0a11ee1d80fbef006f636e6a6a19 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 31 Aug 2019 19:28:31 -0400 Subject: [PATCH 05/11] Fix cooldowns of fire abilities with a duration, getClosestEntity, and Surge Wall diagonal check (#1016) ## Fixes * Fixes getClosestEntity to not rely on a distance check for if the entity is returned, but instead purely get the closest entity from getEntitiesAroundPoint * Fixes SurgeWall to not do that new diagonal check, fixes Ice wall glitching out ## Misc. Changes * Changes JetBlaze hitbox size, was way too big * Changes FireJet, WallOfFire, and the FireJet Combos cooldowns to activate when the move completes --- .../projectkorra/projectkorra/GeneralMethods.java | 14 +++++++------- .../projectkorra/firebending/FireJet.java | 2 +- .../projectkorra/firebending/WallOfFire.java | 7 ++++++- .../projectkorra/firebending/combo/JetBlast.java | 2 +- .../projectkorra/firebending/combo/JetBlaze.java | 4 ++-- .../projectkorra/waterbending/SurgeWall.java | 3 +-- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 59cf232e..d16fa96d 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -872,17 +872,17 @@ public class GeneralMethods { */ public static Entity getClosestEntity(Location center, double radius) { Entity found = null; - double distance = radius * radius; + Double distance = null; for (Entity entity : GeneralMethods.getEntitiesAroundPoint(center, radius)) { - double check = center.distance(entity.getLocation()); + double check = center.distanceSquared(entity.getLocation()); - if (check < distance) { + if (distance == null || check < distance) { found = entity; distance = check; } } - + return found; } @@ -894,12 +894,12 @@ public class GeneralMethods { */ public static LivingEntity getClosestLivingEntity(Location center, double radius) { LivingEntity le = null; - double distance = radius * radius; + Double distance = null; for (Entity entity : GeneralMethods.getEntitiesAroundPoint(center, radius)) { - double check = center.distance(entity.getLocation()); + double check = center.distanceSquared(entity.getLocation()); - if (entity instanceof LivingEntity && check < distance) { + if (entity instanceof LivingEntity && (distance == null || check < distance)) { le = (LivingEntity) entity; distance = check; } diff --git a/src/com/projectkorra/projectkorra/firebending/FireJet.java b/src/com/projectkorra/projectkorra/firebending/FireJet.java index 0f492483..68da1d7a 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireJet.java +++ b/src/com/projectkorra/projectkorra/firebending/FireJet.java @@ -77,7 +77,6 @@ public class FireJet extends FireAbility { this.previousGlidingState = player.isGliding(); player.setGliding(true); } - this.bPlayer.addCooldown(this); } } @@ -118,6 +117,7 @@ public class FireJet extends FireAbility { } this.flightHandler.removeInstance(this.player, this.getName()); this.player.setFallDistance(0); + this.bPlayer.addCooldown(this); } @Override diff --git a/src/com/projectkorra/projectkorra/firebending/WallOfFire.java b/src/com/projectkorra/projectkorra/firebending/WallOfFire.java index d73935de..e11cd6c8 100644 --- a/src/com/projectkorra/projectkorra/firebending/WallOfFire.java +++ b/src/com/projectkorra/projectkorra/firebending/WallOfFire.java @@ -102,7 +102,6 @@ public class WallOfFire extends FireAbility { this.initializeBlocks(); this.start(); - this.bPlayer.addCooldown(this); } private void affect(final Entity entity) { @@ -210,6 +209,12 @@ public class WallOfFire extends FireAbility { } } + @Override + public void remove() { + super.remove(); + this.bPlayer.addCooldown(this); + } + @Override public String getName() { return "WallOfFire"; diff --git a/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java b/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java index 3642ef7d..ffb6efef 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java @@ -79,7 +79,6 @@ public class JetBlast extends FireAbility implements ComboAbility { return; } - this.bPlayer.addCooldown("JetBlast", this.cooldown); this.firstTime = false; final float spread = 0F; ParticleEffect.EXPLOSION_LARGE.display(this.player.getLocation(), 1, spread, spread, spread, 0); @@ -106,6 +105,7 @@ public class JetBlast extends FireAbility implements ComboAbility { task.remove(); } super.remove(); + this.bPlayer.addCooldown("JetBlast", this.cooldown); } @Override diff --git a/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java b/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java index f860aa7a..c04cb42a 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java @@ -88,7 +88,6 @@ public class JetBlaze extends FireAbility implements ComboAbility { this.remove(); return; } - this.bPlayer.addCooldown("JetBlaze", this.cooldown); this.firstTime = false; } else if (System.currentTimeMillis() - this.time > this.duration) { this.remove(); @@ -103,7 +102,7 @@ public class JetBlaze extends FireAbility implements ComboAbility { fs.setDensity(8); fs.setSpread(1.0F); fs.setUseNewParticles(true); - fs.setCollisionRadius(3); + fs.setCollisionRadius(2); fs.setParticleEffect(ParticleEffect.SMOKE_LARGE); fs.setDamage(this.damage); fs.setFireTicks(this.fireTicks); @@ -121,6 +120,7 @@ public class JetBlaze extends FireAbility implements ComboAbility { task.remove(); } super.remove(); + this.bPlayer.addCooldown("JetBlaze", this.cooldown); } @Override diff --git a/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java b/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java index 5f9f8614..9f6fead2 100644 --- a/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java +++ b/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java @@ -255,12 +255,11 @@ public class SurgeWall extends WaterAbility { } final ArrayList blocks = new ArrayList(); - final Location targetLoc = GeneralMethods.getTargetedLocation(this.player, (int) this.range, Material.WATER, Material.ICE); + final Location targetLoc = GeneralMethods.getTargetedLocation(this.player, (int) this.range, false, false, Material.WATER, Material.ICE); this.location = targetLoc.clone(); final Vector eyeDir = this.player.getEyeLocation().getDirection(); Vector vector; Block block; - for (double i = 0; i <= this.getNightFactor(this.radius); i += 0.5) { for (double angle = 0; angle < 360; angle += 10) { vector = GeneralMethods.getOrthogonalVector(eyeDir.clone(), angle, i); From c4be31c3b939da375037b8a8bd2433f61e0aeb4b Mon Sep 17 00:00:00 2001 From: Benford Whitaker Date: Sat, 31 Aug 2019 22:42:32 -0400 Subject: [PATCH 06/11] Fix Charged FireBlast radius and cooldown (#1019) ## Fixes * Fixes Charged FireBlast radius being too big * Fixes Charged FireBlast cooldown happening without using the ability --- .../projectkorra/firebending/FireBlastCharged.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java b/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java index 3702a830..60df8218 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java @@ -216,7 +216,7 @@ public class FireBlastCharged extends FireAbility { } boolean exploded = false; - for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, 2 * this.collisionRadius)) { + for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.collisionRadius)) { if (entity.getEntityId() == this.player.getEntityId() || GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) { continue; } @@ -310,7 +310,9 @@ public class FireBlastCharged extends FireAbility { @Override public void remove() { super.remove(); - this.bPlayer.addCooldown(this); + if (this.charged) { + this.bPlayer.addCooldown(this); + } } @Override From 861f0055d52865e24ed5a126e78eadefba806202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Ind=C3=ADbil=20de=20la=20Cruz=20Calvo?= Date: Mon, 2 Sep 2019 18:53:51 +0200 Subject: [PATCH 07/11] Fix WaterReturn not finding bottles after potions (#1021) ## Additions Static Function that returns the slot id of the first water bottle found, -1 if none found. Used to not repeat code that should be the same (hasWaterBottle and emptyWaterBottle start finding this index, but they don't use the same code). ## Fixes Fixes an error in hasWaterBottle function. In the former version of the WaterReturn.java file, hasWaterBottle only tests if the first item with Material.POTION in the inventory is of type PotionType.WATER. Having a random potion in the inventory in any slot before a Water Bottle makes this to return false, instead of checking all the potions in the Player Inventory. This causes the player to be unable to use the bottle as a water source. The new code checks all the potions. ## Misc. Changes Since the items in an inventory aren't usually sorted (players don't sort items by id in their inventories), the "contains" method iterates all over the items on the inventory until it finds one with the specified material. The "first" method does the same, but instead of returning a boolean, it gives us the slot index of the item or -1 if not found. Since in "fillBottle" method we are going to calculate that index after checking whether the item is in the inventory or not, I've calculated this index with the "first" method and checking if it is greater or equals than 0 (not -1). Doing so we don't repeat the search task and we have a little improvement in efficiency terms. --- .../waterbending/util/WaterReturn.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java b/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java index bcdb7bec..c0784ece 100644 --- a/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java +++ b/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java @@ -114,8 +114,8 @@ public class WaterReturn extends WaterAbility { private void fillBottle() { final PlayerInventory inventory = this.player.getInventory(); - if (inventory.contains(Material.GLASS_BOTTLE)) { - final int index = inventory.first(Material.GLASS_BOTTLE); + final int index = inventory.first(Material.GLASS_BOTTLE); + if (index >= 0) { final ItemStack item = inventory.getItem(index); final ItemStack water = waterBottleItem(); @@ -146,27 +146,15 @@ public class WaterReturn extends WaterAbility { return false; } - public static boolean hasWaterBottle(final Player player) { - if (hasAbility(player, WaterReturn.class) || isBending(player)) { - return false; - } - final PlayerInventory inventory = player.getInventory(); - if (inventory.contains(Material.POTION)) { - final ItemStack item = inventory.getItem(inventory.first(Material.POTION)); - final PotionMeta meta = (PotionMeta) item.getItemMeta(); - return meta.getBasePotionData().getType() == PotionType.WATER; - } - return false; - } - - public static void emptyWaterBottle(final Player player) { - final PlayerInventory inventory = player.getInventory(); + public static int firstWaterBottle(final PlayerInventory inventory) { int index = inventory.first(Material.POTION); // Check that the first one found is actually a WATER bottle. We aren't implementing potion bending just yet. - if (index != -1 && !((PotionMeta) inventory.getItem(index).getItemMeta()).getBasePotionData().getType().equals(PotionType.WATER)) { - for (int i = 0; i < inventory.getSize(); i++) { - if (inventory.getItem(i).getType() == Material.POTION) { + if (index != -1) { + int aux = index; + index = -1; + for (int i = aux; i < inventory.getSize(); i++) { + if (inventory.getItem(i) != null && inventory.getItem(i).getType() == Material.POTION && inventory.getItem(i).hasItemMeta()) { final PotionMeta meta = (PotionMeta) inventory.getItem(i).getItemMeta(); if (meta.getBasePotionData().getType().equals(PotionType.WATER)) { index = i; @@ -176,6 +164,22 @@ public class WaterReturn extends WaterAbility { } } + return index; + } + + public static boolean hasWaterBottle(final Player player) { + if (hasAbility(player, WaterReturn.class) || isBending(player)) { + return false; + } + final PlayerInventory inventory = player.getInventory(); + + return WaterReturn.firstWaterBottle(inventory) >= 0; + } + + public static void emptyWaterBottle(final Player player) { + final PlayerInventory inventory = player.getInventory(); + int index = WaterReturn.firstWaterBottle(inventory); + if (index != -1) { final ItemStack item = inventory.getItem(index); if (item.getAmount() == 1) { From 0f2940f5ebbf96b2223f50a85b647e6d47b0be59 Mon Sep 17 00:00:00 2001 From: Benford Whitaker Date: Sun, 8 Sep 2019 23:19:49 -0400 Subject: [PATCH 08/11] Remove revertBlock recursive calls in EarthAbility and Collapse (#1023) ## Fixes * Fixes recursive calls to `EarthAbility#revertBlock(Block)` --- .../projectkorra/projectkorra/ability/EarthAbility.java | 8 ++++---- .../projectkorra/projectkorra/earthbending/Collapse.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/projectkorra/projectkorra/ability/EarthAbility.java b/src/com/projectkorra/projectkorra/ability/EarthAbility.java index 890102ae..200bc1c2 100644 --- a/src/com/projectkorra/projectkorra/ability/EarthAbility.java +++ b/src/com/projectkorra/projectkorra/ability/EarthAbility.java @@ -604,10 +604,10 @@ public abstract class EarthAbility extends ElementalAbility { if (block.equals(sourceblock)) { info.getState().update(true, false); if (RaiseEarth.blockInAllAffectedBlocks(sourceblock)) { - EarthAbility.revertBlock(sourceblock); + RaiseEarth.revertAffectedBlock(sourceblock); } if (RaiseEarth.blockInAllAffectedBlocks(block)) { - EarthAbility.revertBlock(block); + RaiseEarth.revertAffectedBlock(block); } MOVED_EARTH.remove(block); return true; @@ -636,10 +636,10 @@ public abstract class EarthAbility extends ElementalAbility { } if (RaiseEarth.blockInAllAffectedBlocks(sourceblock)) { - EarthAbility.revertBlock(sourceblock); + RaiseEarth.revertAffectedBlock(sourceblock); } if (RaiseEarth.blockInAllAffectedBlocks(block)) { - EarthAbility.revertBlock(block); + RaiseEarth.revertAffectedBlock(block); } MOVED_EARTH.remove(block); } diff --git a/src/com/projectkorra/projectkorra/earthbending/Collapse.java b/src/com/projectkorra/projectkorra/earthbending/Collapse.java index c4d518dd..1bcf02ac 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Collapse.java +++ b/src/com/projectkorra/projectkorra/earthbending/Collapse.java @@ -98,7 +98,7 @@ public class Collapse extends EarthAbility { thisBlock = this.block.getWorld().getBlockAt(this.location.clone().add(this.direction.clone().multiply(-i))); this.affectedBlocks.put(thisBlock, thisBlock); if (RaiseEarth.blockInAllAffectedBlocks(thisBlock)) { - EarthAbility.revertBlock(thisBlock); + RaiseEarth.revertAffectedBlock(thisBlock); } } } From 2091e58c359ff9d3bb85f3930172fd0a6e76786e Mon Sep 17 00:00:00 2001 From: Benford Whitaker Date: Sun, 8 Sep 2019 23:41:49 -0400 Subject: [PATCH 09/11] AirBlast and AirBurst Changes (#1017) ## Removals * Removes `AirBurst#getAffectedEntities()`, shouldn't allow direct access to the list ## Misc. Changes * Lowers "friction" in AirBlast knockback for entities on the ground * Ignore "friction" in AirBlast when the AirBurst source isn't null * Changes entity velocity comparison to only add vectors angled > pi/3 from push vector * Increase default AirBurst push option --- .../projectkorra/airbending/AirBlast.java | 98 +++++++++---------- .../projectkorra/airbending/AirBurst.java | 4 - .../configuration/ConfigManager.java | 2 +- 3 files changed, 49 insertions(+), 55 deletions(-) diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java index 938f841b..986d15b9 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java @@ -217,60 +217,58 @@ public class AirBlast extends AirAbility { return; } } - - if (!affectedEntities.contains(entity)) { - final boolean isUser = entity.getUniqueId() == this.player.getUniqueId(); - double knockback = this.pushFactorForOthers; - - if (isUser) { - if (isFromOtherOrigin) { - knockback = this.pushFactor; - } else { - return; - } - } - - final double max = this.speed / this.speedFactor; - - final Vector push = this.direction.clone(); - if (Math.abs(push.getY()) > max && !isUser) { - if (push.getY() < 0) { - push.setY(-max); - } else { - push.setY(max); - } - } - - if (this.location.getWorld().equals(this.origin.getWorld())) { - knockback *= 1 - this.location.distance(this.origin) / (2 * this.range); - } - if (GeneralMethods.isSolid(entity.getLocation().add(0, -.5, 0).getBlock())) { - knockback *= .5; - } - - push.normalize().multiply(knockback); - - if (Math.abs(entity.getVelocity().dot(push)) > knockback) { - push.normalize().add(entity.getVelocity()).multiply(knockback); - } - - GeneralMethods.setVelocity(entity, push); - - if (this.source != null) { - new HorizontalVelocityTracker(entity, this.player, 200l, this.source); + final boolean isUser = entity.getUniqueId() == this.player.getUniqueId(); + double knockback = this.pushFactorForOthers; + + if (isUser) { + if (isFromOtherOrigin) { + knockback = this.pushFactor; } else { - new HorizontalVelocityTracker(entity, this.player, 200l, this); + return; } - - if (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player)) { - if (this.source != null) { - DamageHandler.damageEntity(entity, this.damage, this.source); - } else { - DamageHandler.damageEntity(entity, this.damage, this); - } + } + + final double max = this.speed / this.speedFactor; + + final Vector push = this.direction.clone(); + if (Math.abs(push.getY()) > max && !isUser) { + if (push.getY() < 0) { + push.setY(-max); + } else { + push.setY(max); } - + } + + if (this.location.getWorld().equals(this.origin.getWorld())) { + knockback *= 1 - this.location.distance(this.origin) / (2 * this.range); + } + + if (GeneralMethods.isSolid(entity.getLocation().add(0, -0.5, 0).getBlock()) && source == null) { + knockback *= 0.85; + } + + push.normalize().multiply(knockback); + + if (Math.abs(entity.getVelocity().dot(push)) > knockback && entity.getVelocity().angle(push) > Math.PI / 3) { + push.normalize().add(entity.getVelocity()).multiply(knockback); + } + + GeneralMethods.setVelocity(entity, push); + + if (this.source != null) { + new HorizontalVelocityTracker(entity, this.player, 200l, this.source); + } else { + new HorizontalVelocityTracker(entity, this.player, 200l, this); + } + + if (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player) && !this.affectedEntities.contains(entity)) { + if (this.source != null) { + DamageHandler.damageEntity(entity, this.damage, this.source); + } else { + DamageHandler.damageEntity(entity, this.damage, this); + } + this.affectedEntities.add(entity); } diff --git a/src/com/projectkorra/projectkorra/airbending/AirBurst.java b/src/com/projectkorra/projectkorra/airbending/AirBurst.java index d7633877..031fed78 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBurst.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBurst.java @@ -321,8 +321,4 @@ public class AirBurst extends AirAbility { public ArrayList getBlasts() { return this.blasts; } - - public ArrayList getAffectedEntities() { - return this.affectedEntities; - } } diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 871f4ada..231d9b9f 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -811,7 +811,7 @@ public class ConfigManager { config.addDefault("Abilities.Air.AirBurst.Enabled", true); config.addDefault("Abilities.Air.AirBurst.FallThreshold", 10); - config.addDefault("Abilities.Air.AirBurst.PushFactor", 1.5); + config.addDefault("Abilities.Air.AirBurst.PushFactor", 2.8); config.addDefault("Abilities.Air.AirBurst.ChargeTime", 1750); config.addDefault("Abilities.Air.AirBurst.Damage", 0); config.addDefault("Abilities.Air.AirBurst.Cooldown", 0); From da76d0ac120e5c8cc19be6dc0a4c74e86ba5aeb5 Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 10 Sep 2019 21:54:18 -0400 Subject: [PATCH 10/11] Fix Preset command not being able to list page numbers higher than 1 (#1024) ## Fixes * Fixes listing preset pages. Previously doing "/b preset list 2" would just return the help message --- .../projectkorra/command/PresetCommand.java | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/com/projectkorra/projectkorra/command/PresetCommand.java b/src/com/projectkorra/projectkorra/command/PresetCommand.java index efa04582..97708f6e 100644 --- a/src/com/projectkorra/projectkorra/command/PresetCommand.java +++ b/src/com/projectkorra/projectkorra/command/PresetCommand.java @@ -77,41 +77,45 @@ public class PresetCommand extends PKCommand { bPlayer = BendingPlayer.getBendingPlayer(player); } - // bending preset list. - if (args.size() == 1) { - if (Arrays.asList(listaliases).contains(args.get(0)) && this.hasPermission(sender, "list")) { - boolean firstMessage = true; - - final List presets = Preset.presets.get(player.getUniqueId()); - final List presetNames = new ArrayList(); - - if (presets == null || presets.isEmpty()) { - GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresets); - return; - } - - for (final Preset preset : presets) { - presetNames.add(preset.getName()); - } - - for (final String s : this.getPage(presetNames, ChatColor.GOLD + "Presets: ", 1, false)) { - if (firstMessage) { - GeneralMethods.sendBrandingMessage(sender, s); - firstMessage = false; - } else { - sender.sendMessage(ChatColor.YELLOW + s); - } - } - - return; + int page = 1; + String name = null; + if (args.size() == 1 && !Arrays.asList(listaliases).contains(args.get(0))){ + this.help(sender, false); + } else if (args.size() >= 2) { + if (Arrays.asList(listaliases).contains(args.get(0))) { + page = Integer.parseInt(args.get(1)); } else { - this.help(sender, false); - return; + name = args.get(1); } } - final String name = args.get(1); - if (Arrays.asList(deletealiases).contains(args.get(0)) && this.hasPermission(sender, "delete")) { // bending preset delete name. + // bending preset list. + if (Arrays.asList(listaliases).contains(args.get(0)) && this.hasPermission(sender, "list")) { + boolean firstMessage = true; + + final List presets = Preset.presets.get(player.getUniqueId()); + final List presetNames = new ArrayList(); + + if (presets == null || presets.isEmpty()) { + GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresets); + return; + } + + for (final Preset preset : presets) { + presetNames.add(preset.getName()); + } + + for (final String s : this.getPage(presetNames, ChatColor.GOLD + "Presets: ", page, false)) { + if (firstMessage) { + GeneralMethods.sendBrandingMessage(sender, s); + firstMessage = false; + } else { + sender.sendMessage(ChatColor.YELLOW + s); + } + } + + return; + } else if (Arrays.asList(deletealiases).contains(args.get(0)) && this.hasPermission(sender, "delete")) { // bending preset delete name. if (!Preset.presetExists(player, name)) { GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetName); return; From a8a8daa6d0ac25cb505e864e58e81abe40c246f4 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 28 Sep 2019 15:00:31 -0400 Subject: [PATCH 11/11] Fix catapult and metalclips not respecting invincible or region protection (#1027) ## Fixes * Fixes catapult launching player with invincible toggled or protected region * Fixes metalclip working on players with invincible toggled --- src/com/projectkorra/projectkorra/earthbending/Catapult.java | 4 ++++ .../projectkorra/earthbending/metal/MetalClips.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/projectkorra/projectkorra/earthbending/Catapult.java b/src/com/projectkorra/projectkorra/earthbending/Catapult.java index 838c8abc..78bfe6bd 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Catapult.java +++ b/src/com/projectkorra/projectkorra/earthbending/Catapult.java @@ -11,6 +11,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; @@ -69,6 +70,9 @@ public class Catapult extends EarthAbility { private void moveEarth(final Vector apply, final Vector direction) { for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.origin, 2)) { if (entity.getEntityId() != this.player.getEntityId()) { + if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) { + continue; + } entity.setVelocity(apply); } } diff --git a/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java b/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java index c3b95ca0..d535e137 100644 --- a/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java +++ b/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java @@ -18,6 +18,7 @@ import org.bukkit.entity.Zombie; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.MetalAbility; @@ -165,7 +166,7 @@ public class MetalClips extends MetalAbility { return; } else if (this.metalClipsCount == 3 && !this.canUse4Clips) { return; - } else if (this.targetEntity != null && GeneralMethods.isRegionProtectedFromBuild(this, this.targetEntity.getLocation())) { + } else if (this.targetEntity != null && (GeneralMethods.isRegionProtectedFromBuild(this, this.targetEntity.getLocation()) || ((targetEntity instanceof Player) && Commands.invincible.contains(((Player) targetEntity).getName())))) { return; }