mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-09-11 12:49:32 +00:00
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:
parent
4f4335e498
commit
c0fe8256b7
|
@ -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
|
* Damages an Entity by amount of damage specified. Starts a
|
||||||
* {@link EntityDamageByEntityEvent}.
|
* {@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 entity The entity that is receiving the damage
|
||||||
* @param damage The amount of damage to deal
|
* @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) {
|
public static void damageEntity(Ability ability, Entity entity, double damage) {
|
||||||
AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, CoreAbility.getAbility(player, CoreAbility.getAbility(ability).getClass()), damage);
|
if (ability==null)
|
||||||
|
return;
|
||||||
|
Player player = ability.getPlayer();
|
||||||
|
AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, ability, damage);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(damageEvent);
|
Bukkit.getServer().getPluginManager().callEvent(damageEvent);
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
if (entity instanceof Player && Commands.invincible.contains(entity.getName())) {
|
if (entity instanceof Player && Commands.invincible.contains(entity.getName())) {
|
||||||
|
@ -371,7 +368,7 @@ public class GeneralMethods {
|
||||||
NCPExemptionManager.exemptPermanently(player, CheckType.FIGHT_REACH);
|
NCPExemptionManager.exemptPermanently(player, CheckType.FIGHT_REACH);
|
||||||
}
|
}
|
||||||
if (((LivingEntity) entity).getHealth() - damage <= 0 && !entity.isDead()) {
|
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);
|
Bukkit.getServer().getPluginManager().callEvent(deathEvent);
|
||||||
}
|
}
|
||||||
((LivingEntity) entity).damage(damage, player);
|
((LivingEntity) entity).damage(damage, player);
|
||||||
|
|
|
@ -1,5 +1,68 @@
|
||||||
package com.projectkorra.projectkorra;
|
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.AddonAbility;
|
||||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||||
import com.projectkorra.projectkorra.ability.ChiAbility;
|
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.WaterSpout;
|
||||||
import com.projectkorra.projectkorra.waterbending.WaterSpoutWave;
|
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 {
|
public class PKListener implements Listener {
|
||||||
|
|
||||||
ProjectKorra plugin;
|
ProjectKorra plugin;
|
||||||
|
@ -698,9 +699,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());
|
GeneralMethods.damageEntity(e.getAbility(), e.getEntity(), damage);
|
||||||
} else {
|
} 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)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerBendingDeath(EntityBendingDeathEvent event) {
|
public void onPlayerBendingDeath(EntityBendingDeathEvent event) {
|
||||||
if (ConfigManager.deathMsgConfig.get().getBoolean("Properties.Enabled") && event.getVictim() instanceof Player) {
|
if (ConfigManager.deathMsgConfig.get().getBoolean("Properties.Enabled") && event.getEntity() instanceof Player) {
|
||||||
CoreAbility ability = CoreAbility.getAbility(event.getAbility());
|
Ability ability = event.getAbility();
|
||||||
|
|
||||||
if (ability == null) {
|
if (ability == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -740,8 +741,8 @@ public class PKListener implements Listener {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(ability.getElement().getColor());
|
sb.append(ability.getElement().getColor());
|
||||||
sb.append(event.getAbility());
|
sb.append(event.getAbility());
|
||||||
BENDING_PLAYER_DEATH.put((Player) event.getVictim(), sb.toString());
|
BENDING_PLAYER_DEATH.put((Player) event.getEntity(), sb.toString());
|
||||||
final Player player = (Player) event.getVictim();
|
final Player player = (Player) event.getEntity();
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -849,7 +850,7 @@ public class PKListener implements Listener {
|
||||||
Player source = Flight.getLaunchedBy(player);
|
Player source = Flight.getLaunchedBy(player);
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
GeneralMethods.damageEntity(source, player, event.getDamage(), null);
|
GeneralMethods.damageEntity(null, player, event.getDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
package com.projectkorra.projectkorra.airbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import java.util.ArrayList;
|
||||||
import com.projectkorra.projectkorra.Element;
|
import java.util.Arrays;
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import java.util.Random;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
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 org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -25,10 +20,14 @@ 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 java.util.ArrayList;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import java.util.Arrays;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import java.util.Random;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
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 {
|
public class AirBlast extends AirAbility {
|
||||||
|
|
||||||
|
@ -237,9 +236,9 @@ public class AirBlast extends AirAbility {
|
||||||
|
|
||||||
GeneralMethods.setVelocity(entity, velocity);
|
GeneralMethods.setVelocity(entity, velocity);
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
new HorizontalVelocityTracker(entity, player, 200l, "AirBurst", Element.AIR);
|
new HorizontalVelocityTracker(entity, player, 200l, this);
|
||||||
} else {
|
} else {
|
||||||
new HorizontalVelocityTracker(entity, player, 200l, "AirBlast", Element.AIR);
|
new HorizontalVelocityTracker(entity, player, 200l, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setFallDistance(0);
|
entity.setFallDistance(0);
|
||||||
|
@ -254,7 +253,7 @@ public class AirBlast extends AirAbility {
|
||||||
breakBreathbendingHold(entity);
|
breakBreathbendingHold(entity);
|
||||||
|
|
||||||
if (source != null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(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);
|
affectedEntities.add(entity);
|
||||||
} else if (source == null && (damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(entity))) {
|
} else if (source == null && (damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(entity))) {
|
||||||
GeneralMethods.damageEntity(this, entity, damage);
|
GeneralMethods.damageEntity(this, entity, damage);
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
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.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.AirAbility;
|
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.util.Flight;
|
||||||
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
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 {
|
public class AirSuction extends AirAbility {
|
||||||
|
|
||||||
private static final int MAX_TICKS = 10000;
|
private static final int MAX_TICKS = 10000;
|
||||||
|
@ -200,7 +199,7 @@ public class AirSuction extends AirAbility {
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralMethods.setVelocity(entity, velocity);
|
GeneralMethods.setVelocity(entity, velocity);
|
||||||
new HorizontalVelocityTracker(entity, player, 200l, "AirSuction", Element.AIR);
|
new HorizontalVelocityTracker(entity, player, 200l, this);
|
||||||
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);
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class AirSwipe extends AirAbility {
|
||||||
private double maxChargeFactor;
|
private double maxChargeFactor;
|
||||||
private Location origin;
|
private Location origin;
|
||||||
private Random random;
|
private Random random;
|
||||||
|
private AirSwipe ability;
|
||||||
private ConcurrentHashMap<Vector, Location> elements;
|
private ConcurrentHashMap<Vector, Location> elements;
|
||||||
private ArrayList<Entity> affectedEntities;
|
private ArrayList<Entity> affectedEntities;
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ public class AirSwipe extends AirAbility {
|
||||||
public AirSwipe(Player player, boolean charging) {
|
public AirSwipe(Player player, boolean charging) {
|
||||||
super(player);
|
super(player);
|
||||||
|
|
||||||
|
ability = this;
|
||||||
this.charging = charging;
|
this.charging = charging;
|
||||||
this.origin = player.getEyeLocation();
|
this.origin = player.getEyeLocation();
|
||||||
this.charging = false;
|
this.charging = false;
|
||||||
|
@ -194,7 +196,7 @@ public class AirSwipe extends AirAbility {
|
||||||
}
|
}
|
||||||
if (entity instanceof LivingEntity && !affectedEntities.contains(entity)) {
|
if (entity instanceof LivingEntity && !affectedEntities.contains(entity)) {
|
||||||
if (damage != 0) {
|
if (damage != 0) {
|
||||||
GeneralMethods.damageEntity(player, entity, damage, "AirSwipe");
|
GeneralMethods.damageEntity(ability, entity, damage);
|
||||||
}
|
}
|
||||||
affectedEntities.add(entity);
|
affectedEntities.add(entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.projectkorra.projectkorra.airbending;
|
package com.projectkorra.projectkorra.airbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import java.util.ArrayList;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import java.util.List;
|
||||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
|
||||||
import com.projectkorra.projectkorra.avatar.AvatarState;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
@ -13,8 +11,10 @@ import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import java.util.List;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
|
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||||
|
import com.projectkorra.projectkorra.avatar.AvatarState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suffocate
|
* Suffocate
|
||||||
|
@ -50,11 +50,13 @@ public class Suffocate extends AirAbility {
|
||||||
private double blindDelay;
|
private double blindDelay;
|
||||||
private double blindRepeat;
|
private double blindRepeat;
|
||||||
private double animationSpeed;
|
private double animationSpeed;
|
||||||
|
private Suffocate ability;
|
||||||
private ArrayList<BukkitRunnable> tasks;
|
private ArrayList<BukkitRunnable> tasks;
|
||||||
private ArrayList<LivingEntity> targets;
|
private ArrayList<LivingEntity> targets;
|
||||||
|
|
||||||
public Suffocate(Player player) {
|
public Suffocate(Player player) {
|
||||||
super(player);
|
super(player);
|
||||||
|
ability = this;
|
||||||
if (bPlayer.isOnCooldown(this)) {
|
if (bPlayer.isOnCooldown(this)) {
|
||||||
return;
|
return;
|
||||||
} else if (hasAbility(player, Suffocate.class)) {
|
} else if (hasAbility(player, Suffocate.class)) {
|
||||||
|
@ -189,13 +191,12 @@ public class Suffocate extends AirAbility {
|
||||||
return;
|
return;
|
||||||
} else if (!started) {
|
} else if (!started) {
|
||||||
started = true;
|
started = true;
|
||||||
final Player fplayer = player;
|
|
||||||
for (LivingEntity targ : targets) {
|
for (LivingEntity targ : targets) {
|
||||||
final LivingEntity target = targ;
|
final LivingEntity target = targ;
|
||||||
BukkitRunnable br1 = new BukkitRunnable() {
|
BukkitRunnable br1 = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GeneralMethods.damageEntity(fplayer, target, damage, "Suffocate");
|
GeneralMethods.damageEntity(ability, target, damage);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
BukkitRunnable br2 = new BukkitRunnable() {
|
BukkitRunnable br2 = new BukkitRunnable() {
|
||||||
|
|
|
@ -550,7 +550,7 @@ public class EarthSmash extends EarthAbility {
|
||||||
if (entity instanceof LivingEntity && entity != player && !affectedEntities.contains(entity)) {
|
if (entity instanceof LivingEntity && entity != player && !affectedEntities.contains(entity)) {
|
||||||
affectedEntities.add(entity);
|
affectedEntities.add(entity);
|
||||||
double damage = currentBlocks.size() / 13.0 * this.damage;
|
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());
|
Vector travelVec = GeneralMethods.getDirection(location, entity.getLocation());
|
||||||
entity.setVelocity(travelVec.setY(knockup).normalize().multiply(knockback));
|
entity.setVelocity(travelVec.setY(knockup).normalize().multiply(knockback));
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class LavaSurge extends LavaAbility {
|
||||||
for(Entity e : GeneralMethods.getEntitiesAroundPoint(fb.getLocation(), 2)) {
|
for(Entity e : GeneralMethods.getEntitiesAroundPoint(fb.getLocation(), 2)) {
|
||||||
if(e instanceof LivingEntity) {
|
if(e instanceof LivingEntity) {
|
||||||
if(e.getEntityId() != player.getEntityId()) {
|
if(e.getEntityId() != player.getEntityId()) {
|
||||||
GeneralMethods.damageEntity(player, e, impactDamage, "LavaSurge");
|
GeneralMethods.damageEntity(this, e, impactDamage);
|
||||||
e.setFireTicks(100);
|
e.setFireTicks(100);
|
||||||
GeneralMethods.setVelocity(e, direction.clone());
|
GeneralMethods.setVelocity(e, direction.clone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.projectkorra.projectkorra.event;
|
package com.projectkorra.projectkorra.event;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -8,17 +9,14 @@ import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
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}
|
* Called when an entity is killed by {@link GeneralMethods#damageEntity(Player player, Entity entity, double damage, String ability) GeneralMethods.damageEntity}
|
||||||
*
|
|
||||||
* @author kingbirdy
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EntityBendingDeathEvent extends Event {
|
public class EntityBendingDeathEvent extends Event {
|
||||||
|
|
||||||
public static final HandlerList handlers = new HandlerList();
|
public static final HandlerList handlers = new HandlerList();
|
||||||
private Entity victim;
|
private Entity entity;
|
||||||
private Player attacker;
|
private Ability ability;
|
||||||
private String ability;
|
|
||||||
private double damage;
|
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 damage the amount of damage done in the attack that killed the victim
|
||||||
* @param ability the ability used to kill the victim
|
* @param ability the ability used to kill the victim
|
||||||
*/
|
*/
|
||||||
public EntityBendingDeathEvent(Entity victim, Player attacker, double damage, String ability) {
|
public EntityBendingDeathEvent(Entity entity, double damage, Ability ability) {
|
||||||
this.victim = victim;
|
this.entity = entity;
|
||||||
this.attacker = attacker;
|
|
||||||
this.ability = ability;
|
this.ability = ability;
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the player who was killed
|
* @return the entity that was killed
|
||||||
*/
|
*/
|
||||||
public Entity getVictim() {
|
public Entity getEntity() {
|
||||||
return victim;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the player who killed the victim
|
* @return the player who killed the entity
|
||||||
*/
|
*/
|
||||||
public Player getAttacker() {
|
public Player getAttacker() {
|
||||||
return attacker;
|
return ability.getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the ability used to kill the victim
|
* @return the ability used to kill the victim
|
||||||
*/
|
*/
|
||||||
public String getAbility() {
|
public Ability getAbility() {
|
||||||
return ability;
|
return ability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.projectkorra.projectkorra.event;
|
package com.projectkorra.projectkorra.event;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -10,6 +8,8 @@ import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Carbogen on 2/2/2015.
|
* Created by Carbogen on 2/2/2015.
|
||||||
*/
|
*/
|
||||||
|
@ -26,8 +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 String abil;
|
private Ability abil;
|
||||||
private Element element;
|
|
||||||
|
|
||||||
@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) {
|
||||||
|
@ -38,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, 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.entity = entity;
|
||||||
this.instigator = instigator;
|
this.instigator = instigator;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
|
@ -47,7 +46,6 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
abil = ability;
|
abil = ability;
|
||||||
this.element = element;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity getEntity() {
|
public Entity getEntity() {
|
||||||
|
@ -85,14 +83,10 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
|
||||||
return difference;
|
return difference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAbility() {
|
public Ability getAbility() {
|
||||||
return abil;
|
return abil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element getElement() {
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class FireBlastCharged extends FireAbility {
|
||||||
if (distance > damageRadius) {
|
if (distance > damageRadius) {
|
||||||
return;
|
return;
|
||||||
} else if (distance < innerRadius) {
|
} else if (distance < innerRadius) {
|
||||||
GeneralMethods.damageEntity(player, entity, maxDamage, "FireBlast");
|
GeneralMethods.damageEntity(this, entity, maxDamage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class FireDamageTimer {
|
||||||
LivingEntity Lentity = (LivingEntity) entity;
|
LivingEntity Lentity = (LivingEntity) entity;
|
||||||
Player source = INSTANCES.get(entity);
|
Player source = INSTANCES.get(entity);
|
||||||
if (Lentity.getHealth() - DAMAGE <= 0 && !entity.isDead()) {
|
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);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
package com.projectkorra.projectkorra.object;
|
package com.projectkorra.projectkorra.object;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
import java.util.List;
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
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 org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -16,8 +11,13 @@ 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 java.util.List;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
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.
|
* Created by Carbogen on 2/2/2015.
|
||||||
|
@ -35,12 +35,11 @@ public class HorizontalVelocityTracker {
|
||||||
private Vector thisVelocity;
|
private Vector thisVelocity;
|
||||||
private Location launchLocation;
|
private Location launchLocation;
|
||||||
private Location impactLocation;
|
private Location impactLocation;
|
||||||
private String abil;
|
private Ability abil;
|
||||||
private Element e;
|
|
||||||
|
|
||||||
public static String[] abils = {"AirBlast", "AirBurst", "AirSuction", "Bloodbending"};
|
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"))
|
if (!ProjectKorra.plugin.getConfig().getBoolean("Properties.HorizontalCollisionPhysics.Enabled"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -54,7 +53,6 @@ public class HorizontalVelocityTracker {
|
||||||
impactLocation = launchLocation.clone();
|
impactLocation = launchLocation.clone();
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
abil = ability;
|
abil = ability;
|
||||||
this.e = element;
|
|
||||||
update();
|
update();
|
||||||
instances.put(entity, this);
|
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 (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)) {
|
if (!ElementalAbility.isTransparent(instigator, b)) {
|
||||||
hasBeenDamaged = true;
|
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();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
package com.projectkorra.projectkorra.waterbending;
|
package com.projectkorra.projectkorra.waterbending;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import java.util.ArrayList;
|
||||||
import com.projectkorra.projectkorra.Element;
|
import java.util.List;
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
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 org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
|
@ -18,9 +13,13 @@ import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import java.util.List;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
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 {
|
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 vector = GeneralMethods.getDirection(location, GeneralMethods.getTargetedLocation(player, location.distance(target)));
|
||||||
vector.normalize();
|
vector.normalize();
|
||||||
entity.setVelocity(vector.multiply(throwFactor));
|
entity.setVelocity(vector.multiply(throwFactor));
|
||||||
new HorizontalVelocityTracker(entity, player, 200, "Bloodbending", Element.AIR);
|
new HorizontalVelocityTracker(entity, player, 200, this);
|
||||||
}
|
}
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue