mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Added Breathbending
Added the new Breathbending ability for air
This commit is contained in:
parent
fabcdbf599
commit
1de2ca7711
7 changed files with 247 additions and 16 deletions
|
@ -18,10 +18,10 @@ public enum StockAbilities {
|
|||
AvatarState,
|
||||
|
||||
// Project Korra
|
||||
Extraction, Smokescreen, Combustion;
|
||||
Extraction, Smokescreen, Combustion, Breathbending;
|
||||
|
||||
private enum AirbendingAbilities {
|
||||
AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst;
|
||||
AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, Breathbending;
|
||||
}
|
||||
|
||||
private enum WaterbendingAbilities {
|
||||
|
|
|
@ -189,6 +189,11 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Air.AirSwipe.Cooldown", 1500);
|
||||
config.addDefault("Abilities.Air.AirSwipe.ChargeFactor", 3);
|
||||
|
||||
config.addDefault("Abilities.Air.Breathbending.Enabled", true);
|
||||
config.addDefault("Abilities.Air.Breathbending.CanBeUsedOnUndeadMobs", true);
|
||||
config.addDefault("Abilities.Air.Breathbending.Range", 5);
|
||||
config.addDefault("Abilities.Air.Breathbending.Damage", 0.5);
|
||||
|
||||
config.addDefault("Abilities.Air.Tornado.Radius", 10);
|
||||
config.addDefault("Abilities.Air.Tornado.Height", 25);
|
||||
config.addDefault("Abilities.Air.Tornado.Range", 25);
|
||||
|
|
|
@ -4,7 +4,6 @@ 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;
|
||||
|
@ -54,6 +53,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
@ -68,6 +68,7 @@ import com.projectkorra.ProjectKorra.airbending.AirShield;
|
|||
import com.projectkorra.ProjectKorra.airbending.AirSpout;
|
||||
import com.projectkorra.ProjectKorra.airbending.AirSuction;
|
||||
import com.projectkorra.ProjectKorra.airbending.AirSwipe;
|
||||
import com.projectkorra.ProjectKorra.airbending.Breathbending;
|
||||
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
||||
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
||||
import com.projectkorra.ProjectKorra.chiblocking.HighJump;
|
||||
|
@ -153,7 +154,7 @@ public class PKListener implements Listener {
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
|
||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player) || Breathbending.isBreathbent(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -229,7 +230,7 @@ public class PKListener implements Listener {
|
|||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Methods.cooldowns.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
|
||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player) || Breathbending.isBreathbent(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +240,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) return;
|
||||
Player player = event.getPlayer();
|
||||
Methods.cooldowns.put(player.getName(), System.currentTimeMillis());
|
||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
|
||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player) || Breathbending.isBreathbent(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +306,7 @@ public class PKListener implements Listener {
|
|||
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player)) {
|
||||
if (Paralyze.isParalyzed(player) || Bloodbending.isBloodbended(player) || Breathbending.isBreathbent(player)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -346,6 +347,9 @@ public class PKListener implements Listener {
|
|||
if (abil.equalsIgnoreCase("AirShield")) {
|
||||
new AirShield(player);
|
||||
}
|
||||
if(abil.equalsIgnoreCase("Breathbending")) {
|
||||
new Breathbending(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -488,6 +492,10 @@ public class PKListener implements Listener {
|
|||
player.setVelocity(new Vector(0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
if(Breathbending.isBreathbent(player)) {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1, 100));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
|
@ -515,7 +523,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity))
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Breathbending.isBreathbent(entity))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -559,7 +567,7 @@ public class PKListener implements Listener {
|
|||
Entity entity = event.getEntity();
|
||||
if (entity != null)
|
||||
if (Paralyze.isParalyzed(entity)
|
||||
|| Bloodbending.isBloodbended(entity))
|
||||
|| Bloodbending.isBloodbended(entity) || Breathbending.isBreathbent(entity))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -568,7 +576,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity))
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Breathbending.isBreathbent(entity))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -577,7 +585,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity))
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Breathbending.isBreathbent(entity))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -586,7 +594,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity))
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Breathbending.isBreathbent(entity))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -595,7 +603,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity))
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Breathbending.isBreathbent(entity))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -604,7 +612,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity))
|
||||
if (Paralyze.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Breathbending.isBreathbent(entity))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -615,7 +623,7 @@ public class PKListener implements Listener {
|
|||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Bloodbending.isBloodbended(player) || Paralyze.isParalyzed(player)) {
|
||||
if (Bloodbending.isBloodbended(player) || Paralyze.isParalyzed(player) || Breathbending.isBreathbent(player)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -816,7 +824,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) return;
|
||||
|
||||
Player p = event.getPlayer();
|
||||
if (Tornado.getPlayers().contains(p) || Bloodbending.isBloodbended(p)
|
||||
if (Tornado.getPlayers().contains(p) || Bloodbending.isBloodbended(p) || Breathbending.isBreathbent(p)
|
||||
|| FireJet.getPlayers().contains(p)
|
||||
|| AvatarState.getPlayers().contains(p)) {
|
||||
event.setCancelled(p.getGameMode() != GameMode.CREATIVE);
|
||||
|
@ -997,6 +1005,12 @@ public class PKListener implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Breathbending.isBreathbent(e.getEntity())) {
|
||||
if(e.getCause() == DamageCause.CUSTOM) {
|
||||
Breathbending.breakBreathbend(e.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
Entity en = e.getEntity();
|
||||
if (en instanceof Player) {
|
||||
// Player p = (Player) en; // This is the player getting hurt.
|
||||
|
|
|
@ -18,6 +18,7 @@ public class AirbendingManager implements Runnable {
|
|||
AirPassive.handlePassive(Bukkit.getServer());
|
||||
AirBurst.progressAll();
|
||||
AirScooter.progressAll();
|
||||
Breathbending.progressAll();
|
||||
AirSpout.spoutAll();
|
||||
AirBubble.handleBubbles(Bukkit.getServer());
|
||||
AirSuction.progressAll();
|
||||
|
|
204
src/com/projectkorra/ProjectKorra/airbending/Breathbending.java
Normal file
204
src/com/projectkorra/ProjectKorra/airbending/Breathbending.java
Normal file
|
@ -0,0 +1,204 @@
|
|||
package com.projectkorra.ProjectKorra.airbending;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.TempPotionEffect;
|
||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||
|
||||
public class Breathbending {
|
||||
|
||||
public static ConcurrentHashMap<Player, Breathbending> instances = new ConcurrentHashMap<Player, Breathbending>();
|
||||
|
||||
ConcurrentHashMap<Entity, Location> targetentities = new ConcurrentHashMap<Entity, Location>();
|
||||
|
||||
private static boolean canBeUsedOnUndead = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Air.Breathbending.CanBeUsedOnUndeadMobs");
|
||||
private int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Air.Breathbending.Range");
|
||||
private double damage = ProjectKorra.plugin.getConfig().getDouble("Abilities.Air.Breathbending.Damage");
|
||||
|
||||
private Player player;
|
||||
|
||||
public Breathbending(Player player) {
|
||||
if (instances.containsKey(player)) {
|
||||
remove(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (AvatarState.isAvatarState(player)) {
|
||||
range = AvatarState.getValue(range);
|
||||
for (Entity entity : Methods.getEntitiesAroundPoint(player.getLocation(), range)) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
if (entity instanceof Player) {
|
||||
if (Methods.isRegionProtectedFromBuild(player, "Bloodbending", entity.getLocation()) || entity.getEntityId() == player.getEntityId())
|
||||
continue;
|
||||
}
|
||||
Methods.damageEntity(player, entity, 0);
|
||||
targetentities.put(entity, entity.getLocation().clone());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Entity target = Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
|
||||
if (target == null)
|
||||
return;
|
||||
if (!(target instanceof LivingEntity)|| Methods.isRegionProtectedFromBuild(player, "Bloodbending", target.getLocation()))
|
||||
return;
|
||||
if (!canBeUsedOnUndead && isUndead(target)) {
|
||||
return;
|
||||
}
|
||||
Methods.damageEntity(player, target, 0);
|
||||
targetentities.put(target, target.getLocation().clone());
|
||||
}
|
||||
this.player = player;
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
private void progress() {
|
||||
PotionEffect slow = new PotionEffect(PotionEffectType.SLOW, 60, 1);
|
||||
PotionEffect nausea = new PotionEffect(PotionEffectType.SLOW, 60, 1);
|
||||
|
||||
if (!player.isSneaking()) {
|
||||
remove(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canBeUsedOnUndead) {
|
||||
for (Entity entity: targetentities.keySet()) {
|
||||
if (isUndead(entity)) {
|
||||
targetentities.remove(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Methods.canBend(player.getName(), "Breathbending")) {
|
||||
remove(player);
|
||||
return;
|
||||
}
|
||||
if (Methods.getBoundAbility(player) == null) {
|
||||
remove(player);
|
||||
return;
|
||||
}
|
||||
if (!Methods.getBoundAbility(player).equalsIgnoreCase("Breathbending")) {
|
||||
remove(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (AvatarState.isAvatarState(player)) {
|
||||
ArrayList<Entity> entities = new ArrayList<Entity>();
|
||||
for (Entity entity : Methods.getEntitiesAroundPoint(player.getLocation(), range)) {
|
||||
if (Methods.isRegionProtectedFromBuild(player, "Breathbending", entity.getLocation()))
|
||||
continue;
|
||||
entities.add(entity);
|
||||
if (!targetentities.containsKey(entity) && entity instanceof LivingEntity) {
|
||||
Methods.damageEntity(player, entity, 0);
|
||||
targetentities.put(entity, entity.getLocation().clone());
|
||||
}
|
||||
if (entity instanceof LivingEntity) {
|
||||
((LivingEntity) entity).damage(damage);
|
||||
new TempPotionEffect((LivingEntity) entity, slow);
|
||||
new TempPotionEffect((LivingEntity) entity, nausea);
|
||||
entity.setFallDistance(0);
|
||||
if (entity instanceof Creature) {
|
||||
((Creature) entity).setTarget(player);
|
||||
}
|
||||
if (entity.isDead()) {
|
||||
instances.remove(player);
|
||||
}
|
||||
entity.teleport(entity);
|
||||
for(Location airsphere : Methods.getCircle(entity.getLocation(), 3, 3, false, true, 0)) {
|
||||
Methods.playAirbendingParticles(airsphere, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Entity entity : targetentities.keySet()) {
|
||||
if (!entities.contains(entity))
|
||||
targetentities.remove(entity);
|
||||
}
|
||||
} else {
|
||||
for (Entity entity : targetentities.keySet()) {
|
||||
if(entity instanceof LivingEntity) {
|
||||
((LivingEntity) entity).damage(damage);
|
||||
new TempPotionEffect((LivingEntity) entity, slow);
|
||||
new TempPotionEffect((LivingEntity) entity, nausea);
|
||||
entity.setFallDistance(0);
|
||||
if (entity instanceof Creature) {
|
||||
((Creature) entity).setTarget(null);
|
||||
}
|
||||
if (entity.isDead()) {
|
||||
instances.remove(player);
|
||||
}
|
||||
entity.teleport(entity);
|
||||
for(Location airsphere : Methods.getCircle(entity.getLocation(), 3, 3, true, true, 0)) {
|
||||
Methods.playAirbendingParticles(airsphere, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Player player : instances.keySet()) {
|
||||
instances.get(player).progress();
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove(Player player) {
|
||||
if (instances.containsKey(player)) {
|
||||
instances.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void breakBreathbend(Entity entity) {
|
||||
for (Player player : instances.keySet()) {
|
||||
if (instances.get(player).targetentities.containsKey(entity)) {
|
||||
instances.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBreathbent(Entity entity) {
|
||||
for (Player player : instances.keySet()) {
|
||||
if (instances.get(player).targetentities.containsKey(entity)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isUndead(Entity entity) {
|
||||
if (entity == null) return false;
|
||||
if (entity.getType() == EntityType.ZOMBIE
|
||||
|| entity.getType() == EntityType.BLAZE
|
||||
|| entity.getType() == EntityType.GIANT
|
||||
|| entity.getType() == EntityType.IRON_GOLEM
|
||||
|| entity.getType() == EntityType.MAGMA_CUBE
|
||||
|| entity.getType() == EntityType.PIG_ZOMBIE
|
||||
|| entity.getType() == EntityType.SKELETON
|
||||
|| entity.getType() == EntityType.SLIME
|
||||
|| entity.getType() == EntityType.SNOWMAN
|
||||
|| entity.getType() == EntityType.ZOMBIE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Location getBreathbendingLocation(Entity entity) {
|
||||
for (Player player : instances.keySet()) {
|
||||
if (instances.get(player).targetentities.containsKey(entity)) {
|
||||
return instances.get(player).targetentities.get(entity);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -138,6 +138,11 @@ Abilities:
|
|||
Speed: 25
|
||||
Cooldown: 1500
|
||||
ChargeFactor: 3
|
||||
Breathbending:
|
||||
Enabled: true
|
||||
CanBeUsedOnUndeadMobs: true
|
||||
Range: 5
|
||||
Damage: 0.5
|
||||
Tornado:
|
||||
Enabled: true
|
||||
Description: "To use, simply sneak (default: shift). This will create a swirling vortex at the targeted location. Any creature or object caught in the vortex will be launched up and out in some random direction. If another player gets caught in the vortex, the launching effect is minimal. Tornado can also be used to transport the user. If the user gets caught in his/her own tornado, his/her movements are much more manageable. Provided the user doesn't fall out of the vortex, it will take him to a maximum height and move him in the general direction he/she is looking. Skilled airbenders can scale anything with this ability."
|
||||
|
|
|
@ -20,6 +20,7 @@ permissions:
|
|||
bending.admin.choose: true
|
||||
bending.ability.AvatarState: true
|
||||
bending.ability.Bloodbending: true
|
||||
bending.ability.Breathbending: true
|
||||
bending.command.import: true
|
||||
bending.command.toggle.all: true
|
||||
bending.player:
|
||||
|
@ -51,6 +52,7 @@ permissions:
|
|||
bending.ability.AirSpout: true
|
||||
bending.ability.AirSuction: true
|
||||
bending.ability.AirSwipe: true
|
||||
bending.ability.Breathbending: true
|
||||
bending.ability.Tornado: true
|
||||
bending.air.passive: true
|
||||
bending.water:
|
||||
|
|
Loading…
Reference in a new issue