Merge pull request #296 from Simplicitee/master

Changes
This commit is contained in:
OmniCypher 2015-11-14 11:40:48 -08:00
commit 12cf8daa60
14 changed files with 184 additions and 105 deletions

View file

@ -1,68 +1,12 @@
package com.projectkorra.projectkorra; package com.projectkorra.projectkorra;
import java.io.BufferedReader; import fr.neatmonster.nocheatplus.checks.CheckType;
import java.io.BufferedWriter; import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention; import me.ryanhamshire.GriefPrevention.GriefPrevention;
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag; import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones; import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.FallingSand;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.google.common.reflect.ClassPath; import com.google.common.reflect.ClassPath;
import com.griefcraft.lwc.LWC; import com.griefcraft.lwc.LWC;
import com.griefcraft.lwc.LWCPlugin; import com.griefcraft.lwc.LWCPlugin;
@ -128,8 +72,63 @@ import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.DefaultFlag; import com.sk89q.worldguard.protection.flags.DefaultFlag;
import fr.neatmonster.nocheatplus.checks.CheckType; import org.bukkit.Bukkit;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.FallingSand;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class GeneralMethods { public class GeneralMethods {
@ -1278,7 +1277,6 @@ public class GeneralMethods {
return null; return null;
} }
@SuppressWarnings("incomplete-switch")
public static ChatColor getSubBendingColor(Element element) { public static ChatColor getSubBendingColor(Element element) {
switch (element) { switch (element) {
case Fire: case Fire:
@ -1289,9 +1287,14 @@ public class GeneralMethods {
return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.WaterSub")); return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.WaterSub"));
case Earth: case Earth:
return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.EarthSub")); return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.EarthSub"));
} default:
return getAvatarColor(); return getAvatarColor();
} }
}
public static SubElement getSubElementByString(String sub) {
return SubElement.getType(sub);
}
@SuppressWarnings("unused") @SuppressWarnings("unused")
public static Entity getTargetedEntity(Player player, double range, List<Entity> avoid) { public static Entity getTargetedEntity(Player player, double range, List<Entity> avoid) {

View file

@ -1,6 +1,7 @@
package com.projectkorra.projectkorra; package com.projectkorra.projectkorra;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -128,6 +129,7 @@ import com.projectkorra.projectkorra.firebending.Illumination;
import com.projectkorra.projectkorra.firebending.Lightning; import com.projectkorra.projectkorra.firebending.Lightning;
import com.projectkorra.projectkorra.firebending.RingOfFire; import com.projectkorra.projectkorra.firebending.RingOfFire;
import com.projectkorra.projectkorra.firebending.WallOfFire; import com.projectkorra.projectkorra.firebending.WallOfFire;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.object.Preset; import com.projectkorra.projectkorra.object.Preset;
import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.ClickType;
@ -932,7 +934,11 @@ public class PKListener implements Listener {
} }
} }
*/ */
if (element != null) { if (HorizontalVelocityTracker.hasBeenDamagedByHorizontalVelocity(event.getEntity()) && Arrays.asList(HorizontalVelocityTracker.abils).contains(tempAbility)) {
if (ConfigManager.deathMsgConfig.get().contains("HorizontalVelocity." + tempAbility)) {
message = ConfigManager.deathMsgConfig.get().getString("HorizontalVelocity." + tempAbility);
}
} else if (element != null) {
if (ConfigManager.deathMsgConfig.get().contains(element.toString() + "." + tempAbility)) { if (ConfigManager.deathMsgConfig.get().contains(element.toString() + "." + tempAbility)) {
message = ConfigManager.deathMsgConfig.get().getString(element + "." + tempAbility); message = ConfigManager.deathMsgConfig.get().getString(element + "." + tempAbility);
} else if (ConfigManager.deathMsgConfig.get().contains("Combo." + tempAbility)) { } else if (ConfigManager.deathMsgConfig.get().contains("Combo." + tempAbility)) {

View file

@ -1,34 +1,38 @@
package com.projectkorra.projectkorra; package com.projectkorra.projectkorra;
import java.util.Arrays; import com.projectkorra.projectkorra.command.Commands;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import java.util.Arrays;
public enum SubElement { public enum SubElement {
//Air //Air
Flight (Element.Air), Flight (Element.Air, Commands.flightaliases),
SpiritualProjection (Element.Air), SpiritualProjection (Element.Air, Commands.spiritualprojectionaliases),
//Water //Water
Bloodbending (Element.Water), Bloodbending (Element.Water, Commands.bloodaliases),
Healing (Element.Water), Healing (Element.Water, Commands.healingaliases),
Icebending (Element.Water), Icebending (Element.Water, Commands.icealiases),
Plantbending (Element.Water), Plantbending (Element.Water, Commands.plantaliases),
// Earth // Earth
Metalbending (Element.Earth), Metalbending (Element.Earth, Commands.metalbendingaliases),
Sandbending (Element.Earth), Sandbending (Element.Earth, Commands.sandbendingaliases),
Lavabending (Element.Earth), Lavabending (Element.Earth, Commands.lavabendingaliases),
// Fire // Fire
Combustion (Element.Fire), Combustion (Element.Fire, Commands.combustionaliases),
Lightning (Element.Fire); Lightning (Element.Fire, Commands.lightningaliases);
private Element element; private Element element;
private String[] aliases;
SubElement(Element mainElement) { SubElement(Element mainElement, String[] aliases) {
this.element = mainElement; this.element = mainElement;
this.aliases = aliases;
} }
/**Returns the main element associated with the subelement /**Returns the main element associated with the subelement
@ -45,7 +49,7 @@ public enum SubElement {
public static SubElement getType(String string) { public static SubElement getType(String string) {
for (SubElement se : SubElement.values()) { for (SubElement se : SubElement.values()) {
if (se.toString().equalsIgnoreCase(string)) { if (Arrays.asList(se.aliases).contains(string.toLowerCase())) {
return se; return se;
} }
} }

View file

@ -92,6 +92,10 @@ public enum StockAbility {
WaterArms; WaterArms;
} }
public enum AvatarAbilities {
AvatarState;
}
public static boolean isFlightAbility(String ability) { public static boolean isFlightAbility(String ability) {
for (FlightAbilities a : FlightAbilities.values()) for (FlightAbilities a : FlightAbilities.values())
if (a.name().equalsIgnoreCase(ability)) if (a.name().equalsIgnoreCase(ability))

View file

@ -23,6 +23,7 @@ import com.projectkorra.projectkorra.BendingPlayer;
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.object.HorizontalVelocityTracker; import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
@ -72,7 +73,6 @@ public class AirBlast implements ConfigLoadable {
private ArrayList<Block> affectedlevers = new ArrayList<Block>(); private ArrayList<Block> affectedlevers = new ArrayList<Block>();
private ArrayList<Entity> affectedentities = new ArrayList<Entity>(); private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
@SuppressWarnings("unused")
private AirBurst source = null; private AirBurst source = null;
public AirBlast(Location location, Vector direction, Player player, double factorpush, AirBurst burst) { public AirBlast(Location location, Vector direction, Player player, double factorpush, AirBurst burst) {
@ -236,7 +236,10 @@ public class AirBlast implements ConfigLoadable {
return; return;
GeneralMethods.setVelocity(entity, velocity); GeneralMethods.setVelocity(entity, velocity);
new HorizontalVelocityTracker(entity, player, 200l); if (source != null)
new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirBurst);
else
new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirBlast);
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,7 +1,9 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import java.util.ArrayList; import com.projectkorra.projectkorra.GeneralMethods;
import java.util.concurrent.ConcurrentHashMap; import com.projectkorra.projectkorra.configuration.ConfigLoadable;
import com.projectkorra.projectkorra.util.Flight;
import com.projectkorra.projectkorra.waterbending.WaterMethods;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -10,9 +12,8 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.GeneralMethods; import java.util.ArrayList;
import com.projectkorra.projectkorra.configuration.ConfigLoadable; import java.util.concurrent.ConcurrentHashMap;
import com.projectkorra.projectkorra.util.Flight;
public class AirScooter implements ConfigLoadable { public class AirScooter implements ConfigLoadable {
@ -155,7 +156,10 @@ public class AirScooter implements ConfigLoadable {
velocity.setY(0); velocity.setY(0);
} }
Location loc = player.getLocation(); Location loc = player.getLocation();
if (!WaterMethods.isWater(player.getLocation().add(0, 2, 0).getBlock()))
loc.setY((double) floorblock.getY() + 1.5); loc.setY((double) floorblock.getY() + 1.5);
else
return false;
// player.setFlying(true); // player.setFlying(true);
// player.teleport(loc.add(velocity)); // player.teleport(loc.add(velocity));
player.setSprinting(false); player.setSprinting(false);

View file

@ -1,7 +1,16 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import java.util.ArrayList; import com.projectkorra.projectkorra.BendingPlayer;
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.ability.StockAbility;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigLoadable;
import com.projectkorra.projectkorra.earthbending.EarthMethods;
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.Effect;
import org.bukkit.Location; import org.bukkit.Location;
@ -9,16 +18,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer; import java.util.ArrayList;
import com.projectkorra.projectkorra.GeneralMethods; import java.util.concurrent.ConcurrentHashMap;
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.earthbending.EarthMethods;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.util.Flight;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
public class AirSuction implements ConfigLoadable { public class AirSuction implements ConfigLoadable {
@ -260,7 +261,7 @@ public class AirSuction implements ConfigLoadable {
continue; continue;
} }
GeneralMethods.setVelocity(entity, velocity); GeneralMethods.setVelocity(entity, velocity);
new HorizontalVelocityTracker(entity, player, 200l); new HorizontalVelocityTracker(entity, player, 200l, StockAbility.AirSuction);
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

@ -36,6 +36,7 @@ public class Commands {
public static String[] firealiases = { "fire", "f", "firebending", "firebender" }; public static String[] firealiases = { "fire", "f", "firebending", "firebender" };
public static String[] wateraliases = { "water", "w", "waterbending", "waterbender" }; public static String[] wateraliases = { "water", "w", "waterbending", "waterbender" };
public static String[] elementaliases = { "air", "a", "airbending", "airbender", "chi", "c", "chiblocking", "chiblocker", "earth", "e", "earthbending", "earthbender", "fire", "f", "firebending", "firebender", "water", "w", "waterbending", "waterbender" }; public static String[] elementaliases = { "air", "a", "airbending", "airbender", "chi", "c", "chiblocking", "chiblocker", "earth", "e", "earthbending", "earthbender", "fire", "f", "firebending", "firebender", "water", "w", "waterbending", "waterbender" };
public static String[] avataraliases = { "avatar", "av", "avy", "aang", "korra" };
/* /*
* Combo Aliases * Combo Aliases

View file

@ -5,6 +5,7 @@ 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.SubElement;
import com.projectkorra.projectkorra.ability.AbilityModuleManager;
import com.projectkorra.projectkorra.ability.combo.ComboManager; import com.projectkorra.projectkorra.ability.combo.ComboManager;
import com.projectkorra.projectkorra.airbending.AirMethods; import com.projectkorra.projectkorra.airbending.AirMethods;
import com.projectkorra.projectkorra.chiblocking.ChiMethods; import com.projectkorra.projectkorra.chiblocking.ChiMethods;
@ -68,6 +69,11 @@ public class DisplayCommand extends PKCommand {
displaySubElement(sender, element); displaySubElement(sender, element);
} }
//avatar
else if (Arrays.asList(Commands.avataraliases).contains(element)) {
displayAvatar(sender);
}
else { else {
ChatColor w = ChatColor.WHITE; ChatColor w = ChatColor.WHITE;
sender.sendMessage(ChatColor.RED + "Not a valid argument." + ChatColor.WHITE + "\nElements: " + AirMethods.getAirColor() + "Air" + ChatColor.WHITE + " | " + WaterMethods.getWaterColor() + "Water" + ChatColor.WHITE + " | " + EarthMethods.getEarthColor() + "Earth" + ChatColor.WHITE + " | " + FireMethods.getFireColor() + "Fire" + ChatColor.WHITE + " | " + ChiMethods.getChiColor() + "Chi"); sender.sendMessage(ChatColor.RED + "Not a valid argument." + ChatColor.WHITE + "\nElements: " + AirMethods.getAirColor() + "Air" + ChatColor.WHITE + " | " + WaterMethods.getWaterColor() + "Water" + ChatColor.WHITE + " | " + EarthMethods.getEarthColor() + "Earth" + ChatColor.WHITE + " | " + FireMethods.getFireColor() + "Fire" + ChatColor.WHITE + " | " + ChiMethods.getChiColor() + "Chi");
@ -94,6 +100,24 @@ public class DisplayCommand extends PKCommand {
} }
} }
private void displayAvatar(CommandSender sender) {
List<String> abilities = new ArrayList<>();
for (String ability : AbilityModuleManager.abilities) {
if (!AbilityModuleManager.airbendingabilities.contains(ability) && !AbilityModuleManager.earthbendingabilities.contains(ability) && !AbilityModuleManager.firebendingabilities.contains(ability) && !AbilityModuleManager.waterbendingabilities.contains(ability) && !AbilityModuleManager.chiabilities.contains(ability)) {
abilities.add(ability);
}
}
if (abilities.isEmpty()) {
sender.sendMessage(ChatColor.YELLOW + "There are no " + GeneralMethods.getAvatarColor() + "avatar" + ChatColor.YELLOW + " abilities on this server!");
return;
}
for (String ability : abilities) {
if (GeneralMethods.canView((Player) sender, ability)) {
sender.sendMessage(GeneralMethods.getAvatarColor() + ability);
}
}
}
/** /**
* Displays the enabled moves for the given element to the CommandSender. * Displays the enabled moves for the given element to the CommandSender.
* *

View file

@ -67,6 +67,11 @@ public class ConfigManager {
config.addDefault("Combo.FireWheel", "{victim} was incinerated by {attacker}'s {ability}"); config.addDefault("Combo.FireWheel", "{victim} was incinerated by {attacker}'s {ability}");
config.addDefault("Combo.IceBullets", "{victim}'s heart was frozen by {attacker}'s {ability}"); config.addDefault("Combo.IceBullets", "{victim}'s heart was frozen by {attacker}'s {ability}");
config.addDefault("HorizontalVelocity.AirBlast","{victim} experienced kinetic damage by {attacker}'s {ability}");
config.addDefault("HorizontalVelocity.AirBurst","{victim} experienced kinetic damage by {attacker}'s {ability}");
config.addDefault("HorizontalVelocity.AirSuction","{victim} experienced kinetic damage by {attacker}'s {ability}");
config.addDefault("HorizontalVelocity.Bloodbending","{victim} experienced kinetic damage by {attacker}'s {ability}");
deathMsgConfig.save(); deathMsgConfig.save();
break; break;
case DEFAULT: case DEFAULT:

View file

@ -1,5 +1,7 @@
package com.projectkorra.projectkorra.event; package com.projectkorra.projectkorra.event;
import com.projectkorra.projectkorra.ability.StockAbility;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -12,6 +14,7 @@ import org.bukkit.util.Vector;
* Created by Carbogen on 2/2/2015. * Created by Carbogen on 2/2/2015.
*/ */
public class HorizontalVelocityChangeEvent extends Event implements Cancellable { public class HorizontalVelocityChangeEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private boolean isCancelled; private boolean isCancelled;
@ -23,6 +26,7 @@ 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;
@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) {
@ -33,7 +37,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) { public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference, Location start, Location end, StockAbility ability ) {
this.entity = entity; this.entity = entity;
this.instigator = instigator; this.instigator = instigator;
this.from = from; this.from = from;
@ -41,6 +45,7 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
this.difference = difference; this.difference = difference;
this.start = start; this.start = start;
this.end = end; this.end = end;
abil = ability;
} }
public Entity getEntity() { public Entity getEntity() {
@ -75,6 +80,10 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
return difference; return difference;
} }
public StockAbility getAbility() {
return abil;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View file

@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.object;
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.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;
@ -20,8 +21,9 @@ import java.util.concurrent.ConcurrentHashMap;
* Created by Carbogen on 2/2/2015. * Created by Carbogen on 2/2/2015.
*/ */
public class HorizontalVelocityTracker { public class HorizontalVelocityTracker {
public static ConcurrentHashMap<Entity, HorizontalVelocityTracker> instances = new ConcurrentHashMap<Entity, HorizontalVelocityTracker>();
public static ConcurrentHashMap<Entity, HorizontalVelocityTracker> instances = new ConcurrentHashMap<Entity, HorizontalVelocityTracker>();
public boolean hasBeenDamaged = false;
private long delay; private long delay;
private long fireTime; private long fireTime;
private Entity entity; private Entity entity;
@ -30,8 +32,11 @@ public class HorizontalVelocityTracker {
private Vector thisVelocity; private Vector thisVelocity;
private Location launchLocation; private Location launchLocation;
private Location impactLocation; private Location impactLocation;
private StockAbility abil;
public HorizontalVelocityTracker(Entity e, Player instigator, long delay) { public static String[] abils = {"AirBlast", "AirBurst", "AirSuction", "Bloodbending"};
public HorizontalVelocityTracker(Entity e, Player instigator, long delay, StockAbility ability) {
remove(e); remove(e);
entity = e; entity = e;
this.instigator = instigator; this.instigator = instigator;
@ -41,6 +46,7 @@ public class HorizontalVelocityTracker {
launchLocation = e.getLocation().clone(); launchLocation = e.getLocation().clone();
impactLocation = launchLocation.clone(); impactLocation = launchLocation.clone();
this.delay = delay; this.delay = delay;
abil = ability;
update(); update();
instances.put(entity, this); instances.put(entity, this);
} }
@ -70,7 +76,8 @@ public class HorizontalVelocityTracker {
for (Block b : blocks) { for (Block b : blocks) {
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)) {
ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff, launchLocation, impactLocation)); ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff, launchLocation, impactLocation, abil));
hasBeenDamaged = true;
remove(); remove();
return; return;
} }
@ -93,4 +100,11 @@ public class HorizontalVelocityTracker {
if (instances.containsKey(e)) if (instances.containsKey(e))
instances.remove(e); instances.remove(e);
} }
public static boolean hasBeenDamagedByHorizontalVelocity(Entity e) {
if (instances.containsKey(e)) {
return instances.get(e).hasBeenDamaged;
}
return false;
}
} }

View file

@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.BendingPlayer;
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.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;
@ -117,7 +118,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); new HorizontalVelocityTracker(entity, player, 200, StockAbility.Bloodbending);
} }
remove(player); remove(player);
} }

View file

@ -146,7 +146,7 @@ public class OctopusForm {
double knock = AvatarState.isAvatarState(player) ? AvatarState.getValue(knockback) : knockback; double knock = AvatarState.isAvatarState(player) ? AvatarState.getValue(knockback) : knockback;
entity.setVelocity(GeneralMethods.getDirection(player.getLocation(), location).normalize().multiply(knock)); entity.setVelocity(GeneralMethods.getDirection(player.getLocation(), location).normalize().multiply(knock));
if (entity instanceof LivingEntity) if (entity instanceof LivingEntity)
GeneralMethods.damageEntity(player, entity, damage, "OctoposForm"); GeneralMethods.damageEntity(player, entity, damage, "OctopusForm");
AirMethods.breakBreathbendingHold(entity); AirMethods.breakBreathbendingHold(entity);
} }
} }