diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index 432d75a7..ed29ab5f 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -622,9 +622,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().toString()); + GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), damage, e.getElement(), e.getSubElement(), e.getAbility()); } else { - GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), maxDamage, e.getAbility().toString()); + GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), maxDamage, e.getElement(), e.getSubElement(), e.getAbility()); } } } diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java index 4e2d74d3..fae8c571 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java @@ -1,8 +1,14 @@ package com.projectkorra.projectkorra.airbending; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.concurrent.ConcurrentHashMap; +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.AvatarState; +import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.ConfigLoadable; +import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; +import com.projectkorra.projectkorra.util.Flight; import org.bukkit.Effect; import org.bukkit.Location; @@ -19,15 +25,9 @@ import org.bukkit.material.Lever; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; -import com.projectkorra.projectkorra.BendingPlayer; -import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.AvatarState; -import com.projectkorra.projectkorra.ability.StockAbility; -import com.projectkorra.projectkorra.command.Commands; -import com.projectkorra.projectkorra.configuration.ConfigLoadable; -import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; -import com.projectkorra.projectkorra.util.Flight; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.concurrent.ConcurrentHashMap; public class AirBlast implements ConfigLoadable { @@ -237,9 +237,9 @@ public class AirBlast implements ConfigLoadable { GeneralMethods.setVelocity(entity, velocity); if (source != null) - new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirBurst); + new HorizontalVelocityTracker(entity, player, 200l, "AirBurst", Element.Air, null); else - new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirBlast); + new HorizontalVelocityTracker(entity, player, 200l, "AirBlast", Element.Air, null); entity.setFallDistance(0); if (!isUser && entity instanceof Player) { new Flight((Player) entity, player); diff --git a/src/com/projectkorra/projectkorra/airbending/AirSuction.java b/src/com/projectkorra/projectkorra/airbending/AirSuction.java index c90530bc..fbe30134 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSuction.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSuction.java @@ -1,10 +1,10 @@ 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.AvatarState; -import com.projectkorra.projectkorra.ability.StockAbility; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.ConfigLoadable; import com.projectkorra.projectkorra.earthbending.EarthMethods; @@ -261,7 +261,7 @@ public class AirSuction implements ConfigLoadable { continue; } GeneralMethods.setVelocity(entity, velocity); - new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirSuction); + new HorizontalVelocityTracker(entity, player, 200l, "AirSuction", Element.Air, null); entity.setFallDistance(0); if (entity.getEntityId() != player.getEntityId() && entity instanceof Player) { new Flight((Player) entity, player); diff --git a/src/com/projectkorra/projectkorra/command/DisplayCommand.java b/src/com/projectkorra/projectkorra/command/DisplayCommand.java index 50525502..46acf05b 100644 --- a/src/com/projectkorra/projectkorra/command/DisplayCommand.java +++ b/src/com/projectkorra/projectkorra/command/DisplayCommand.java @@ -112,10 +112,14 @@ public class DisplayCommand extends PKCommand { return; } for (String ability : abilities) { - if (GeneralMethods.canView((Player) sender, ability)) { + if (sender instanceof Player) { + if (GeneralMethods.canView((Player) sender, ability)) { + sender.sendMessage(GeneralMethods.getAvatarColor() + ability); + } + } else { sender.sendMessage(GeneralMethods.getAvatarColor() + ability); } - } + } } /** diff --git a/src/com/projectkorra/projectkorra/event/HorizontalVelocityChangeEvent.java b/src/com/projectkorra/projectkorra/event/HorizontalVelocityChangeEvent.java index cef182bc..76a8ca80 100644 --- a/src/com/projectkorra/projectkorra/event/HorizontalVelocityChangeEvent.java +++ b/src/com/projectkorra/projectkorra/event/HorizontalVelocityChangeEvent.java @@ -1,6 +1,7 @@ package com.projectkorra.projectkorra.event; -import com.projectkorra.projectkorra.ability.StockAbility; +import com.projectkorra.projectkorra.Element; +import com.projectkorra.projectkorra.SubElement; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -26,7 +27,9 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable private Vector difference; private Location start; private Location end; - private StockAbility abil; + private String abil; + private Element element; + private SubElement sub; @Deprecated public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference) { @@ -37,7 +40,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, StockAbility ability ) { + public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference, Location start, Location end, String ability, Element element, SubElement sub) { this.entity = entity; this.instigator = instigator; this.from = from; @@ -80,9 +83,17 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable return difference; } - public StockAbility getAbility() { + public String getAbility() { return abil; } + + public Element getElement() { + return element; + } + + public SubElement getSubElement() { + return sub; + } @Override public HandlerList getHandlers() { diff --git a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java index 4b58e40b..91402e4d 100644 --- a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java +++ b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java @@ -1,8 +1,9 @@ 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.StockAbility; +import com.projectkorra.projectkorra.SubElement; import com.projectkorra.projectkorra.earthbending.EarthMethods; import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent; import com.projectkorra.projectkorra.waterbending.WaterMethods; @@ -32,11 +33,13 @@ public class HorizontalVelocityTracker { private Vector thisVelocity; private Location launchLocation; private Location impactLocation; - private StockAbility abil; + private String abil; + private Element e; + private SubElement sub; public static String[] abils = {"AirBlast", "AirBurst", "AirSuction", "Bloodbending"}; - public HorizontalVelocityTracker(Entity e, Player instigator, long delay, StockAbility ability) { + public HorizontalVelocityTracker(Entity e, Player instigator, long delay, String ability, Element element, SubElement se) { remove(e); entity = e; this.instigator = instigator; @@ -47,6 +50,8 @@ public class HorizontalVelocityTracker { impactLocation = launchLocation.clone(); this.delay = delay; abil = ability; + this.e = element; + sub = se; update(); instances.put(entity, this); } @@ -77,7 +82,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 (!EarthMethods.isTransparentToEarthbending(instigator, b)) { hasBeenDamaged = true; - ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff, launchLocation, impactLocation, abil)); + ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff, launchLocation, impactLocation, abil, e, sub)); remove(); return; } diff --git a/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java b/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java index 38848562..1ea67aea 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java +++ b/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java @@ -1,10 +1,11 @@ package com.projectkorra.projectkorra.waterbending; import com.projectkorra.projectkorra.BendingPlayer; +import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; +import com.projectkorra.projectkorra.SubElement; import com.projectkorra.projectkorra.ability.AvatarState; -import com.projectkorra.projectkorra.ability.StockAbility; import com.projectkorra.projectkorra.airbending.AirMethods; import com.projectkorra.projectkorra.firebending.FireMethods; import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; @@ -118,7 +119,7 @@ public class Bloodbending { Vector vector = GeneralMethods.getDirection(location, GeneralMethods.getTargetedLocation(player, location.distance(target))); vector.normalize(); entity.setVelocity(vector.multiply(factor)); - new HorizontalVelocityTracker(entity, player, 200, StockAbility.Bloodbending); + new HorizontalVelocityTracker(entity, player, 200, "Bloodbending", Element.Air, SubElement.Bloodbending); } remove(player); }