Merge pull request #301 from Simplicitee/master

Fix display command console, Change horizontal velocity for addons
This commit is contained in:
OmniCypher 2015-11-15 17:11:45 -08:00
commit e1bbc6ea7f
7 changed files with 51 additions and 30 deletions

View file

@ -622,9 +622,9 @@ public class PKListener implements Listener {
double damage = ((e.getDistanceTraveled() - minimumDistance) < 0 ? 0 : e.getDistanceTraveled() - minimumDistance) / (e.getDifference().length()); double damage = ((e.getDistanceTraveled() - minimumDistance) < 0 ? 0 : e.getDistanceTraveled() - minimumDistance) / (e.getDifference().length());
if (damage > 0) { if (damage > 0) {
if(damage <= maxDamage) { 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 { } else {
GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), maxDamage, e.getAbility().toString()); GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), maxDamage, e.getElement(), e.getSubElement(), e.getAbility());
} }
} }
} }

View file

@ -1,8 +1,14 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import java.util.ArrayList; import com.projectkorra.projectkorra.BendingPlayer;
import java.util.Arrays; import com.projectkorra.projectkorra.Element;
import java.util.concurrent.ConcurrentHashMap; 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.Effect;
import org.bukkit.Location; import org.bukkit.Location;
@ -19,15 +25,9 @@ import org.bukkit.material.Lever;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer; import java.util.ArrayList;
import com.projectkorra.projectkorra.GeneralMethods; import java.util.Arrays;
import com.projectkorra.projectkorra.ProjectKorra; import java.util.concurrent.ConcurrentHashMap;
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;
public class AirBlast implements ConfigLoadable { public class AirBlast implements ConfigLoadable {
@ -237,9 +237,9 @@ public class AirBlast implements ConfigLoadable {
GeneralMethods.setVelocity(entity, velocity); GeneralMethods.setVelocity(entity, velocity);
if (source != null) if (source != null)
new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirBurst); new HorizontalVelocityTracker(entity, player, 200l, "AirBurst", Element.Air, null);
else else
new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirBlast); new HorizontalVelocityTracker(entity, player, 200l, "AirBlast", Element.Air, null);
entity.setFallDistance(0); entity.setFallDistance(0);
if (!isUser && entity instanceof Player) { if (!isUser && entity instanceof Player) {
new Flight((Player) entity, player); new Flight((Player) entity, player);

View file

@ -1,10 +1,10 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AvatarState; import com.projectkorra.projectkorra.ability.AvatarState;
import com.projectkorra.projectkorra.ability.StockAbility;
import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigLoadable; import com.projectkorra.projectkorra.configuration.ConfigLoadable;
import com.projectkorra.projectkorra.earthbending.EarthMethods; import com.projectkorra.projectkorra.earthbending.EarthMethods;
@ -261,7 +261,7 @@ public class AirSuction implements ConfigLoadable {
continue; continue;
} }
GeneralMethods.setVelocity(entity, velocity); GeneralMethods.setVelocity(entity, velocity);
new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirSuction); new HorizontalVelocityTracker(entity, player, 200l, "AirSuction", Element.Air, null);
entity.setFallDistance(0); entity.setFallDistance(0);
if (entity.getEntityId() != player.getEntityId() && entity instanceof Player) { if (entity.getEntityId() != player.getEntityId() && entity instanceof Player) {
new Flight((Player) entity, player); new Flight((Player) entity, player);

View file

@ -112,7 +112,11 @@ public class DisplayCommand extends PKCommand {
return; return;
} }
for (String ability : abilities) { 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); sender.sendMessage(GeneralMethods.getAvatarColor() + ability);
} }
} }

View file

@ -1,6 +1,7 @@
package com.projectkorra.projectkorra.event; 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.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -26,7 +27,9 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
private Vector difference; private Vector difference;
private Location start; private Location start;
private Location end; private Location end;
private StockAbility abil; private String abil;
private Element element;
private SubElement sub;
@Deprecated @Deprecated
public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference) { 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; 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.entity = entity;
this.instigator = instigator; this.instigator = instigator;
this.from = from; this.from = from;
@ -80,10 +83,18 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
return difference; return difference;
} }
public StockAbility getAbility() { public String getAbility() {
return abil; return abil;
} }
public Element getElement() {
return element;
}
public SubElement getSubElement() {
return sub;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View file

@ -1,8 +1,9 @@
package com.projectkorra.projectkorra.object; package com.projectkorra.projectkorra.object;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra; 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.earthbending.EarthMethods;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent; import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
import com.projectkorra.projectkorra.waterbending.WaterMethods; import com.projectkorra.projectkorra.waterbending.WaterMethods;
@ -32,11 +33,13 @@ public class HorizontalVelocityTracker {
private Vector thisVelocity; private Vector thisVelocity;
private Location launchLocation; private Location launchLocation;
private Location impactLocation; private Location impactLocation;
private StockAbility abil; private String abil;
private Element e;
private SubElement sub;
public static String[] abils = {"AirBlast", "AirBurst", "AirSuction", "Bloodbending"}; 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); remove(e);
entity = e; entity = e;
this.instigator = instigator; this.instigator = instigator;
@ -47,6 +50,8 @@ public class HorizontalVelocityTracker {
impactLocation = launchLocation.clone(); impactLocation = launchLocation.clone();
this.delay = delay; this.delay = delay;
abil = ability; abil = ability;
this.e = element;
sub = se;
update(); update();
instances.put(entity, this); 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 (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)) { if (!EarthMethods.isTransparentToEarthbending(instigator, b)) {
hasBeenDamaged = true; 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(); remove();
return; return;
} }

View file

@ -1,10 +1,11 @@
package com.projectkorra.projectkorra.waterbending; package com.projectkorra.projectkorra.waterbending;
import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.SubElement;
import com.projectkorra.projectkorra.ability.AvatarState; import com.projectkorra.projectkorra.ability.AvatarState;
import com.projectkorra.projectkorra.ability.StockAbility;
import com.projectkorra.projectkorra.airbending.AirMethods; import com.projectkorra.projectkorra.airbending.AirMethods;
import com.projectkorra.projectkorra.firebending.FireMethods; import com.projectkorra.projectkorra.firebending.FireMethods;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; 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 vector = GeneralMethods.getDirection(location, GeneralMethods.getTargetedLocation(player, location.distance(target)));
vector.normalize(); vector.normalize();
entity.setVelocity(vector.multiply(factor)); entity.setVelocity(vector.multiply(factor));
new HorizontalVelocityTracker(entity, player, 200, StockAbility.Bloodbending); new HorizontalVelocityTracker(entity, player, 200, "Bloodbending", Element.Air, SubElement.Bloodbending);
} }
remove(player); remove(player);
} }