mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Paralyze
This commit is contained in:
parent
a907a42e28
commit
26237ce090
5 changed files with 84 additions and 1 deletions
|
@ -118,6 +118,12 @@ public class ConfigManager {
|
||||||
plugin.getConfig().addDefault("Abilities.Chi.Passive.Speed", 1);
|
plugin.getConfig().addDefault("Abilities.Chi.Passive.Speed", 1);
|
||||||
plugin.getConfig().addDefault("Abilities.Chi.Passive.Jump", 2);
|
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");
|
plugin.getConfig().addDefault("Storage.engine", "sqlite");
|
||||||
|
|
||||||
plugin.getConfig().addDefault("Storage.MySQL.host", "localhost");
|
plugin.getConfig().addDefault("Storage.MySQL.host", "localhost");
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
||||||
|
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
|
||||||
|
|
||||||
public class Flight {
|
public class Flight {
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import com.projectkorra.ProjectKorra.airbending.AirBlast;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirBurst;
|
import com.projectkorra.ProjectKorra.airbending.AirBurst;
|
||||||
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
||||||
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
||||||
|
import com.projectkorra.ProjectKorra.chiblocking.Paralyze;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||||
import com.projectkorra.ProjectKorra.firebending.Enflamed;
|
import com.projectkorra.ProjectKorra.firebending.Enflamed;
|
||||||
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
||||||
|
@ -122,7 +123,7 @@ public class PKListener implements Listener {
|
||||||
public void onPlayerSneak(PlayerToggleSneakEvent event) {
|
public void onPlayerSneak(PlayerToggleSneakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Paralyze.isParaylzed(player) || Bloodbending.isBloodbended(player)) {
|
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,6 +335,9 @@ 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")) {
|
||||||
|
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) { // We don't want them to be able to block chi if an ability is bound.
|
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);
|
ChiPassive.blockChi(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Methods.getBoundAbility(damager).equalsIgnoreCase("Paralyze")) {
|
||||||
|
if (ChiPassive.willChiBlock(p)) {
|
||||||
|
new Paralyze((Player) e.getDamager(), e.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
62
src/com/projectkorra/ProjectKorra/chiblocking/Paralyze.java
Normal file
62
src/com/projectkorra/ProjectKorra/chiblocking/Paralyze.java
Normal 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -83,6 +83,11 @@ Abilities:
|
||||||
BlockChi:
|
BlockChi:
|
||||||
Duration: 2500
|
Duration: 2500
|
||||||
DodgeChance: 25
|
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:
|
Storage:
|
||||||
engine: sqlite
|
engine: sqlite
|
||||||
MySQL:
|
MySQL:
|
||||||
|
|
Loading…
Reference in a new issue