mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Chi no longer takes fall damage if sprinting
This commit is contained in:
parent
4ef2e12287
commit
b90552537f
1 changed files with 48 additions and 43 deletions
|
@ -115,7 +115,7 @@ public class PKListener implements Listener {
|
||||||
public PKListener(ProjectKorra plugin) {
|
public PKListener(ProjectKorra plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Integer, Integer> noFallEntities = new HashMap<Integer, Integer>(); // Grappling Hooks
|
public static HashMap<Integer, Integer> noFallEntities = new HashMap<Integer, Integer>(); // Grappling Hooks
|
||||||
public static HashMap<String, Integer> noGrapplePlayers = new HashMap<String, 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) {
|
public void onPlayerGrapple(PlayerGrappleEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
if (!plugin.getConfig().getBoolean("Properties.CustomItems.GrapplingHook.Enable")) return;
|
if (!plugin.getConfig().getBoolean("Properties.CustomItems.GrapplingHook.Enable")) return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!Methods.isBender(player.getName(), Element.Chi) && (!Methods.isBender(player.getName(), Element.Earth) || !Methods.canMetalbend(player))) {
|
if (!Methods.isBender(player.getName(), Element.Chi) && (!Methods.isBender(player.getName(), Element.Earth) || !Methods.canMetalbend(player))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -132,29 +132,29 @@ public class PKListener implements Listener {
|
||||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
|
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getHookItem().setDurability((short) - 10);
|
event.getHookItem().setDurability((short) - 10);
|
||||||
if (noGrapplePlayers.containsKey(player.getName())) {
|
if (noGrapplePlayers.containsKey(player.getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity e = event.getPulledEntity();
|
Entity e = event.getPulledEntity();
|
||||||
Location loc = event.getPullLocation();
|
Location loc = event.getPullLocation();
|
||||||
|
|
||||||
if (player.equals(e)) {
|
if (player.equals(e)) {
|
||||||
if (player.getLocation().distance(loc) < 3) { // Too close
|
if (player.getLocation().distance(loc) < 3) { // Too close
|
||||||
GrapplingHookAPI.pullPlayerSlightly(player, loc);
|
GrapplingHookAPI.pullPlayerSlightly(player, loc);
|
||||||
} else {
|
} else {
|
||||||
GrapplingHookAPI.pullEntityToLocation(player, loc);
|
GrapplingHookAPI.pullEntityToLocation(player, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GrapplingHookAPI.addUse(player, event.getHookItem())) {
|
if (GrapplingHookAPI.addUse(player, event.getHookItem())) {
|
||||||
GrapplingHookAPI.playGrappleSound(player.getLocation());
|
GrapplingHookAPI.playGrappleSound(player.getLocation());
|
||||||
}
|
}
|
||||||
GrapplingHookAPI.addPlayerCooldown(player, 100);
|
GrapplingHookAPI.addPlayerCooldown(player, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void fishEvent(PlayerFishEvent event) {
|
public void fishEvent(PlayerFishEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
@ -169,7 +169,7 @@ public class PKListener implements Listener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerGrappleEvent e = new PlayerGrappleEvent(player, player, loc);
|
PlayerGrappleEvent e = new PlayerGrappleEvent(player, player, loc);
|
||||||
plugin.getServer().getPluginManager().callEvent(e);
|
plugin.getServer().getPluginManager().callEvent(e);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ public class PKListener implements Listener {
|
||||||
if (abil == null) {
|
if (abil == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Methods.isChiBlocked(player.getName())) {
|
if (Methods.isChiBlocked(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -352,7 +352,7 @@ public class PKListener implements Listener {
|
||||||
if (abil.equalsIgnoreCase("Tremorsense")) {
|
if (abil.equalsIgnoreCase("Tremorsense")) {
|
||||||
Methods.getBendingPlayer(player.getName()).toggleTremorsense();
|
Methods.getBendingPlayer(player.getName()).toggleTremorsense();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abil.equalsIgnoreCase("Extraction")) {
|
if (abil.equalsIgnoreCase("Extraction")) {
|
||||||
new Extraction(player);
|
new Extraction(player);
|
||||||
}
|
}
|
||||||
|
@ -560,19 +560,19 @@ public class PKListener implements Listener {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Methods.isChiBlocked(player.getName())) {
|
if (Methods.isChiBlocked(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AirScooter.check(player);
|
AirScooter.check(player);
|
||||||
|
|
||||||
String abil = Methods.getBoundAbility(player);
|
String abil = Methods.getBoundAbility(player);
|
||||||
if (abil == null) return;
|
if (abil == null) return;
|
||||||
if (Methods.canBend(player.getName(), abil)) {
|
if (Methods.canBend(player.getName(), abil)) {
|
||||||
|
|
||||||
|
|
||||||
if (Methods.isAirAbility(abil)) {
|
if (Methods.isAirAbility(abil)) {
|
||||||
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
|
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
|
||||||
return;
|
return;
|
||||||
|
@ -705,7 +705,7 @@ public class PKListener implements Listener {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abil.equalsIgnoreCase("AvatarState")) {
|
if (abil.equalsIgnoreCase("AvatarState")) {
|
||||||
new AvatarState(player);
|
new AvatarState(player);
|
||||||
}
|
}
|
||||||
|
@ -783,7 +783,7 @@ public class PKListener implements Listener {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Enflamed.dealFlameDamage(entity);
|
Enflamed.dealFlameDamage(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
if (Methods.getBoundAbility(player) != null && Methods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) {
|
if (Methods.getBoundAbility(player) != null && Methods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) {
|
||||||
|
@ -929,7 +929,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();
|
||||||
|
@ -959,28 +959,28 @@ 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());
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1032,10 +1032,15 @@ public class PKListener implements Listener {
|
||||||
&& Methods.isBender(player.getName(), Element.Chi)
|
&& Methods.isBender(player.getName(), Element.Chi)
|
||||||
&& event.getCause() == DamageCause.FALL
|
&& event.getCause() == DamageCause.FALL
|
||||||
&& Methods.canBendPassive(player.getName(), Element.Chi)) {
|
&& Methods.canBendPassive(player.getName(), Element.Chi)) {
|
||||||
double initdamage = event.getDamage();
|
if (player.isSprinting()) {
|
||||||
double newdamage = event.getDamage() * ChiPassive.FallReductionFactor;
|
event.setDamage(0);
|
||||||
double finaldamage = initdamage - newdamage;
|
event.setCancelled(true);
|
||||||
event.setDamage(finaldamage);
|
} 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) {
|
if (!event.isCancelled() && event.getCause() == DamageCause.FALL) {
|
||||||
|
|
Loading…
Reference in a new issue