ChiBlocking Passive Fixed

Chi actually blocks now
This commit is contained in:
MistPhizzle 2014-06-29 20:27:47 -04:00
parent d3776fe766
commit c6e45753e1
4 changed files with 103 additions and 34 deletions

View file

@ -15,6 +15,7 @@ public class BendingPlayer {
String player;
ArrayList<Element> elements;
HashMap<Integer, String> abilities;
boolean isChiBlocked;
boolean permaRemoved;
boolean isToggled;
private long slowTime = 0;
@ -27,6 +28,7 @@ public class BendingPlayer {
this.abilities = abilities;
this.permaRemoved = permaRemoved;
isToggled = true;
isChiBlocked = false;
players.put(player, this);
}
@ -79,4 +81,16 @@ public class BendingPlayer {
public boolean isTremorsensing() {
return tremorsense;
}
public void blockChi() {
isChiBlocked = true;
}
public void unblockChi() {
isChiBlocked = false;
}
public boolean isChiBlocked() {
return isChiBlocked;
}
}

View file

@ -56,6 +56,7 @@ import com.projectkorra.ProjectKorra.Ability.AbilityModule;
import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.airbending.AirSpout;
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
@ -499,15 +500,20 @@ public class Methods {
}
public static boolean isChiBlocked(String player) {
long currTime = System.currentTimeMillis();
long duration = ProjectKorra.plugin.getConfig().getLong("Abilities.Chi.Passive.BlockChi.Duration");
if (BendingPlayer.blockedChi.contains(player)) {
if (BendingPlayer.blockedChi.get(player) + duration >= currTime) {
BendingPlayer.blockedChi.remove(player);
return false;
}
}
return true;
return Methods.getBendingPlayer(player).isChiBlocked();
// long currTime = System.currentTimeMillis();
// long duration = ProjectKorra.plugin.getConfig().getLong("Abilities.Chi.Passive.BlockChi.Duration");
// if (BendingPlayer.blockedChi.contains(player)) {
// if (BendingPlayer.blockedChi.get(player) + ChiPassive.duration >= System.currentTimeMillis()) {
// return true;
// } else {
// BendingPlayer.blockedChi.remove(player);
// return false;
// }
// } else {
// Bukkit.getServer().broadcastMessage("test");
// return false;
// }
}
public static Vector rotateVectorAroundVector(Vector axis, Vector rotator,

View file

@ -3,6 +3,7 @@ package com.projectkorra.ProjectKorra;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -211,6 +212,11 @@ public class PKListener implements Listener {
return;
}
if (Methods.isChiBlocked(player.getName())) {
event.setCancelled(true);
return;
}
if (!player.isSneaking() && Methods.canBend(player.getName(), abil)) {
if (abil.equalsIgnoreCase("AirShield")) {
@ -483,12 +489,18 @@ public class PKListener implements Listener {
event.setCancelled(true);
}
if (Methods.isChiBlocked(player.getName())) {
event.setCancelled(true);
return;
}
String abil = Methods.getBoundAbility(player);
if (abil == null) return;
if (Methods.canBend(player.getName(), abil)) {
if (abil.equalsIgnoreCase("AvatarState")) {
new AvatarState(player);
}
if (Methods.isAirAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
return;
@ -617,6 +629,9 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("RapidPunch")) {
new RapidPunch(player);
}
if (abil.equalsIgnoreCase("Paralyze")) {
//
}
}
}
}
@ -813,29 +828,45 @@ 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 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 sourceplayer = (Player) e.getDamager();
Player targetplayer = (Player) e.getEntity();
if (Methods.canBendPassive(sourceplayer.getName(), Element.Chi)) {
if (Methods.isBender(sourceplayer.getName(), Element.Chi) && e.getCause() == DamageCause.ENTITY_ATTACK && e.getDamage() == 1) {
if (sourceplayer.getLocation().distance(targetplayer.getLocation()) <= plugin.getConfig().getDouble("Abilities.Chi.RapidPunch.Distance")) {
if (Methods.isWeapon(sourceplayer.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
return;
} else {
if (ChiPassive.willChiBlock(targetplayer)) {
ChiPassive.blockChi(targetplayer);
}
}
}
}
}
// 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());
// }
// }
// }
// }
// }
}
}
}

View file

@ -18,19 +18,23 @@ public class ChiPassive {
public static int jumpPower = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.Jump");
public static int speedPower = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.Speed");
public static int dodgeChance = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.ChiBlock.DodgeChance");
public static int duration = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.ChiBlock.Duration");
public static int dodgeChance = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.BlockChi.DodgeChance");
public static int duration = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.BlockChi.Duration");
public static boolean willChiBlock(Player player) {
Random rand = new Random();
if (rand.nextInt(99) + 1 < dodgeChance) {
return false;
}
if (Methods.isChiBlocked(player.getName())) return false;
if (Methods.isChiBlocked(player.getName())) {
return false;
}
return true;
}
public static void blockChi(Player player) {
Methods.getBendingPlayer(player.getName()).blockChi();
// Bukkit.getServer().broadcastMessage("We made it");
BendingPlayer.blockedChi.put(player.getName(), System.currentTimeMillis());
}
@ -46,11 +50,25 @@ public class ChiPassive {
}
}
}
if (BendingPlayer.blockedChi.contains(player.getName())) {
if (BendingPlayer.blockedChi.get(player.getName()) + duration >= System.currentTimeMillis()) {
BendingPlayer.blockedChi.remove(player.getName());
}
}
}
for (String s: BendingPlayer.blockedChi.keySet()) {
if (!(BendingPlayer.blockedChi.get(s) + duration >= System.currentTimeMillis())) {
Methods.getBendingPlayer(s).unblockChi();
}
// if (BendingPlayer.blockedChi.contains(player.getName())) {
// if (BendingPlayer.blockedChi.get(player.getName()) + duration < System.currentTimeMillis()) {
// BendingPlayer.blockedChi.remove(player.getName());
// } else {
// }
// }
}
// for (String s: BendingPlayer.blockedChi.keySet()) {
// if (BendingPlayer.blockedChi.get(s) + duration >= System.currentTimeMillis()) {
// Bukkit.getServer().broadcastMessage(s + "'s Chi is blocked.");
// } else {
// Bukkit.getServer().broadcastMessage(s + "'s Chi has been unblocked.");
// BendingPlayer.blockedChi.remove(s);
// }
// }
}
}