Stupid Commit, Will Revert

This commit is contained in:
MistPhizzle 2014-07-13 16:40:47 -04:00
parent ef812566da
commit 599ecf6426
16 changed files with 168 additions and 116 deletions

View file

@ -0,0 +1,59 @@
package com.projectkorra.ProjectKorra.CustomEvents;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class EntityDamageByBendingEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private Player attacker;
private Entity target;
private String ability;
private double damage;
private boolean cancelled = false;
public EntityDamageByBendingEvent(Player Attacker, Entity Target, String Ability, double Damage) {
attacker = Attacker;
target = Target;
ability = Ability;
damage = Damage;
}
public Player getAttacker() {
return attacker;
}
public Entity getTarget() {
return target;
}
public String getAbilityName() {
return ability;
}
public double getDamage() {
return damage;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean set) {
cancelled = set;
}
}

View file

@ -65,6 +65,7 @@ import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig;
import com.projectkorra.ProjectKorra.Ability.AbilityModule; import com.projectkorra.ProjectKorra.Ability.AbilityModule;
import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager;
import com.projectkorra.ProjectKorra.Ability.AvatarState; import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.CustomEvents.EntityDamageByBendingEvent;
import com.projectkorra.ProjectKorra.airbending.AirBlast; import com.projectkorra.ProjectKorra.airbending.AirBlast;
import com.projectkorra.ProjectKorra.airbending.AirBubble; import com.projectkorra.ProjectKorra.airbending.AirBubble;
import com.projectkorra.ProjectKorra.airbending.AirBurst; import com.projectkorra.ProjectKorra.airbending.AirBurst;
@ -1345,12 +1346,13 @@ public class Methods {
return set; return set;
} }
public static void damageEntity(Player player, Entity entity, double damage) { public static void damageEntity(Player player, Entity entity, String ability, double damage) {
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
((LivingEntity) entity).damage(damage, player); Bukkit.getServer().getPluginManager().callEvent(new EntityDamageByBendingEvent(player, entity, ability, damage));
((LivingEntity) entity) // ((LivingEntity) entity).damage(damage, player);
.setLastDamageCause(new EntityDamageByEntityEvent(player, // ((LivingEntity) entity)
entity, DamageCause.CUSTOM, damage)); // .setLastDamageCause(new EntityDamageByEntityEvent(player,
// entity, DamageCause.CUSTOM, damage));
} }
} }

View file

@ -4,7 +4,9 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.EntityEffect;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -54,6 +56,7 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Ability.AvatarState; import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.CustomEvents.EntityDamageByBendingEvent;
import com.projectkorra.ProjectKorra.CustomEvents.PlayerGrappleEvent; import com.projectkorra.ProjectKorra.CustomEvents.PlayerGrappleEvent;
import com.projectkorra.ProjectKorra.Utilities.GrapplingHookAPI; import com.projectkorra.ProjectKorra.Utilities.GrapplingHookAPI;
import com.projectkorra.ProjectKorra.airbending.AirBlast; import com.projectkorra.ProjectKorra.airbending.AirBlast;
@ -899,7 +902,7 @@ public class PKListener implements Listener {
Entity en = e.getEntity(); Entity en = e.getEntity();
if (en instanceof Player) { if (en instanceof Player) {
// Player p = (Player) en; // This is the player getting hurt. // Player p = (Player) en; // This is the player getting hurt.
if (e.getDamager() instanceof Player) { // This is the player hitting someone. if (e.getDamager() instanceof Player) { // This is the player hitting someone.
Player sourceplayer = (Player) e.getDamager(); Player sourceplayer = (Player) e.getDamager();
Player targetplayer = (Player) e.getEntity(); Player targetplayer = (Player) e.getEntity();
@ -930,27 +933,27 @@ public class PKListener implements Listener {
} }
} }
// Player damager = (Player) e.getDamager(); // Player damager = (Player) e.getDamager();
// if (Methods.canBendPassive(damager.getName(), Element.Chi)) { // if (Methods.canBendPassive(damager.getName(), Element.Chi)) {
// if (e.getCause() == DamageCause.ENTITY_ATTACK) { // if (e.getCause() == DamageCause.ENTITY_ATTACK) {
// if (Methods.isWeapon(damager.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { // if (Methods.isWeapon(damager.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
// return; // return;
// } // }
// if (damager.getItemInHand() != null && Methods.isWeapon(damager.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { // if (damager.getItemInHand() != null && Methods.isWeapon(damager.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
// // Above method checks if the player has an item in their hand, if it is a weapon, and if they can bend with weapons. // // Above method checks if the player has an item in their hand, if it is a weapon, and if they can bend with weapons.
// if (Methods.getBoundAbility(damager) == null || Methods.getBoundAbility(damager).equalsIgnoreCase("RapidPunch")) { // We don't want them to be able to block chi if an ability is bound. // if (Methods.getBoundAbility(damager) == null || Methods.getBoundAbility(damager).equalsIgnoreCase("RapidPunch")) { // We don't want them to be able to block chi if an ability is bound.
// if (ChiPassive.willChiBlock(p)) { // if (ChiPassive.willChiBlock(p)) {
// ChiPassive.blockChi(p); // ChiPassive.blockChi(p);
// } // }
// } // }
// if (Methods.getBoundAbility(damager).equalsIgnoreCase("Paralyze")) { // if (Methods.getBoundAbility(damager).equalsIgnoreCase("Paralyze")) {
// if (ChiPassive.willChiBlock(p)) { // if (ChiPassive.willChiBlock(p)) {
// new Paralyze((Player) e.getDamager(), e.getEntity()); // new Paralyze((Player) e.getDamager(), e.getEntity());
// } // }
// } // }
// } // }
// } // }
// } // }
} }
} }
} }
@ -1010,7 +1013,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);
Methods.damageEntity(source, player, event.getDamage()); Methods.damageEntity(source, player, null, event.getDamage());
} }
} }
@ -1045,6 +1048,32 @@ public class PKListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamageByBending(EntityDamageByBendingEvent event) {
Player player = event.getAttacker();
Entity target = event.getTarget();
if (target instanceof LivingEntity) {
LivingEntity le = (LivingEntity) target;
if (event.isCancelled()) return;
if (target instanceof Player) {
Player victim = (Player) target;
if (event.getAbilityName() != null && event.getAbilityName().equalsIgnoreCase("FireBurst")) {
Bukkit.getServer().broadcastMessage("FireBurst: " + event.getDamage());
return;
}
victim.playEffect(EntityEffect.HURT);
if (victim.getHealth() - event.getDamage() <= 0) {
victim.setHealth(0);
} else {
victim.setHealth(victim.getHealth() - event.getDamage());
}
} else {
target.playEffect(EntityEffect.HURT);
le.damage(event.getDamage(), player);
}
}
}
} }

View file

