This commit is contained in:
MistPhizzle 2014-06-24 20:53:49 -04:00
parent a907a42e28
commit 26237ce090
5 changed files with 84 additions and 1 deletions

View file

@ -117,6 +117,12 @@ public class ConfigManager {
plugin.getConfig().addDefault("Abilities.Chi.Passive.FallReductionFactor", 0.5);
plugin.getConfig().addDefault("Abilities.Chi.Passive.Speed", 1);
plugin.getConfig().addDefault("Abilities.Chi.Passive.Jump", 2);
config.addDefault("Abilities.Chi.Paralyze.Enabled", true);
config.addDefault("Abilities.Chi.Paralyze.Description", "Paralyzes the target, making them unable to do anything for a short "
+ "period of time. This ability has a long cooldown.");
config.addDefault("Abilities.Chi.Paralyze.Cooldown", 15000);
config.addDefault("Abilities.Chi.Paralyze.Duration", 2000);
plugin.getConfig().addDefault("Storage.engine", "sqlite");

View file

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.airbending.Tornado;
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
public class Flight {

View file

@ -46,6 +46,7 @@ import com.projectkorra.ProjectKorra.airbending.AirBlast;
import com.projectkorra.ProjectKorra.airbending.AirBurst;
import com.projectkorra.ProjectKorra.airbending.Tornado;
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
import com.projectkorra.ProjectKorra.chiblocking.Paralyze;
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
import com.projectkorra.ProjectKorra.firebending.Enflamed;
import com.projectkorra.ProjectKorra.firebending.FireStream;
@ -122,7 +123,7 @@ public class PKListener implements Listener {
public void onPlayerSneak(PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
if (Paralyze.isParaylzed(player) || Bloodbending.isBloodbended(player)) {
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
event.setCancelled(true);
}
@ -334,6 +335,9 @@ 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) { // We don't want them to be able to block chi if an ability is bound.
@ -341,6 +345,11 @@ public class PKListener implements Listener {
ChiPassive.blockChi(p);
}
}
if (Methods.getBoundAbility(damager).equalsIgnoreCase("Paralyze")) {
if (ChiPassive.willChiBlock(p)) {
new Paralyze((Player) e.getDamager(), e.getEntity());
}
}
}
}
}

View file

@ -0,0 +1,62 @@
package com.projectkorra.ProjectKorra.chiblocking;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Element;
import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
public class Paralyze {
private static ConcurrentHashMap<Entity, Long> entities = new ConcurrentHashMap<Entity, Long>();
private static ConcurrentHashMap<Entity, Long> cooldowns = new ConcurrentHashMap<Entity, Long>();
private static final long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Chi.Paralyze.Cooldown");
private static final long duration = ProjectKorra.plugin.getConfig().getLong("Abilities.Chi.Paralyze.Duration");
public Paralyze(Player sourceplayer, Entity targetentity) {
if (Methods.getBoundAbility(sourceplayer) == null) return;
if (Methods.isBender(sourceplayer.getName(), Element.Chi)
&& Methods.getBoundAbility(sourceplayer).equalsIgnoreCase("Paralyze")
&& Methods.canBend(sourceplayer.getName(), "Paralyze")) {
if (cooldowns.containsKey(targetentity)) {
if (System.currentTimeMillis() < cooldowns.get(targetentity)
+ cooldown) {
return;
} else {
cooldowns.remove(targetentity);
}
}
paralyze(targetentity);
cooldowns.put(targetentity, System.currentTimeMillis());
}
}
private static void paralyze(Entity entity) {
entities.put(entity, System.currentTimeMillis());
if (entity instanceof Creature) {
((Creature) entity).setTarget(null);
}
}
public static boolean isParalyzed(Entity entity) {
if (entity instanceof Player) {
if (AvatarState.isAvatarState((Player) entity))
return false;
}
if (entities.containsKey(entity)) {
if (System.currentTimeMillis() < entities.get(entity) + duration) {
return true;
}
entities.remove(entity);
}
return false;
}
}

View file

@ -83,6 +83,11 @@ Abilities:
BlockChi:
Duration: 2500
DodgeChance: 25
Paralyze:
Enabled: true
Description: "Paralyzes the target, making them unable to do anything for a short period of time. This ability has a long cooldown."
Cooldown: 15000
Duration: 2000
Storage:
engine: sqlite
MySQL: