Chi no longer takes fall damage if sprinting

This commit is contained in:
MistPhizzle 2014-07-19 20:41:17 -04:00
parent 4ef2e12287
commit b90552537f

View file

@ -115,7 +115,7 @@ public class PKListener implements Listener {
public PKListener(ProjectKorra plugin) {
this.plugin = plugin;
}
public static HashMap<Integer, Integer> noFallEntities = new HashMap<Integer, Integer>(); // Grappling Hooks
public static HashMap<String, Integer> noGrapplePlayers = new HashMap<String, Integer>(); // Grappling Hooks
@ -123,7 +123,7 @@ public class PKListener implements Listener {
public void onPlayerGrapple(PlayerGrappleEvent event) {
if (event.isCancelled()) return;
if (!plugin.getConfig().getBoolean("Properties.CustomItems.GrapplingHook.Enable")) return;
Player player = event.getPlayer();
if (!Methods.isBender(player.getName(), Element.Chi) && (!Methods.isBender(player.getName(), Element.Earth) || !Methods.canMetalbend(player))) {
event.setCancelled(true);
@ -132,29 +132,29 @@ public class PKListener implements Listener {
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
event.setCancelled(true);
}
event.getHookItem().setDurability((short) - 10);
if (noGrapplePlayers.containsKey(player.getName())) {
return;
}
Entity e = event.getPulledEntity();
Location loc = event.getPullLocation();
if (player.equals(e)) {
if (player.getLocation().distance(loc) < 3) { // Too close
GrapplingHookAPI.pullPlayerSlightly(player, loc);
} else {
GrapplingHookAPI.pullEntityToLocation(player, loc);
}
if (GrapplingHookAPI.addUse(player, event.getHookItem())) {
GrapplingHookAPI.playGrappleSound(player.getLocation());
}
GrapplingHookAPI.addPlayerCooldown(player, 100);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void fishEvent(PlayerFishEvent event) {
if (event.isCancelled()) return;
@ -169,7 +169,7 @@ public class PKListener implements Listener {
return;
}
}
PlayerGrappleEvent e = new PlayerGrappleEvent(player, player, loc);
plugin.getServer().getPluginManager().callEvent(e);
}
@ -266,7 +266,7 @@ public class PKListener implements Listener {
if (abil == null) {
return;
}
if (Methods.isChiBlocked(player.getName())) {
event.setCancelled(true);
return;
@ -352,7 +352,7 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("Tremorsense")) {
Methods.getBendingPlayer(player.getName()).toggleTremorsense();
}
if (abil.equalsIgnoreCase("Extraction")) {
new Extraction(player);
}
@ -560,19 +560,19 @@ public class PKListener implements Listener {
event.setCancelled(true);
return;
}
if (Methods.isChiBlocked(player.getName())) {
event.setCancelled(true);
return;
}
AirScooter.check(player);
String abil = Methods.getBoundAbility(player);
if (abil == null) return;
if (Methods.canBend(player.getName(), abil)) {
if (Methods.isAirAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
return;
@ -705,7 +705,7 @@ public class PKListener implements Listener {
//
}
}
if (abil.equalsIgnoreCase("AvatarState")) {
new AvatarState(player);
}
@ -783,7 +783,7 @@ public class PKListener implements Listener {
event.setCancelled(true);
Enflamed.dealFlameDamage(entity);
}
if (entity instanceof Player) {
Player player = (Player) entity;
if (Methods.getBoundAbility(player) != null && Methods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) {
@ -929,7 +929,7 @@ public class PKListener implements Listener {
Entity en = e.getEntity();
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.
Player sourceplayer = (Player) e.getDamager();
Player targetplayer = (Player) e.getEntity();
@ -959,28 +959,28 @@ public class PKListener implements Listener {
}
}
}
// Player damager = (Player) e.getDamager();
// if (Methods.canBendPassive(damager.getName(), Element.Chi)) {
// if (e.getCause() == DamageCause.ENTITY_ATTACK) {
// if (Methods.isWeapon(damager.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
// return;
// }
// 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.
// 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)) {
// ChiPassive.blockChi(p);
// }
// }
// if (Methods.getBoundAbility(damager).equalsIgnoreCase("Paralyze")) {
// if (ChiPassive.willChiBlock(p)) {
// new Paralyze((Player) e.getDamager(), e.getEntity());
// }
// }
// }
// }
// }
// Player damager = (Player) e.getDamager();
// if (Methods.canBendPassive(damager.getName(), Element.Chi)) {
// if (e.getCause() == DamageCause.ENTITY_ATTACK) {
// if (Methods.isWeapon(damager.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
// return;
// }
// 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.
// 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)) {
// ChiPassive.blockChi(p);
// }
// }
// if (Methods.getBoundAbility(damager).equalsIgnoreCase("Paralyze")) {
// if (ChiPassive.willChiBlock(p)) {
// new Paralyze((Player) e.getDamager(), e.getEntity());
// }
// }
// }
// }
// }
}
}
}
@ -1032,10 +1032,15 @@ public class PKListener implements Listener {
&& Methods.isBender(player.getName(), Element.Chi)
&& event.getCause() == DamageCause.FALL
&& Methods.canBendPassive(player.getName(), Element.Chi)) {
double initdamage = event.getDamage();
double newdamage = event.getDamage() * ChiPassive.FallReductionFactor;
double finaldamage = initdamage - newdamage;
event.setDamage(finaldamage);
if (player.isSprinting()) {
event.setDamage(0);
event.setCancelled(true);
} else {
double initdamage = event.getDamage();
double newdamage = event.getDamage() * ChiPassive.FallReductionFactor;
double finaldamage = initdamage - newdamage;
event.setDamage(finaldamage);
}
}
if (!event.isCancelled() && event.getCause() == DamageCause.FALL) {