@ -260,7 +260,8 @@ public class AirSwipe {
if (entity instanceof LivingEntity if (entity instanceof LivingEntity
&& !affectedentities.contains(entity)) { && !affectedentities.contains(entity)) {
if (damage != 0) if (damage != 0)
Methods.damageEntity(player, entity, damage); Methods.damageEntity(player, entity, "AirSwipe", damage);
// Methods.damageEntity(player, entity, damage);
affectedentities.add(entity); affectedentities.add(entity);
} }

View file

@ -53,7 +53,7 @@ public class RapidPunch {
instance.remove(p); instance.remove(p);
if (target instanceof LivingEntity && target != null) { if (target instanceof LivingEntity && target != null) {
LivingEntity lt = (LivingEntity) target; LivingEntity lt = (LivingEntity) target;
Methods.damageEntity(p, target, damage); Methods.damageEntity(p, target, "RapidPunch", damage);
if (target instanceof Player) if (target instanceof Player)
if (ChiPassive.willChiBlock((Player) target)) { if (ChiPassive.willChiBlock((Player) target)) {
ChiPassive.blockChi((Player) target); ChiPassive.blockChi((Player) target);

View file

@ -389,7 +389,7 @@ public class EarthBlast {
Location location = player.getEyeLocation(); Location location = player.getEyeLocation();
Vector vector = location.getDirection(); Vector vector = location.getDirection();
entity.setVelocity(vector.normalize().multiply(pushfactor)); entity.setVelocity(vector.normalize().multiply(pushfactor));
Methods.damageEntity(player, entity, damage); Methods.damageEntity(player, entity, "EarthBlast", damage);
progressing = false; progressing = false;
// } // }

View file

@ -3,6 +3,7 @@ package com.projectkorra.ProjectKorra.earthbending;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -20,7 +21,7 @@ public class Ripple {
private static ConcurrentHashMap<Integer[], Block> blocks = new ConcurrentHashMap<Integer[], Block>(); private static ConcurrentHashMap<Integer[], Block> blocks = new ConcurrentHashMap<Integer[], Block>();
static final double radius = 15; static final double radius = 15;
private static final int damage = 5; private static final double damage = 5;
private static int ID = Integer.MIN_VALUE; private static int ID = Integer.MIN_VALUE;
@ -240,12 +241,11 @@ public class Ripple {
length = 2; length = 2;
} }
if (Methods.moveEarth(player, block, new Vector(0, 1, 0), length, false)) { if (Methods.moveEarth(player, block, new Vector(0, 1, 0), length, false)) {
for (Entity entity : Methods.getEntitiesAroundPoint(block for (Entity entity : Methods.getEntitiesAroundPoint(block.getLocation().clone().add(0, 1, 0), 2)) {
.getLocation().clone().add(0, 1, 0), 2)) { if (entity.getEntityId() != player.getEntityId() && !entities.contains(entity)) {
if (entity.getEntityId() != player.getEntityId() if (!(entity instanceof FallingBlock)) {
&& !entities.contains(entity)) {
if (!(entity instanceof FallingBlock))
entities.add(entity); entities.add(entity);
}
} }
} }
return true; return true;
@ -256,7 +256,7 @@ public class Ripple {
private void affect(Entity entity) { private void affect(Entity entity) {
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
Methods.damageEntity(player, entity, damage); Methods.damageEntity(player, entity, "Shockwave", damage);
} }
Vector vector = direction.clone(); Vector vector = direction.clone();

View file

@ -49,7 +49,7 @@ public class FireBlast {
private int id; private int id;
private double speedfactor; private double speedfactor;
private int ticks = 0; private int ticks = 0;
private int damage = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.FireBlast.Damage"); private double damage = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Damage");
double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Range"); double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.FireBlast.Range");
long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBlast.Cooldown"); long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Fire.FireBlast.Cooldown");
@ -95,7 +95,7 @@ public class FireBlast {
} }
public FireBlast(Location location, Vector direction, Player player, public FireBlast(Location location, Vector direction, Player player,
int damage, List<Block> safeblocks) { double damage, List<Block> safeblocks) {
if (location.getBlock().isLiquid()) { if (location.getBlock().isLiquid()) {
return; return;
} }
@ -134,46 +134,9 @@ public class FireBlast {
return false; return false;
} }
// if (player.isSneaking()
// && Methods.getBendingAbility(player) == Abilities.AirBlast) {
// new AirBlast(player);
// }
Block block = location.getBlock(); Block block = location.getBlock();
// for (Block testblock : Methods.getBlocksAroundPoint(location,
// affectingradius)) {
// if (testblock.getType() == Material.FIRE) {
// testblock.setType(Material.AIR);
// testblock.getWorld().playEffect(testblock.getLocation(),
// Effect.EXTINGUISH, 0);
// }
// if (((block.getType() == Material.LEVER) || (block.getType() ==
// Material.STONE_BUTTON))
// && !affectedlevers.contains(block)) {
// EntityHuman eH = ((CraftPlayer) player).getHandle();
//
// net.minecraft.server.Block.byId[block.getTypeId()].interact(
// ((CraftWorld) block.getWorld()).getHandle(),
// block.getX(), block.getY(), block.getZ(), eH);
//
// affectedlevers.add(block);
// }
// }
if (Methods.isSolid(block) || block.isLiquid()) { if (Methods.isSolid(block) || block.isLiquid()) {
if (block.getType() == Material.FURNACE && canPowerFurnace) { if (block.getType() == Material.FURNACE && canPowerFurnace) {
// BlockState state = block.getState();
// Furnace furnace = (Furnace) state;
// FurnaceInventory inv = furnace.getInventory();
// if (inv.getFuel() == null) {
// ItemStack temp = inv.getSmelting();
// ItemStack tempfuel = new ItemStack(Material.WOOD_AXE, 1);
// ItemStack tempsmelt = new ItemStack(Material.COBBLESTONE);
// inv.setFuel(tempfuel);
// inv.setSmelting(tempsmelt);
// state.update(true);
// inv.setSmelting(temp);
// state.update(true);
// }
} else if (FireStream.isIgnitable(player, } else if (FireStream.isIgnitable(player,
block.getRelative(BlockFace.UP))) { block.getRelative(BlockFace.UP))) {
ignite(location); ignite(location);
@ -200,17 +163,8 @@ public class FireBlast {
for (Entity entity : Methods.getEntitiesAroundPoint(location, for (Entity entity : Methods.getEntitiesAroundPoint(location,
affectingradius)) { affectingradius)) {
// Block bblock = location.getBlock();
// Block block1 = entity.getLocation().getBlock();
// if (bblock.equals(block1))
affect(entity); affect(entity);
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
// Block block2 = ((LivingEntity) entity).getEyeLocation()
// .getBlock();
// if (bblock.equals(block1))
// break;
// if (bblock.equals(block2)) {
// affect(entity);
break; break;
// } // }
} }
@ -265,7 +219,7 @@ public class FireBlast {
} }
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
entity.setFireTicks(50); entity.setFireTicks(50);
Methods.damageEntity(player, entity, (int) Methods Methods.damageEntity(player, entity, "FireBlast", Methods
.firebendingDayAugment((double) damage, .firebendingDayAugment((double) damage,
entity.getWorld())); entity.getWorld()));
new Enflamed(entity, player); new Enflamed(entity, player);

View file

@ -22,7 +22,7 @@ public class FireBurst {
private Player player; private Player player;
private long starttime; private long starttime;
private int damage = 3; private double damage = 3;
private long chargetime = 2500; private long chargetime = 2500;
private double deltheta = 10; private double deltheta = 10;
private double delphi = 10; private double delphi = 10;

View file

@ -155,14 +155,14 @@ public class Fireball {
if (distance > explosionradius) if (distance > explosionradius)
return; return;
if (distance < innerradius) { if (distance < innerradius) {
Methods.damageEntity(player, entity, maxdamage); Methods.damageEntity(player, entity, "FireBlast", maxdamage);
return; return;
} }
double slope = -(maxdamage * .5) / (explosionradius - innerradius); double slope = -(maxdamage * .5) / (explosionradius - innerradius);
double damage = slope * (distance - innerradius) + maxdamage; double damage = slope * (distance - innerradius) + maxdamage;
// Methods.verbose(damage); // Methods.verbose(damage);
Methods.damageEntity(player, entity, (int) damage); Methods.damageEntity(player, entity, "FireBlast", damage);
} }
private void fireball() { private void fireball() {

View file

@ -153,7 +153,7 @@ public class Lightning {
return; return;
double damage = maxdamage - (distance / strikeradius) * .5; double damage = maxdamage - (distance / strikeradius) * .5;
hitentities.add(entity); hitentities.add(entity);
Methods.damageEntity(player, entity, (int) damage); Methods.damageEntity(player, entity, "Lightning", damage);
} }
public static boolean isNearbyChannel(Location location) { public static boolean isNearbyChannel(Location location) {

View file

@ -184,7 +184,7 @@ public class WallOfFire {
entity.setFireTicks(50); entity.setFireTicks(50);
entity.setVelocity(new Vector(0, 0, 0)); entity.setVelocity(new Vector(0, 0, 0));
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
Methods.damageEntity(player, entity, damage); Methods.damageEntity(player, entity, "WallOfFire", damage);
new Enflamed(entity, player); new Enflamed(entity, player);
} }
} }

View file

@ -54,7 +54,8 @@ public class Bloodbending {
"Bloodbending"))) "Bloodbending")))
continue; continue;
} }
Methods.damageEntity(player, entity, 0); Methods.damageEntity(player, entity, "Bloodbending", 0);
// Methods.damageEntity(player, entity, 0);
targetentities.put(entity, entity.getLocation().clone()); targetentities.put(entity, entity.getLocation().clone());
} }
} }
@ -71,7 +72,8 @@ public class Bloodbending {
|| AvatarState.isAvatarState((Player) target)) || AvatarState.isAvatarState((Player) target))
return; return;
} }
Methods.damageEntity(player, target, 0); Methods.damageEntity(player, target, "Bloodbending", 0);
// Methods.damageEntity(player, target, 0);
targetentities.put(target, target.getLocation().clone()); targetentities.put(target, target.getLocation().clone());
} }
this.player = player; this.player = player;
@ -138,7 +140,8 @@ public class Bloodbending {
entities.add(entity); entities.add(entity);
if (!targetentities.containsKey(entity) if (!targetentities.containsKey(entity)
&& entity instanceof LivingEntity) { && entity instanceof LivingEntity) {
Methods.damageEntity(player, entity, 0); Methods.damageEntity(player, entity, "Bloodbending", 0);
// Methods.damageEntity(player, entity, 0);
targetentities.put(entity, entity.getLocation().clone()); targetentities.put(entity, entity.getLocation().clone());
} }
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {

View file

@ -141,7 +141,8 @@ public class OctopusForm {
.getDirection(player.getLocation(), location).normalize() .getDirection(player.getLocation(), location).normalize()
.multiply(1.75)); .multiply(1.75));
if (entity instanceof LivingEntity) if (entity instanceof LivingEntity)
Methods.damageEntity(player, entity, damage); Methods.damageEntity(player, entity, "OctopusForm", damage);
// Methods.damageEntity(player, entity, damage);
} }
} }

View file

@ -527,7 +527,8 @@ public class Torrent {
if (Methods.isNight(world)) { if (Methods.isNight(world)) {
damagedealt = (int) (Methods.getWaterbendingNightAugment(world) * (double) deflectdamage); damagedealt = (int) (Methods.getWaterbendingNightAugment(world) * (double) deflectdamage);
} }
Methods.damageEntity(player, entity, damagedealt); Methods.damageEntity(player, entity, "Torrent", damagedealt);
// Methods.damageEntity(player, entity, damagedealt);
} }
} }
@ -546,7 +547,8 @@ public class Torrent {
damagedealt = (int) (Methods.getWaterbendingNightAugment(world) * (double) damage); damagedealt = (int) (Methods.getWaterbendingNightAugment(world) * (double) damage);
} }
// if (((LivingEntity) entity).getNoDamageTicks() == 0) { // if (((LivingEntity) entity).getNoDamageTicks() == 0) {
Methods.damageEntity(player, entity, damagedealt); Methods.damageEntity(player, entity, "Torrent", damagedealt);
// Methods.damageEntity(player, entity, damagedealt);
// Methods.verbose("Hit! Health at " // Methods.verbose("Hit! Health at "
// + ((LivingEntity) entity).getHealth()); // + ((LivingEntity) entity).getHealth());
hurtentities.add(entity); hurtentities.add(entity);

View file

@ -382,9 +382,10 @@ public class WaterManipulation {
// .add(direction)); // .add(direction));
if (AvatarState.isAvatarState(player)) if (AvatarState.isAvatarState(player))
damage = AvatarState.getValue(damage); damage = AvatarState.getValue(damage);
Methods.damageEntity(player, entity, (int) Methods Methods.damageEntity(player, entity, "WaterManipulation", Methods.waterbendingNightAugment(damage, player.getWorld()));
.waterbendingNightAugment(damage, // Methods.damageEntity(player, entity, (int) Methods
player.getWorld())); // .waterbendingNightAugment(damage,
// player.getWorld()));
progressing = false; progressing = false;
// } // }
} }