mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
ChiBlocking Passive Fixed
Chi actually blocks now
This commit is contained in:
parent
d3776fe766
commit
c6e45753e1
4 changed files with 103 additions and 34 deletions
|
@ -15,6 +15,7 @@ public class BendingPlayer {
|
||||||
String player;
|
String player;
|
||||||
ArrayList<Element> elements;
|
ArrayList<Element> elements;
|
||||||
HashMap<Integer, String> abilities;
|
HashMap<Integer, String> abilities;
|
||||||
|
boolean isChiBlocked;
|
||||||
boolean permaRemoved;
|
boolean permaRemoved;
|
||||||
boolean isToggled;
|
boolean isToggled;
|
||||||
private long slowTime = 0;
|
private long slowTime = 0;
|
||||||
|
@ -27,6 +28,7 @@ public class BendingPlayer {
|
||||||
this.abilities = abilities;
|
this.abilities = abilities;
|
||||||
this.permaRemoved = permaRemoved;
|
this.permaRemoved = permaRemoved;
|
||||||
isToggled = true;
|
isToggled = true;
|
||||||
|
isChiBlocked = false;
|
||||||
|
|
||||||
players.put(player, this);
|
players.put(player, this);
|
||||||
}
|
}
|
||||||
|
@ -79,4 +81,16 @@ public class BendingPlayer {
|
||||||
public boolean isTremorsensing() {
|
public boolean isTremorsensing() {
|
||||||
return tremorsense;
|
return tremorsense;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void blockChi() {
|
||||||
|
isChiBlocked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unblockChi() {
|
||||||
|
isChiBlocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChiBlocked() {
|
||||||
|
return isChiBlocked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ 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.airbending.AirSpout;
|
import com.projectkorra.ProjectKorra.airbending.AirSpout;
|
||||||
|
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
|
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
|
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
|
||||||
|
@ -499,15 +500,20 @@ public class Methods {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChiBlocked(String player) {
|
public static boolean isChiBlocked(String player) {
|
||||||
long currTime = System.currentTimeMillis();
|
return Methods.getBendingPlayer(player).isChiBlocked();
|
||||||
long duration = ProjectKorra.plugin.getConfig().getLong("Abilities.Chi.Passive.BlockChi.Duration");
|
// long currTime = System.currentTimeMillis();
|
||||||
if (BendingPlayer.blockedChi.contains(player)) {
|
// long duration = ProjectKorra.plugin.getConfig().getLong("Abilities.Chi.Passive.BlockChi.Duration");
|
||||||
if (BendingPlayer.blockedChi.get(player) + duration >= currTime) {
|
// if (BendingPlayer.blockedChi.contains(player)) {
|
||||||
BendingPlayer.blockedChi.remove(player);
|
// if (BendingPlayer.blockedChi.get(player) + ChiPassive.duration >= System.currentTimeMillis()) {
|
||||||
return false;
|
// return true;
|
||||||
}
|
// } else {
|
||||||
}
|
// BendingPlayer.blockedChi.remove(player);
|
||||||
return true;
|
// return false;
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// Bukkit.getServer().broadcastMessage("test");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector rotateVectorAroundVector(Vector axis, Vector rotator,
|
public static Vector rotateVectorAroundVector(Vector axis, Vector rotator,
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.projectkorra.ProjectKorra;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -211,6 +212,11 @@ public class PKListener implements Listener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Methods.isChiBlocked(player.getName())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!player.isSneaking() && Methods.canBend(player.getName(), abil)) {
|
if (!player.isSneaking() && Methods.canBend(player.getName(), abil)) {
|
||||||
|
|
||||||
if (abil.equalsIgnoreCase("AirShield")) {
|
if (abil.equalsIgnoreCase("AirShield")) {
|
||||||
|
@ -483,12 +489,18 @@ public class PKListener implements Listener {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Methods.isChiBlocked(player.getName())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
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 (abil.equalsIgnoreCase("AvatarState")) {
|
if (abil.equalsIgnoreCase("AvatarState")) {
|
||||||
new AvatarState(player);
|
new AvatarState(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -617,6 +629,9 @@ public class PKListener implements Listener {
|
||||||
if (abil.equalsIgnoreCase("RapidPunch")) {
|
if (abil.equalsIgnoreCase("RapidPunch")) {
|
||||||
new RapidPunch(player);
|
new RapidPunch(player);
|
||||||
}
|
}
|
||||||
|
if (abil.equalsIgnoreCase("Paralyze")) {
|
||||||
|
//
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -813,29 +828,45 @@ 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 damager = (Player) e.getDamager();
|
Player sourceplayer = (Player) e.getDamager();
|
||||||
if (Methods.canBendPassive(damager.getName(), Element.Chi)) {
|
Player targetplayer = (Player) e.getEntity();
|
||||||
if (e.getCause() == DamageCause.ENTITY_ATTACK) {
|
if (Methods.canBendPassive(sourceplayer.getName(), Element.Chi)) {
|
||||||
if (Methods.isWeapon(damager.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
|
if (Methods.isBender(sourceplayer.getName(), Element.Chi) && e.getCause() == DamageCause.ENTITY_ATTACK && e.getDamage() == 1) {
|
||||||
return;
|
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")) {
|
||||||
if (damager.getItemInHand() != null && Methods.isWeapon(damager.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
|
return;
|
||||||
// Above method checks if the player has an item in their hand, if it is a weapon, and if they can bend with weapons.
|
} else {
|
||||||
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(targetplayer)) {
|
||||||
ChiPassive.blockChi(p);
|
ChiPassive.blockChi(targetplayer);
|
||||||
}
|
|
||||||
}
|
|
||||||
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());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,19 +18,23 @@ public class ChiPassive {
|
||||||
public static int jumpPower = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.Jump");
|
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 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 dodgeChance = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.BlockChi.DodgeChance");
|
||||||
public static int duration = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.ChiBlock.Duration");
|
public static int duration = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.Passive.BlockChi.Duration");
|
||||||
|
|
||||||
public static boolean willChiBlock(Player player) {
|
public static boolean willChiBlock(Player player) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
if (rand.nextInt(99) + 1 < dodgeChance) {
|
if (rand.nextInt(99) + 1 < dodgeChance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Methods.isChiBlocked(player.getName())) return false;
|
if (Methods.isChiBlocked(player.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void blockChi(Player player) {
|
public static void blockChi(Player player) {
|
||||||
|
Methods.getBendingPlayer(player.getName()).blockChi();
|
||||||
|
// Bukkit.getServer().broadcastMessage("We made it");
|
||||||
BendingPlayer.blockedChi.put(player.getName(), System.currentTimeMillis());
|
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);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue