Remove unneeded damageEntity method, update events

- change EntityBendingDeath and HorizontalVelocityChange to use Ability objects, instead of strings

- update abilities to reflect changes
This commit is contained in:
Philip Stephenson 2016-02-21 16:01:28 -05:00
parent 4f4335e498
commit c0fe8256b7
14 changed files with 158 additions and 171 deletions

View file

@ -344,22 +344,19 @@ public class GeneralMethods {
}
}
public static void damageEntity(Ability ability, Entity entity, double damage) {
damageEntity(ability.getPlayer(), entity, damage, ability.getName());
}
/**
* Damages an Entity by amount of damage specified. Starts a
* {@link EntityDamageByEntityEvent}.
*
* @param player The player dealing the damage
* @param ability The ability that is used to damage the entity
* @param entity The entity that is receiving the damage
* @param damage The amount of damage to deal
* @param element The element of the ability
* @param ability The ability that is used to damage the entity
*/
public static void damageEntity(Player player, Entity entity, double damage, String ability) {
AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, CoreAbility.getAbility(player, CoreAbility.getAbility(ability).getClass()), damage);
public static void damageEntity(Ability ability, Entity entity, double damage) {
if (ability==null)
return;
Player player = ability.getPlayer();
AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, ability, damage);
Bukkit.getServer().getPluginManager().callEvent(damageEvent);
if (entity instanceof LivingEntity) {
if (entity instanceof Player && Commands.invincible.contains(entity.getName())) {
@ -371,7 +368,7 @@ public class GeneralMethods {
NCPExemptionManager.exemptPermanently(player, CheckType.FIGHT_REACH);
}
if (((LivingEntity) entity).getHealth() - damage <= 0 && !entity.isDead()) {
EntityBendingDeathEvent deathEvent = new EntityBendingDeathEvent(entity, player, damage, ability);
EntityBendingDeathEvent deathEvent = new EntityBendingDeathEvent(entity, damage, ability);
Bukkit.getServer().getPluginManager().callEvent(deathEvent);
}
((LivingEntity) entity).damage(damage, player);

View file

@ -1,5 +1,68 @@
package com.projectkorra.projectkorra;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.entity.SlimeSplitEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.ability.Ability;
import com.projectkorra.projectkorra.ability.AddonAbility;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.ChiAbility;
@ -95,68 +158,6 @@ import com.projectkorra.projectkorra.waterbending.WaterPassive;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.projectkorra.waterbending.WaterSpoutWave;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.entity.SlimeSplitEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public class PKListener implements Listener {
ProjectKorra plugin;
@ -698,9 +699,9 @@ public class PKListener implements Listener {
double damage = ((e.getDistanceTraveled() - minimumDistance) < 0 ? 0 : e.getDistanceTraveled() - minimumDistance) / (e.getDifference().length());
if (damage > 0) {
if(damage <= maxDamage) {
GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), damage, e.getAbility());
GeneralMethods.damageEntity(e.getAbility(), e.getEntity(), damage);
} else {
GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), maxDamage, e.getAbility());
GeneralMethods.damageEntity(e.getAbility(), e.getEntity(), maxDamage);
}
}
}
@ -730,8 +731,8 @@ public class PKListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerBendingDeath(EntityBendingDeathEvent event) {
if (ConfigManager.deathMsgConfig.get().getBoolean("Properties.Enabled") && event.getVictim() instanceof Player) {
CoreAbility ability = CoreAbility.getAbility(event.getAbility());
if (ConfigManager.deathMsgConfig.get().getBoolean("Properties.Enabled") && event.getEntity() instanceof Player) {
Ability ability = event.getAbility();
if (ability == null) {
return;
@ -740,8 +741,8 @@ public class PKListener implements Listener {
StringBuilder sb = new StringBuilder();
sb.append(ability.getElement().getColor());
sb.append(event.getAbility());
BENDING_PLAYER_DEATH.put((Player) event.getVictim(), sb.toString());
final Player player = (Player) event.getVictim();
BENDING_PLAYER_DEATH.put((Player) event.getEntity(), sb.toString());
final Player player = (Player) event.getEntity();
new BukkitRunnable() {
@Override
@ -849,7 +850,7 @@ public class PKListener implements Listener {
Player source = Flight.getLaunchedBy(player);
if (source != null) {
event.setCancelled(true);
GeneralMethods.damageEntity(source, player, event.getDamage(), null);
GeneralMethods.damageEntity(null, player, event.getDamage());
}
}

View file

@ -1,14 +1,9 @@
package com.projectkorra.projectkorra.airbending;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.util.Flight;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Effect;
import org.bukkit.Location;
@ -25,10 +20,14 @@ import org.bukkit.material.Lever;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.util.Flight;
public class AirBlast extends AirAbility {
@ -237,9 +236,9 @@ public class AirBlast extends AirAbility {
GeneralMethods.setVelocity(entity, velocity);
if (source != null) {
new HorizontalVelocityTracker(entity, player, 200l, "AirBurst", Element.AIR);
new HorizontalVelocityTracker(entity, player, 200l, this);
} else {
new HorizontalVelocityTracker(entity, player, 200l, "AirBlast", Element.AIR);
new HorizontalVelocityTracker(entity, player, 200l, this);
}
entity.setFallDistance(0);
@ -254,7 +253,7 @@ public class AirBlast extends AirAbility {
breakBreathbendingHold(entity);
if (source != null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(entity))) {
GeneralMethods.damageEntity(player, entity, damage, "AirBurst");
GeneralMethods.damageEntity(this, entity, damage);
affectedEntities.add(entity);
} else if (source == null && (damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(entity))) {
GeneralMethods.damageEntity(this, entity, damage);

View file

@ -1,7 +1,15 @@
package com.projectkorra.projectkorra.airbending;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility;
@ -11,15 +19,6 @@ import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.util.Flight;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
public class AirSuction extends AirAbility {
private static final int MAX_TICKS = 10000;
@ -200,7 +199,7 @@ public class AirSuction extends AirAbility {
}
GeneralMethods.setVelocity(entity, velocity);
new HorizontalVelocityTracker(entity, player, 200l, "AirSuction", Element.AIR);
new HorizontalVelocityTracker(entity, player, 200l, this);
entity.setFallDistance(0);
if (entity.getEntityId() != player.getEntityId() && entity instanceof Player) {
new Flight((Player) entity, player);

View file

@ -48,6 +48,7 @@ public class AirSwipe extends AirAbility {
private double maxChargeFactor;
private Location origin;
private Random random;
private AirSwipe ability;
private ConcurrentHashMap<Vector, Location> elements;
private ArrayList<Entity> affectedEntities;
@ -58,6 +59,7 @@ public class AirSwipe extends AirAbility {
public AirSwipe(Player player, boolean charging) {
super(player);
ability = this;
this.charging = charging;
this.origin = player.getEyeLocation();
this.charging = false;
@ -194,7 +196,7 @@ public class AirSwipe extends AirAbility {
}
if (entity instanceof LivingEntity && !affectedEntities.contains(entity)) {
if (damage != 0) {
GeneralMethods.damageEntity(player, entity, damage, "AirSwipe");
GeneralMethods.damageEntity(ability, entity, damage);
}
affectedEntities.add(entity);
}

View file

@ -1,9 +1,7 @@
package com.projectkorra.projectkorra.airbending;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.avatar.AvatarState;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
@ -13,8 +11,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.avatar.AvatarState;
/**
* Suffocate
@ -50,11 +50,13 @@ public class Suffocate extends AirAbility {
private double blindDelay;
private double blindRepeat;
private double animationSpeed;
private Suffocate ability;
private ArrayList<BukkitRunnable> tasks;
private ArrayList<LivingEntity> targets;
public Suffocate(Player player) {
super(player);
ability = this;
if (bPlayer.isOnCooldown(this)) {
return;
} else if (hasAbility(player, Suffocate.class)) {
@ -189,13 +191,12 @@ public class Suffocate extends AirAbility {
return;
} else if (!started) {
started = true;
final Player fplayer = player;
for (LivingEntity targ : targets) {
final LivingEntity target = targ;
BukkitRunnable br1 = new BukkitRunnable() {
@Override
public void run() {
GeneralMethods.damageEntity(fplayer, target, damage, "Suffocate");
GeneralMethods.damageEntity(ability, target, damage);
}
};
BukkitRunnable br2 = new BukkitRunnable() {

View file

@ -550,7 +550,7 @@ public class EarthSmash extends EarthAbility {
if (entity instanceof LivingEntity && entity != player && !affectedEntities.contains(entity)) {
affectedEntities.add(entity);
double damage = currentBlocks.size() / 13.0 * this.damage;
GeneralMethods.damageEntity(player, entity, damage, "EarthSmash");
GeneralMethods.damageEntity(this, entity, damage);
Vector travelVec = GeneralMethods.getDirection(location, entity.getLocation());
entity.setVelocity(travelVec.setY(knockup).normalize().multiply(knockback));
}

View file

@ -257,7 +257,7 @@ public class LavaSurge extends LavaAbility {
for(Entity e : GeneralMethods.getEntitiesAroundPoint(fb.getLocation(), 2)) {
if(e instanceof LivingEntity) {
if(e.getEntityId() != player.getEntityId()) {
GeneralMethods.damageEntity(player, e, impactDamage, "LavaSurge");
GeneralMethods.damageEntity(this, e, impactDamage);
e.setFireTicks(100);
GeneralMethods.setVelocity(e, direction.clone());
}

View file

@ -1,6 +1,7 @@
package com.projectkorra.projectkorra.event;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.Ability;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -8,17 +9,14 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when a player is killed by {@link GeneralMethods#damageEntity(Player player, Entity entity, double damage, String ability) GeneralMethods.damageEntity}
*
* @author kingbirdy
* Called when an entity is killed by {@link GeneralMethods#damageEntity(Player player, Entity entity, double damage, String ability) GeneralMethods.damageEntity}
*/
public class EntityBendingDeathEvent extends Event {
public static final HandlerList handlers = new HandlerList();
private Entity victim;
private Player attacker;
private String ability;
private Entity entity;
private Ability ability;
private double damage;
/**
@ -28,34 +26,33 @@ public class EntityBendingDeathEvent extends Event {
* @param damage the amount of damage done in the attack that killed the victim
* @param ability the ability used to kill the victim
*/
public EntityBendingDeathEvent(Entity victim, Player attacker, double damage, String ability) {
this.victim = victim;
this.attacker = attacker;
public EntityBendingDeathEvent(Entity entity, double damage, Ability ability) {
this.entity = entity;
this.ability = ability;
this.damage = damage;
}
/**
*
* @return the player who was killed
* @return the entity that was killed
*/
public Entity getVictim() {
return victim;
public Entity getEntity() {
return entity;
}
/**
*
* @return the player who killed the victim
* @return the player who killed the entity
*/
public Player getAttacker() {
return attacker;
return ability.getPlayer();
}
/**
*
* @return the ability used to kill the victim
*/
public String getAbility() {
public Ability getAbility() {
return ability;
}

View file

@ -1,7 +1,5 @@
package com.projectkorra.projectkorra.event;
import com.projectkorra.projectkorra.Element;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -10,6 +8,8 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.ability.Ability;
/**
* Created by Carbogen on 2/2/2015.
*/
@ -26,8 +26,7 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
private Vector difference;
private Location start;
private Location end;
private String abil;
private Element element;
private Ability abil;
@Deprecated
public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference) {
@ -38,7 +37,7 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
this.difference = difference;
}
public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference, Location start, Location end, String ability, Element element) {
public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference, Location start, Location end, Ability ability) {
this.entity = entity;
this.instigator = instigator;
this.from = from;
@ -47,7 +46,6 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
this.start = start;
this.end = end;
abil = ability;
this.element = element;
}
public Entity getEntity() {
@ -85,14 +83,10 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
return difference;
}
public String getAbility() {
public Ability getAbility() {
return abil;
}
public Element getElement() {
return element;
}
@Override
public HandlerList getHandlers() {
return handlers;

View file

@ -130,7 +130,7 @@ public class FireBlastCharged extends FireAbility {
if (distance > damageRadius) {
return;
} else if (distance < innerRadius) {
GeneralMethods.damageEntity(player, entity, maxDamage, "FireBlast");
GeneralMethods.damageEntity(this, entity, maxDamage);
return;
}

View file

@ -55,7 +55,7 @@ public class FireDamageTimer {
LivingEntity Lentity = (LivingEntity) entity;
Player source = INSTANCES.get(entity);
if (Lentity.getHealth() - DAMAGE <= 0 && !entity.isDead()) {
EntityBendingDeathEvent event = new EntityBendingDeathEvent(entity, source, DAMAGE, CoreAbility.getAbilitiesByElement(Element.FIRE).get(0).getName());
EntityBendingDeathEvent event = new EntityBendingDeathEvent(entity, DAMAGE, CoreAbility.getAbilitiesByElement(Element.FIRE).get(0));
Bukkit.getServer().getPluginManager().callEvent(event);
}

View file

@ -1,12 +1,7 @@
package com.projectkorra.projectkorra.object;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.Material;
@ -16,8 +11,13 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.Ability;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
/**
* Created by Carbogen on 2/2/2015.
@ -35,12 +35,11 @@ public class HorizontalVelocityTracker {
private Vector thisVelocity;
private Location launchLocation;
private Location impactLocation;
private String abil;
private Element e;
private Ability abil;
public static String[] abils = {"AirBlast", "AirBurst", "AirSuction", "Bloodbending"};
public HorizontalVelocityTracker(Entity e, Player instigator, long delay, String ability, Element element) {
public HorizontalVelocityTracker(Entity e, Player instigator, long delay, Ability ability) {
if (!ProjectKorra.plugin.getConfig().getBoolean("Properties.HorizontalCollisionPhysics.Enabled"))
return;
@ -54,7 +53,6 @@ public class HorizontalVelocityTracker {
impactLocation = launchLocation.clone();
this.delay = delay;
abil = ability;
this.e = element;
update();
instances.put(entity, this);
}
@ -91,7 +89,7 @@ public class HorizontalVelocityTracker {
if (GeneralMethods.isSolid(b) && (entity.getLocation().getBlock().getRelative(BlockFace.EAST, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.NORTH, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.WEST, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.SOUTH, 1).equals(b))) {
if (!ElementalAbility.isTransparent(instigator, b)) {
hasBeenDamaged = true;
ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff, launchLocation, impactLocation, abil, e));
ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff, launchLocation, impactLocation, abil));
remove();
return;
}

View file

@ -1,13 +1,8 @@
package com.projectkorra.projectkorra.waterbending;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.BloodAbility;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.util.TempPotionEffect;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.entity.Creature;
@ -18,9 +13,13 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.BloodAbility;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.util.TempPotionEffect;
public class Bloodbending extends BloodAbility {
@ -147,7 +146,7 @@ public class Bloodbending extends BloodAbility {
Vector vector = GeneralMethods.getDirection(location, GeneralMethods.getTargetedLocation(player, location.distance(target)));
vector.normalize();
entity.setVelocity(vector.multiply(throwFactor));
new HorizontalVelocityTracker(entity, player, 200, "Bloodbending", Element.AIR);
new HorizontalVelocityTracker(entity, player, 200, this);
}
remove();
}