diff --git a/src/com/projectkorra/ProjectKorra/BendingPlayer.java b/src/com/projectkorra/ProjectKorra/BendingPlayer.java index ec9c7666..5932d6ee 100644 --- a/src/com/projectkorra/ProjectKorra/BendingPlayer.java +++ b/src/com/projectkorra/ProjectKorra/BendingPlayer.java @@ -9,17 +9,17 @@ import java.util.concurrent.ConcurrentHashMap; public class BendingPlayer { public static ConcurrentHashMap players = new ConcurrentHashMap(); - public static ConcurrentHashMap blockedChi = new ConcurrentHashMap(); +// public static ConcurrentHashMap blockedChi = new ConcurrentHashMap(); UUID uuid; String player; ArrayList elements; HashMap abilities; - boolean isChiBlocked; boolean permaRemoved; boolean isToggled; private long slowTime = 0; private boolean tremorsense = true; + boolean blockedChi; public BendingPlayer(UUID uuid, String player, ArrayList elements, HashMap abilities, boolean permaRemoved) { this.uuid = uuid; @@ -28,7 +28,7 @@ public class BendingPlayer { this.abilities = abilities; this.permaRemoved = permaRemoved; isToggled = true; - isChiBlocked = false; + blockedChi = false; players.put(player, this); } @@ -83,14 +83,14 @@ public class BendingPlayer { } public void blockChi() { - isChiBlocked = true; + blockedChi = true; } public void unblockChi() { - isChiBlocked = false; + blockedChi = false; } public boolean isChiBlocked() { - return isChiBlocked; + return blockedChi; } } diff --git a/src/com/projectkorra/ProjectKorra/Methods.java b/src/com/projectkorra/ProjectKorra/Methods.java index 6eff0036..95096eb9 100644 --- a/src/com/projectkorra/ProjectKorra/Methods.java +++ b/src/com/projectkorra/ProjectKorra/Methods.java @@ -260,6 +260,8 @@ public class Methods { } cooldowns.remove(p.getName()); } + if (bPlayer.blockedChi) return false; +// if (bPlayer.isChiBlocked()) return false; if (!p.hasPermission("bending.ability." + ability)) return false; if (isAirAbility(ability) && !isBender(player, Element.Air)) return false; if (isWaterAbility(ability) && !isBender(player, Element.Water)) return false; diff --git a/src/com/projectkorra/ProjectKorra/PKListener.java b/src/com/projectkorra/ProjectKorra/PKListener.java index 9fe41e87..02f3b68e 100644 --- a/src/com/projectkorra/ProjectKorra/PKListener.java +++ b/src/com/projectkorra/ProjectKorra/PKListener.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -132,7 +133,7 @@ public class PKListener implements Listener { } } } - + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerGrapple(PlayerGrappleEvent event) { if (event.isCancelled()) return; @@ -147,7 +148,7 @@ public class PKListener implements Listener { event.setCancelled(true); return; } - + if (Methods.isBender(player.getName(), Element.Earth) && !player.hasPermission("bending.earth.grapplinghook")) { event.setCancelled(true); return; @@ -177,7 +178,7 @@ public class PKListener implements Listener { GrapplingHookAPI.addPlayerCooldown(player, 100); } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onProjectileHit(ProjectileHitEvent event) { Integer id = event.getEntity().getEntityId(); @@ -189,15 +190,15 @@ public class PKListener implements Listener { } Smokescreen.snowballs.remove(id); } -// if (Combustion.fireballs.contains(id)) { -// Location loc = event.getEntity().getLocation(); -//// for (Entity en: Methods.getEntitiesAroundPoint(loc, 4)) { -//// if (en instanceof LivingEntity) { -//// LivingEntity le = (LivingEntity) en; -//// le.damage(ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Combustion.Damage")); -//// } -//// } -// } + // if (Combustion.fireballs.contains(id)) { + // Location loc = event.getEntity().getLocation(); + //// for (Entity en: Methods.getEntitiesAroundPoint(loc, 4)) { + //// if (en instanceof LivingEntity) { + //// LivingEntity le = (LivingEntity) en; + //// le.damage(ProjectKorra.plugin.getConfig().getDouble("Abilities.Fire.Combustion.Damage")); + //// } + //// } + // } } @EventHandler(priority = EventPriority.HIGHEST) @@ -224,7 +225,7 @@ public class PKListener implements Listener { public void onPlayerInteraction(PlayerInteractEvent event) { if (event.isCancelled()) return; Player player = event.getPlayer(); - + if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { Methods.cooldowns.put(player.getName(), System.currentTimeMillis()); } @@ -522,10 +523,10 @@ public class PKListener implements Listener { public void onEntityExplode(EntityExplodeEvent event) { if (event.isCancelled()) return; -// if (event.getEntity() instanceof org.bukkit.entity.Fireball && Combustion.fireballs.contains(event.getEntity().getEntityId())) { -// event.setCancelled(true); -// } - + // if (event.getEntity() instanceof org.bukkit.entity.Fireball && Combustion.fireballs.contains(event.getEntity().getEntityId())) { + // event.setCancelled(true); + // } + for (Block block : event.blockList()) { EarthBlast blast = EarthBlast.getBlastFromSource(block); @@ -545,8 +546,8 @@ public class PKListener implements Listener { Methods.removeRevertIndex(block); } } - - + + } @@ -618,7 +619,7 @@ public class PKListener implements Listener { event.setCancelled(true); return; } - + if (Methods.isChiBlocked(player.getName())) { event.setCancelled(true); return; @@ -842,7 +843,7 @@ public class PKListener implements Listener { if (event.getCause() == DamageCause.FIRE && FireStream.ignitedblocks.containsKey(entity.getLocation().getBlock())) { new Enflamed(entity, FireStream.ignitedblocks.get(entity.getLocation().getBlock())); } - + if (Enflamed.isEnflamed(entity) && event.getCause() == DamageCause.FIRE_TICK) { event.setCancelled(true); Enflamed.dealFlameDamage(entity); @@ -973,10 +974,10 @@ public class PKListener implements Listener { fireball.dealDamage(entity); return; } - -// if (Combustion.fireballs.contains(source.getEntityId())) { -// e.setCancelled(true); -// } + + // if (Combustion.fireballs.contains(source.getEntityId())) { + // e.setCancelled(true); + // } if (e.getCause() == DamageCause.LIGHTNING) { if (Lightning.isNearbyChannel(source.getLocation())) { @@ -1004,16 +1005,26 @@ public class PKListener implements Listener { 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") && Methods.getBoundAbility(sourceplayer) == null) { - if (Methods.isWeapon(sourceplayer.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { - return; + if (Methods.isWeapon(sourceplayer.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { + return; + } + if (ChiPassive.willChiBlock(targetplayer)) { + if (Methods.getBoundAbility(sourceplayer) != null && Methods.getBoundAbility(sourceplayer).equalsIgnoreCase("Paralyze")) { + new Paralyze(sourceplayer, targetplayer); } else { - - if (ChiPassive.willChiBlock(targetplayer)) { - ChiPassive.blockChi(targetplayer); - } + ChiPassive.blockChi(targetplayer); } } + // if (sourceplayer.getLocation().distance(targetplayer.getLocation()) <= plugin.getConfig().getDouble("Abilities.Chi.RapidPunch.Distance") && Methods.getBoundAbility(sourceplayer) == null) { + // if (Methods.isWeapon(sourceplayer.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { + // return; + // } else { + // if (ChiPassive.willChiBlock(targetplayer)) { + // ChiPassive.blockChi(targetplayer); + // + // } + // } + // } } } if (Methods.canBendPassive(sourceplayer.getName(), Element.Chi)) { diff --git a/src/com/projectkorra/ProjectKorra/chiblocking/ChiPassive.java b/src/com/projectkorra/ProjectKorra/chiblocking/ChiPassive.java index 6998f134..4ec6d095 100644 --- a/src/com/projectkorra/ProjectKorra/chiblocking/ChiPassive.java +++ b/src/com/projectkorra/ProjectKorra/chiblocking/ChiPassive.java @@ -34,10 +34,13 @@ public class ChiPassive { return true; } - public static void blockChi(Player player) { + public static void blockChi(final Player player) { Methods.getBendingPlayer(player.getName()).blockChi(); -// Bukkit.getServer().broadcastMessage("We made it"); - BendingPlayer.blockedChi.put(player.getName(), System.currentTimeMillis()); + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(ProjectKorra.plugin, new Runnable() { + public void run() { + Methods.getBendingPlayer(player.getName()).unblockChi(); + } + }, 50); } public static void handlePassive() { @@ -53,18 +56,25 @@ public class ChiPassive { } } } - for (String s: BendingPlayer.blockedChi.keySet()) { - if (!(BendingPlayer.blockedChi.get(s) + duration >= System.currentTimeMillis())) { - if (Methods.getBendingPlayer(s) == null) continue; - Methods.getBendingPlayer(s).unblockChi(); - } +// for (String s: BendingPlayer.blockedChi.keySet()) { +// +// if (Methods.getBendingPlayer(s) == null) continue; +// Bukkit.getServer().broadcastMessage("Chi Blocked for " + s); +// if (BendingPlayer.blockedChi.get(s) + duration < System.currentTimeMillis()) { +// Methods.getBendingPlayer(s).unblockChi(); +// Bukkit.getServer().broadcastMessage(s + " Chi Unblocked"); +// } +// if (!(BendingPlayer.blockedChi.get(s) + duration >= System.currentTimeMillis())) { +// if (Methods.getBendingPlayer(s) == null) continue; +// 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.");