From 4842970973052022e157139584b93481ffc67731 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 30 May 2015 03:06:44 +0100 Subject: [PATCH 01/25] Added checks in bindAbility and saveAbilities to stop the method if the player has a MultiAbility bound. --- .../ProjectKorra/GeneralMethods.java | 3613 +++++++++-------- 1 file changed, 1814 insertions(+), 1799 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/GeneralMethods.java b/src/com/projectkorra/ProjectKorra/GeneralMethods.java index 47e56dba..5ae6ae04 100644 --- a/src/com/projectkorra/ProjectKorra/GeneralMethods.java +++ b/src/com/projectkorra/ProjectKorra/GeneralMethods.java @@ -1,1799 +1,1814 @@ -package com.projectkorra.ProjectKorra; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import me.ryanhamshire.GriefPrevention.GriefPrevention; -import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag; -import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.FallingSand; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginManager; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; - -import com.griefcraft.lwc.LWC; -import com.griefcraft.lwc.LWCPlugin; -import com.griefcraft.model.Protection; -import com.massivecraft.factions.engine.EngineMain; -import com.massivecraft.massivecore.ps.PS; -import com.palmergames.bukkit.towny.Towny; -import com.palmergames.bukkit.towny.TownyMessaging; -import com.palmergames.bukkit.towny.TownySettings; -import com.palmergames.bukkit.towny.object.Coord; -import com.palmergames.bukkit.towny.object.PlayerCache; -import com.palmergames.bukkit.towny.object.PlayerCache.TownBlockStatus; -import com.palmergames.bukkit.towny.object.TownyPermission; -import com.palmergames.bukkit.towny.object.TownyUniverse; -import com.palmergames.bukkit.towny.object.TownyWorld; -import com.palmergames.bukkit.towny.object.WorldCoord; -import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; -import com.palmergames.bukkit.towny.war.flagwar.TownyWar; -import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig; -import com.projectkorra.ProjectKorra.Ability.AbilityModule; -import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; -import com.projectkorra.ProjectKorra.Ability.StockAbilities; -import com.projectkorra.ProjectKorra.Ability.Combo.ComboAbilityModule; -import com.projectkorra.ProjectKorra.Ability.Combo.ComboModuleManager; -import com.projectkorra.ProjectKorra.Utilities.ParticleEffect; -import com.projectkorra.ProjectKorra.airbending.AirCombo; -import com.projectkorra.ProjectKorra.airbending.AirMethods; -import com.projectkorra.ProjectKorra.airbending.AirShield; -import com.projectkorra.ProjectKorra.airbending.AirSpout; -import com.projectkorra.ProjectKorra.airbending.AirSwipe; -import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; -import com.projectkorra.ProjectKorra.chiblocking.Paralyze; -import com.projectkorra.ProjectKorra.earthbending.EarthBlast; -import com.projectkorra.ProjectKorra.earthbending.EarthMethods; -import com.projectkorra.ProjectKorra.earthbending.EarthPassive; -import com.projectkorra.ProjectKorra.earthbending.MetalClips; -import com.projectkorra.ProjectKorra.firebending.Combustion; -import com.projectkorra.ProjectKorra.firebending.FireBlast; -import com.projectkorra.ProjectKorra.firebending.FireCombo; -import com.projectkorra.ProjectKorra.firebending.FireMethods; -import com.projectkorra.ProjectKorra.firebending.FireShield; -import com.projectkorra.ProjectKorra.waterbending.Bloodbending; -import com.projectkorra.ProjectKorra.waterbending.FreezeMelt; -import com.projectkorra.ProjectKorra.waterbending.WaterManipulation; -import com.projectkorra.ProjectKorra.waterbending.WaterMethods; -import com.projectkorra.ProjectKorra.waterbending.WaterSpout; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.flags.DefaultFlag; - -import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; - - -@SuppressWarnings("deprecation") -public class GeneralMethods { - - static ProjectKorra plugin; - private static FileConfiguration config = ProjectKorra.plugin.getConfig(); - - public static Random rand = new Random(); - public static double CACHE_TIME = config.getDouble("Properties.RegionProtection.CacheBlockTime"); - - public static ConcurrentHashMap cooldowns = new ConcurrentHashMap(); - // Represents PlayerName, previously checked blocks, and whether they were true or false - public static ConcurrentHashMap> blockProtectionCache = new ConcurrentHashMap>(); - - public static Integer[] nonOpaque = {0, 6, 8, 9, 10, 11, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 66, 68, 69, 70, 72, - 75, 76, 77, 78, 83, 90, 93, 94, 104, 105, 106, 111, 115, 119, 127, 131, 132, 175}; - - // Stands for toggled = false while logging out - public static List toggedOut = new ArrayList(); - - /** - * Checks to see if an AbilityExists. Uses method {@link #getAbility(String)} to check if it exists. - * @param string Ability Name - * @return true if ability exists - */ - public static boolean abilityExists(String string) { - for (String st: AbilityModuleManager.abilities) { - if (string.equalsIgnoreCase(st)) - return true; - } - return false; - } - - public static boolean comboExists(String string) - { - for(ComboAbilityModule c : ComboModuleManager.combo) - if(string.equalsIgnoreCase(c.getName())) - return true; - - return false; - } - - public ComboAbilityModule getCombo(String name) - { - for(ComboAbilityModule c : ComboModuleManager.combo) - if(name.equalsIgnoreCase(c.getName())) - return c; - - return null; - } - - public static boolean isDisabledStockAbility(String string){ - for (String st : AbilityModuleManager.disabledStockAbilities){ - if (string.equalsIgnoreCase(st)) - return true; - } - return false; - } - - /** - * Binds a Ability to the hotbar slot that the player is on. - * @param player The player to bind to - * @param ability The ability name to Bind - * @see {@link #bindAbility(Player, String, int)} - */ - public static void bindAbility(Player player, String ability) { - int slot = player.getInventory().getHeldItemSlot() + 1; - bindAbility(player,ability, slot); - } - - /** - * Binds a Ability to a specific hotbar slot. - * @param player The player to bind to - * @param ability - * @param slot - * @see {@link #bindAbility(Player, String)} - */ - public static void bindAbility(Player player, String ability, int slot) { - BendingPlayer bPlayer = getBendingPlayer(player.getName()); - bPlayer.getAbilities().put(slot, ability); - if (AirMethods.isAirAbility(ability)) { - player.sendMessage(AirMethods.getAirColor() + "Succesfully bound " + ability + " to slot " + slot); - } - else if (WaterMethods.isWaterAbility(ability)) { - player.sendMessage(WaterMethods.getWaterColor() + "Succesfully bound " + ability + " to slot " + slot); - } - else if (EarthMethods.isEarthAbility(ability)) { - player.sendMessage(EarthMethods.getEarthColor() + "Succesfully bound " + ability + " to slot " + slot); - } - else if (FireMethods.isFireAbility(ability)) { - player.sendMessage(FireMethods.getFireColor() + "Succesfully bound " + ability + " to slot " + slot); - } - else if (ChiMethods.isChiAbility(ability)) { - player.sendMessage(ChiMethods.getChiColor() + "Succesfully bound " + ability + " to slot " + slot); - } else { - player.sendMessage(getAvatarColor() + "Successfully bound " + ability + " to slot " + slot); - } - - saveAbility(bPlayer, slot, ability); - } - - /** - * Breaks a block and sets it to {@link Material#AIR AIR}. - * @param block The block to break - */ - public static void breakBlock(Block block) { - block.breakNaturally(new ItemStack(Material.AIR)); - } - - public static boolean canBind(String player, String ability) { - Player p = Bukkit.getPlayer(player); - if (p == null) return false; - if (!p.hasPermission("bending.ability." + ability)) return false; - if (AirMethods.isAirAbility(ability) && !isBender(player, Element.Air)) return false; - if (WaterMethods.isWaterAbility(ability) && !isBender(player, Element.Water)) return false; - if (EarthMethods.isEarthAbility(ability) && !isBender(player, Element.Earth)) return false; - if (FireMethods.isFireAbility(ability) && !isBender(player, Element.Fire)) return false; - if (ChiMethods.isChiAbility(ability) && !isBender(player, Element.Chi)) return false; - return true; - } - - /** - * Checks to see if a Player can bend a specific Ability. - * @param player The player name to check - * @param ability The Ability name to check - * @return true If player can bend specified ability and has the permissions to do so - */ - public static boolean canBend(String player, String ability) { - BendingPlayer bPlayer = getBendingPlayer(player); - Player p = Bukkit.getPlayer(player); - if (bPlayer == null) return false; - if (plugin.getConfig().getStringList("Properties.DisabledWorlds") != null && plugin.getConfig().getStringList("Properties.DisabledWorlds").contains(p.getWorld().getName())) return false; - if (Commands.isToggledForAll) return false; - if (!bPlayer.isToggled) return false; - if (p == null) return false; - if (cooldowns.containsKey(p.getName())) { - if (cooldowns.get(p.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) { - return false; - } - cooldowns.remove(p.getName()); - } - if (bPlayer.blockedChi) return false; - // if (bPlayer.isChiBlocked()) return false; - if (!p.hasPermission("bending.ability." + ability)) return false; - if (AirMethods.isAirAbility(ability) && !isBender(player, Element.Air)) return false; - if (WaterMethods.isWaterAbility(ability) && !isBender(player, Element.Water)) return false; - if (EarthMethods.isEarthAbility(ability) && !isBender(player, Element.Earth)) return false; - if (FireMethods.isFireAbility(ability) && !isBender(player, Element.Fire)) return false; - if (ChiMethods.isChiAbility(ability) && !isBender(player, Element.Chi)) return false; - -// if (isFlightAbility(ability) && !canAirFlight(plugin.getServer().getPlayer(player))) return false; -// if (isSpiritualProjectionAbility(ability) && !canUseSpiritualProjection(plugin.getServer().getPlayer(player))) return false; -// if (isCombustionbendingAbility(ability) && !canCombustionbend(plugin.getServer().getPlayer(player))) return false; -// if (isLightningbendingAbility(ability) && !canLightningbend(plugin.getServer().getPlayer(player))) return false; -// if (isSandbendingAbility(ability) && !canSandbend(plugin.getServer().getPlayer(player))) return false; -// if (isMetalbendingAbility(ability) && !canMetalbend(plugin.getServer().getPlayer(player))) return false; -// if (isLavabendingAbility(ability) && !canLavabend(plugin.getServer().getPlayer(player))) return false; -// if (isIcebendingAbility(ability) && !canIcebend(plugin.getServer().getPlayer(player))) return false; -// if (isHealingAbility(ability) && !canWaterHeal(plugin.getServer().getPlayer(player))) return false; -// if (isPlantbendingAbility(ability) && !canPlantbend(plugin.getServer().getPlayer(player))) return false; -// if (isBloodbendingAbility(ability) && !canBloodbend(plugin.getServer().getPlayer(player))) return false; - - - - if (isRegionProtectedFromBuild(p, ability, p.getLocation())) return false; - if (Paralyze.isParalyzed(p) || Bloodbending.isBloodbended(p)) return false; - if (MetalClips.isControlled(p)) return false; - if (BendingManager.events.get(p.getWorld()) != null && BendingManager.events.get(p.getWorld()).equalsIgnoreCase("SolarEclipse") && FireMethods.isFireAbility(ability)) return false; - if (BendingManager.events.get(p.getWorld()) != null && BendingManager.events.get(p.getWorld()).equalsIgnoreCase("LunarEclipse") && WaterMethods.isWaterAbility(ability)) return false; - return true; - } - - public static boolean canBendPassive(String player, Element element) { - BendingPlayer bPlayer = getBendingPlayer(player); - Player p = Bukkit.getPlayer(player); - if (bPlayer == null) return false; - if (p == null) return false; - if (!p.hasPermission("bending." + element.toString().toLowerCase() + ".passive")) return false; - if (!bPlayer.isToggled) return false; - if (!bPlayer.hasElement(element)) return false; - if (isRegionProtectedFromBuild(p, null, p.getLocation())) return false; - if (bPlayer.blockedChi) return false; - return true; - } - - public static boolean isSubAbility(String ability) { - if (AbilityModuleManager.subabilities.contains(ability)) return true; - return false; - } - - /** - * Creates a {@link BendingPlayer} with the data from the database. This runs when a player logs in. - * @param uuid The UUID of the player - * @param player The player name - * @throws SQLException - */ - public static void createBendingPlayer(final UUID uuid, final String player) { - new BukkitRunnable() { - @Override - public void run() { - createBendingPlayerAsynchronously(uuid, player); - } - }.runTaskAsynchronously(ProjectKorra.plugin); - } - - private static void createBendingPlayerAsynchronously(final UUID uuid, final String player) { - ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + uuid.toString() + "'"); - try { - if (!rs2.next()) { // Data doesn't exist, we want a completely new - // player. - new BendingPlayer(uuid, player, new ArrayList(), new HashMap(), false); - DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player) VALUES ('" + uuid.toString() + "', '" + player + "')"); - ProjectKorra.log.info("Created new BendingPlayer for " + player); - } else { - // The player has at least played before. - String player2 = rs2.getString("player"); - if (!player.equalsIgnoreCase(player2)) { - DBConnection.sql.modifyQuery("UPDATE pk_players SET player = '" + player + "' WHERE uuid = '" + uuid.toString() + "'"); - // They have changed names. - - ProjectKorra.log.info("Updating Player Name for " + player); - } - - String element = rs2.getString("element"); - String permaremoved = rs2.getString("permaremoved"); - boolean p = false; - final ArrayList elements = new ArrayList(); - if (element != null) { // Player has an element. - if (element.contains("a")) - elements.add(Element.Air); - if (element.contains("w")) - elements.add(Element.Water); - if (element.contains("e")) - elements.add(Element.Earth); - if (element.contains("f")) - elements.add(Element.Fire); - if (element.contains("c")) - elements.add(Element.Chi); - } - - final HashMap abilities = new HashMap(); - for (int i = 1; i <= 9; i++) { - String slot = rs2.getString("slot" + i); - - if (slot != null) { - abilities.put(i, slot); - } - } - - p = (permaremoved == null ? false : (permaremoved.equals("true") ? true : (permaremoved.equals("false") ? false : p))); - - final boolean boolean_p = p; - new BukkitRunnable() { - @Override - public void run() { - new BendingPlayer(uuid, player, elements, abilities, boolean_p); - } - }.runTask(ProjectKorra.plugin); - } - } catch (SQLException ex) { - ex.printStackTrace(); - } - } - - /** - * Damages an Entity by amount of damage specified. Starts a {@link EntityDamageByEntityEvent}. - * @param player The player dealing the damage - * @param entity The entity that is receiving the damage - * @param damage The amount of damage to deal - */ - public static void damageEntity(Player player, Entity entity, double damage) { - if (entity instanceof LivingEntity) { - if (entity instanceof Player) { - if (Commands.invincible.contains(((Player) entity).getName())) return; - } - if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { - NCPExemptionManager.exemptPermanently(player, CheckType.FIGHT_REACH); - } - ((LivingEntity) entity).damage(damage, player); - ((LivingEntity) entity).setLastDamageCause( - new EntityDamageByEntityEvent(player, entity, DamageCause.CUSTOM, damage)); - if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { - NCPExemptionManager.unexempt(player); - } - } - } - - /** - * Deserializes the configuration file "bendingPlayers.yml" of the old BendingPlugin and creates a converted.yml ready for conversion. - * @throws IOException If the "bendingPlayers.yml" file is not found - */ - public static void deserializeFile() { - File readFile = new File(".", "bendingPlayers.yml"); - File writeFile = new File(".", "converted.yml"); - if (readFile.exists()) { - try ( - DataInputStream input = new DataInputStream(new FileInputStream(readFile)); - BufferedReader reader = new BufferedReader(new InputStreamReader(input)); - - DataOutputStream output = new DataOutputStream(new FileOutputStream(writeFile)); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output)); - ){ - - String line; - while ((line = reader.readLine()) != null) { - if (!line.trim().contains("==: BendingPlayer")) { - writer.write(line + "\n"); - } - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - /** - * Drops a {@code Collection} of items on a specified block. - * @param block The block to drop items on. - * @param items The items to drop. - */ - public static void dropItems(Block block, Collection items) { - for (ItemStack item : items) - block.getWorld().dropItem(block.getLocation(), item); - } - - /** - * Gets the ability from specified ability name. - * @param string The ability name - * @return Ability name if found in {@link AbilityModuleManager#abilities} - *

- * else null - *

- */ - public static String getAbility(String string) { - for (String st: AbilityModuleManager.abilities) { - if (st.equalsIgnoreCase(string)) return st; - } - return null; - } - - /** - * Gets the Element color from the Ability name specified. - * @param ability The ability name - *

- * @return - * {@link #getChiColor()}
- * {@link #getAirColor()}
- * {@link #getWaterColor()}
- * {@link #getEarthColor()}
- * {@link #getFireColor()}
- * else {@link #getAvatarColor()} - *

- */ - public static ChatColor getAbilityColor(String ability) { - if (AbilityModuleManager.chiabilities.contains(ability)) return ChiMethods.getChiColor(); - if (AbilityModuleManager.airbendingabilities.contains(ability)) - { - if (AbilityModuleManager.subabilities.contains(ability)) return getSubBendingColor(Element.Air); - return AirMethods.getAirColor(); - } - if (AbilityModuleManager.waterbendingabilities.contains(ability)) - { - if (AbilityModuleManager.subabilities.contains(ability)) return getSubBendingColor(Element.Water); - return WaterMethods.getWaterColor(); - } - if (AbilityModuleManager.earthbendingabilities.contains(ability)) - { - if (AbilityModuleManager.subabilities.contains(ability)) return getSubBendingColor(Element.Earth); - return EarthMethods.getEarthColor(); - } - if (AbilityModuleManager.firebendingabilities.contains(ability)) - { - if (AbilityModuleManager.subabilities.contains(ability)) return getSubBendingColor(Element.Fire); - return FireMethods.getFireColor(); - } - - else return getAvatarColor(); - } - - /** - * Gets the AvatarColor from the config. - * @return Config specified ChatColor - */ - public static ChatColor getAvatarColor() { - return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Avatar")); - } - - /** - * Gets a {@link BendingPlayer} from specified player name. - * @param player The name of the Player - * @return The BendingPlayer object if {@link BendingPlayer#players} contains the player name - */ - public static BendingPlayer getBendingPlayer(String player) { - return BendingPlayer.players.get(player); - } - - /** - * Gets a {@code List} within the specified radius around the specified location. - * @param location The base location - * @param radius The block radius from location to include within the list of blocks - * @return The list of Blocks - */ - public static List getBlocksAroundPoint(Location location, double radius) { - List blocks = new ArrayList(); - - int xorg = location.getBlockX(); - int yorg = location.getBlockY(); - int zorg = location.getBlockZ(); - - int r = (int) radius * 4; - - for (int x = xorg - r; x <= xorg + r; x++) { - for (int y = yorg - r; y <= yorg + r; y++) { - for (int z = zorg - r; z <= zorg + r; z++) { - Block block = location.getWorld().getBlockAt(x, y, z); - if (block.getLocation().distance(location) <= radius) { - blocks.add(block); - } - } - } - } - - return blocks; - } - - /** - * Gets the Ability bound to the slot that the player is in. - * @param player The player to check - * @return The Ability name bounded to the slot - *

- * else null - *

- */ - public static String getBoundAbility(Player player) { - BendingPlayer bPlayer = getBendingPlayer(player.getName()); - if (bPlayer == null) return null; - - int slot = player.getInventory().getHeldItemSlot() + 1; - return bPlayer.getAbilities().get(slot); - } - - public static long getGlobalCooldown() { - return plugin.getConfig().getLong("Properties.GlobalCooldown"); - } - - public static BlockFace getCardinalDirection(Vector vector) { - BlockFace[] faces = { BlockFace.NORTH, BlockFace.NORTH_EAST, - BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, - BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST }; - Vector n, ne, e, se, s, sw, w, nw; - w = new Vector(-1, 0, 0); - n = new Vector(0, 0, -1); - s = n.clone().multiply(-1); - e = w.clone().multiply(-1); - ne = n.clone().add(e.clone()).normalize(); - se = s.clone().add(e.clone()).normalize(); - nw = n.clone().add(w.clone()).normalize(); - sw = s.clone().add(w.clone()).normalize(); - - Vector[] vectors = { n, ne, e, se, s, sw, w, nw }; - - double comp = 0; - int besti = 0; - for (int i = 0; i < vectors.length; i++) { - double dot = vector.dot(vectors[i]); - if (dot > comp) { - comp = dot; - besti = i; - } - } - - return faces[besti]; - - } - - public static List getCircle(Location loc, int radius, int height, boolean hollow, boolean sphere, int plusY){ - List circleblocks = new ArrayList(); - int cx = loc.getBlockX(); - int cy = loc.getBlockY(); - int cz = loc.getBlockZ(); - - for(int x = cx - radius; x <= cx + radius; x++){ - for (int z = cz - radius; z <= cz + radius; z++){ - for(int y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height); y++){ - double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0); - - if(dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1))){ - Location l = new Location(loc.getWorld(), x, y + plusY, z); - circleblocks.add(l); - } - } - } - } - - return circleblocks; - } - - public static Vector getDirection(Location location, Location destination) { - double x1, y1, z1; - double x0, y0, z0; - - x1 = destination.getX(); - y1 = destination.getY(); - z1 = destination.getZ(); - - x0 = location.getX(); - y0 = location.getY(); - z0 = location.getZ(); - - return new Vector(x1 - x0, y1 - y0, z1 - z0); - - } - - public static double getDistanceFromLine(Vector line, Location pointonline, - Location point) { - - Vector AP = new Vector(); - double Ax, Ay, Az; - Ax = pointonline.getX(); - Ay = pointonline.getY(); - Az = pointonline.getZ(); - - double Px, Py, Pz; - Px = point.getX(); - Py = point.getY(); - Pz = point.getZ(); - - AP.setX(Px - Ax); - AP.setY(Py - Ay); - AP.setZ(Pz - Az); - - return (AP.crossProduct(line).length()) / (line.length()); - } - - /** - * Gets a {@code Collection} of item drops from a single block. - * @param block The single block - * @param type The Material type to change the block into - * @param data The block data to change the block into - * @param breakitem Unused - * @return The item drops fromt the specified block - */ - public static Collection getDrops(Block block, Material type, byte data, ItemStack breakitem) { - BlockState tempstate = block.getState(); - block.setType(type); - block.setData(data); - Collection item = block.getDrops(); - tempstate.update(true); - return item; - } - - /** - * Gets a {@code List} of entities around a specified radius from the specified area - * @param location The base location - * @param radius The radius of blocks to look for entities from the location - * @return A list of entities around a point - */ - public static List getEntitiesAroundPoint(Location location, double radius) { - - List entities = location.getWorld().getEntities(); - List list = location.getWorld().getEntities(); - - for (Entity entity : entities) { - if (entity.getWorld() != location.getWorld()) { - list.remove(entity); - } else if (entity.getLocation().distance(location) > radius) { - list.remove(entity); - } - } - - return list; - - } - - @SuppressWarnings("incomplete-switch") - public static int getIntCardinalDirection(Vector vector) { - BlockFace face = getCardinalDirection(vector); - - switch (face) { - case SOUTH: - return 7; - case SOUTH_WEST: - return 6; - case WEST: - return 3; - case NORTH_WEST: - return 0; - case NORTH: - return 1; - case NORTH_EAST: - return 2; - case EAST: - return 5; - case SOUTH_EAST: - return 8; - } - - return 4; - - } - - @SuppressWarnings("incomplete-switch") - public static ChatColor getSubBendingColor(Element element) - { - switch(element) - { - case Fire: - return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.FireSub")); - case Air: - return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.AirSub")); - case Water: - return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.WaterSub")); - case Earth: - return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.EarthSub")); - } - - return getAvatarColor(); - } - - public static Vector getOrthogonalVector(Vector axis, double degrees, double length) { - - Vector ortho = new Vector(axis.getY(), -axis.getX(), 0); - ortho = ortho.normalize(); - ortho = ortho.multiply(length); - - return rotateVectorAroundVector(axis, ortho, degrees); - - } - - public static Location getPointOnLine(Location origin, Location target, double distance) { - return origin.clone().add( - getDirection(origin, target).normalize().multiply(distance)); - - } - - @SuppressWarnings("unused") - public static Entity getTargetedEntity(Player player, double range, List avoid) { - double longestr = range + 1; - Entity target = null; - Location origin = player.getEyeLocation(); - Vector direction = player.getEyeLocation().getDirection().normalize(); - for (Entity entity : origin.getWorld().getEntities()) { - if (avoid.contains(entity)) - continue; - if (entity.getLocation().distance(origin) < longestr - && getDistanceFromLine(direction, origin, entity.getLocation()) < 2 - && (entity instanceof LivingEntity) - && entity.getEntityId() != player.getEntityId() - && entity.getLocation().distance(origin.clone().add(direction)) < - entity.getLocation().distance(origin.clone().add(direction.clone().multiply(-1)))) { - target = entity; - longestr = entity.getLocation().distance(origin); - } - } - if(target != null) { - List blklist = new ArrayList(); - blklist = GeneralMethods.getBlocksAlongLine(player.getLocation(), target.getLocation(), player.getWorld()); - for(Block isair:blklist) - { - if(GeneralMethods.isObstructed(origin, target.getLocation())) { - target = null; - break; - } - } - } - return target; - } - - public static List getBlocksAlongLine(Location ploc, Location tloc, World w) { - List blocks = new ArrayList(); - - //Next we will name each coordinate - int x1 = ploc.getBlockX(); - int y1 = ploc.getBlockY(); - int z1 = ploc.getBlockZ(); - - int x2 = tloc.getBlockX(); - int y2 = tloc.getBlockY(); - int z2 = tloc.getBlockZ(); - - //Then we create the following integers - int xMin, yMin, zMin; - int xMax, yMax, zMax; - int x, y, z; - - //Now we need to make sure xMin is always lower then xMax - if(x1 > x2){ //If x1 is a higher number then x2 - xMin = x2; - xMax = x1; - }else{ - xMin = x1; - xMax = x2; - } - //Same with Y - if(y1 > y2){ - yMin = y2; - yMax = y1; - }else{ - yMin = y1; - yMax = y2; - } - - //And Z - if(z1 > z2){ - zMin = z2; - zMax = z1; - }else{ - zMin = z1; - zMax = z2; - } - - //Now it's time for the loop - for(x = xMin; x <= xMax; x ++){ - for(y = yMin; y <= yMax; y ++){ - for(z = zMin; z <= zMax; z ++){ - Block b = new Location(w, x, y, z).getBlock(); - blocks.add(b); - } - } - } - - //And last but not least, we return with the list - return blocks; - } - - public static Location getTargetedLocation(Player player, double originselectrange, Integer... nonOpaque2) { - Location origin = player.getEyeLocation(); - Vector direction = origin.getDirection(); - - HashSet trans = new HashSet(); - trans.add((byte) 0); - - if (nonOpaque2 == null) { - trans = null; - } else { - for (int i : nonOpaque2) { - trans.add((byte) i); - } - } - - Block block = player.getTargetBlock(trans, (int) originselectrange + 1); - double distance = block.getLocation().distance(origin) - 1.5; - Location location = origin.add(direction.multiply(distance)); - - return location; - } - - public static Location getTargetedLocation(Player player, int range) { - return getTargetedLocation(player, range, 0); - } - - public static boolean hasPermission(Player player, String ability) { - if (player.hasPermission("bending.ability." + ability) && canBind(player.getName(), ability)) return true; - return false; - } - - public static boolean canView(Player player, String ability) { - if (player.hasPermission("bending.ability." + ability)) return true; - return false; - } - - public static boolean isAbilityInstalled(String name, String author) { - String ability = getAbility(name); - if (ability == null) return false; - if (AbilityModuleManager.authors.get(name).equalsIgnoreCase(author)) return true; - return false; - } - - public static boolean isAdjacentToThreeOrMoreSources(Block block) { - if (TempBlock.isTempBlock(block)) - return false; - int sources = 0; - byte full = 0x0; - BlockFace[] faces = { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, - BlockFace.SOUTH }; - for (BlockFace face : faces) { - Block blocki = block.getRelative(face); - if ((blocki.getType() == Material.LAVA || blocki.getType() == Material.STATIONARY_LAVA) - && blocki.getData() == full - && EarthPassive.canPhysicsChange(blocki)) - sources++; - if ((blocki.getType() == Material.WATER || blocki.getType() == Material.STATIONARY_WATER) - && blocki.getData() == full - && WaterManipulation.canPhysicsChange(blocki)) - sources++; - if (FreezeMelt.frozenblocks.containsKey(blocki)) { - //if (FreezeMelt.frozenblocks.get(blocki) == full) - //sources++; - } else if (blocki.getType() == Material.ICE) { - //sources++; - } - } - if (sources >= 2) - return true; - return false; - } - - public static boolean isBender(String player, Element element) { - BendingPlayer bPlayer = getBendingPlayer(player); - if (bPlayer == null) return false; - if (bPlayer.hasElement(element)) return true; - return false; - } - - public static boolean isHarmlessAbility(String ability) { - return AbilityModuleManager.harmlessabilities.contains(ability); - } - - public static boolean isImportEnabled() { - return plugin.getConfig().getBoolean("Properties.ImportEnabled"); - } - - public static boolean isObstructed(Location location1, Location location2) { - Vector loc1 = location1.toVector(); - Vector loc2 = location2.toVector(); - - Vector direction = loc2.subtract(loc1); - direction.normalize(); - - Location loc; - - double max = location1.distance(location2); - - for (double i = 0; i <= max; i++) { - loc = location1.clone().add(direction.clone().multiply(i)); - Material type = loc.getBlock().getType(); - if (type != Material.AIR - && !Arrays.asList(EarthMethods.getTransparentEarthbending()).contains( - type.getId())) - return true; - } - - return false; - } - - /* - * isRegionProtectedFromBuild is one of the most server intensive methods in the - * plugin. It uses a blockCache that keeps track of recent blocks that may have already been checked. - * Abilities like TremorSense call this ability 5 times per tick even though it only needs to check a single block, - * instead of doing all 5 of those checks this method will now look in the map first. - */ - public static boolean isRegionProtectedFromBuild(Player player, String ability, Location loc) { - if(!blockProtectionCache.containsKey(player.getName())) - blockProtectionCache.put(player.getName(), new ConcurrentHashMap()); - - ConcurrentHashMap blockMap = blockProtectionCache.get(player.getName()); - Block block = loc.getBlock(); - if(blockMap.containsKey(block)) { - BlockCacheElement elem = blockMap.get(block); - - // both abilities must be equal to each other to use the cache - if((ability == null && elem.getAbility() == null) - || (ability != null && elem.getAbility() != null && elem.getAbility().equals(ability))) { - return elem.isAllowed(); - } - } - - boolean value = isRegionProtectedFromBuildPostCache(player, ability, loc); - blockMap.put(block, new BlockCacheElement(player, block, ability, value, System.currentTimeMillis())); - return value; - } - - public static boolean isRegionProtectedFromBuildPostCache(Player player, String ability, Location loc) { - - boolean allowharmless = plugin.getConfig().getBoolean("Properties.RegionProtection.AllowHarmlessAbilities"); - boolean respectWorldGuard = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectWorldGuard"); - boolean respectPreciousStones = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectPreciousStones"); - boolean respectFactions = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectFactions"); - boolean respectTowny = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectTowny"); - boolean respectGriefPrevention = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectGriefPrevention"); - boolean respectLWC = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectLWC"); - - Set ignite = AbilityModuleManager.igniteabilities; - Set explode = AbilityModuleManager.explodeabilities; - - if (ability == null && allowharmless) - return false; - if (isHarmlessAbility(ability) && allowharmless) - return false; - - PluginManager pm = Bukkit.getPluginManager(); - - Plugin wgp = pm.getPlugin("WorldGuard"); - Plugin psp = pm.getPlugin("PreciousStones"); - Plugin fcp = pm.getPlugin("Factions"); - Plugin twnp = pm.getPlugin("Towny"); - Plugin gpp = pm.getPlugin("GriefPrevention"); - Plugin massivecore = pm.getPlugin("MassiveCore"); - Plugin lwc = pm.getPlugin("LWC"); - - - - for (Location location : new Location[] { loc, player.getLocation() }) { - World world = location.getWorld(); - - if (lwc != null && respectLWC) { - LWCPlugin lwcp = (LWCPlugin) lwc; - LWC lwc2 = lwcp.getLWC(); - Protection protection = lwc2.getProtectionCache().getProtection(location.getBlock()); - if (protection != null) { - if (!lwc2.canAccessProtection(player, protection)) { - return true; - } - } - } - if (wgp != null && respectWorldGuard && !player.hasPermission("worldguard.region.bypass." + world.getName())) { - WorldGuardPlugin wg = (WorldGuardPlugin) Bukkit - .getPluginManager().getPlugin("WorldGuard"); - if (!player.isOnline()) - return true; - - if (ignite.contains(ability)) { - if (!wg.hasPermission(player, "worldguard.override.lighter")) { - if (wg.getGlobalStateManager().get(world).blockLighter) - return true; - } - } - if (explode.contains(ability)) { - if (wg.getGlobalStateManager().get(location.getWorld()).blockTNTExplosions) - return true; - if (!wg.getRegionContainer().createQuery().testBuild(location, player, DefaultFlag.TNT)) - return true; - } - - if (!wg.canBuild(player, location.getBlock())) { - return true; - } - } - - if (psp != null && respectPreciousStones) { - PreciousStones ps = (PreciousStones) psp; - - if (ignite.contains(ability)) { - if (ps.getForceFieldManager().hasSourceField(location, - FieldFlag.PREVENT_FIRE)) - return true; - } - if (explode.contains(ability)) { - if (ps.getForceFieldManager().hasSourceField(location, - FieldFlag.PREVENT_EXPLOSIONS)) - return true; - } - -// if (ps.getForceFieldManager().hasSourceField(location, -// FieldFlag.PREVENT_PLACE)) -// return true; - - if (!PreciousStones.API().canBreak(player, location)) { - return true; - } - } - - if (fcp != null && massivecore != null && respectFactions) { - if (!EngineMain.canPlayerBuildAt(player, PS.valueOf(loc.getBlock()), false)) { - return true; - } else { - return false; - } - } - - if (twnp != null && respectTowny) { - Towny twn = (Towny) twnp; - - WorldCoord worldCoord; - - try { - TownyWorld tWorld = TownyUniverse.getDataSource().getWorld( - world.getName()); - worldCoord = new WorldCoord(tWorld.getName(), - Coord.parseCoord(location)); - - boolean bBuild = PlayerCacheUtil.getCachePermission(player, - location, 3, (byte) 0, - TownyPermission.ActionType.BUILD); - - if (ignite.contains(ability)) { - - } - - if (explode.contains(ability)) { - - } - - if (!bBuild) { - PlayerCache cache = twn.getCache(player); - TownBlockStatus status = cache.getStatus(); - - if (((status == TownBlockStatus.ENEMY) && TownyWarConfig - .isAllowingAttacks())) { - - try { - TownyWar.callAttackCellEvent(twn, player, - location.getBlock(), worldCoord); - } catch (Exception e) { - TownyMessaging.sendErrorMsg(player, - e.getMessage()); - } - - return true; - - } else if (status == TownBlockStatus.WARZONE) { - } else { - return true; - } - - if ((cache.hasBlockErrMsg())) - TownyMessaging.sendErrorMsg(player, - cache.getBlockErrMsg()); - } - - } catch (Exception e1) { - TownyMessaging.sendErrorMsg(player, TownySettings - .getLangString("msg_err_not_configured")); - } - - } - - if (gpp != null && respectGriefPrevention) { - Material type = player.getWorld().getBlockAt(location).getType(); - if (type == null) type = Material.AIR; - String reason = GriefPrevention.instance.allowBuild(player, location); // WORKING with WorldGuard 6.0 BETA 4 - - - if (ignite.contains(ability)) { - - } - - if (explode.contains(ability)) { - - } - - if (reason != null) - return true; - } - } - - return false; - } - - - public static boolean isSolid(Block block) { - if (Arrays.asList(nonOpaque).contains(block.getTypeId())) return false; - return true; - } - - public static boolean isWeapon(Material mat) { - if (mat == null) return false; - if (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE - || mat == Material.WOOD_SPADE || mat == Material.WOOD_SWORD - - || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE - || mat == Material.STONE_SPADE || mat == Material.STONE_SWORD - - || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE - || mat == Material.IRON_SWORD || mat == Material.IRON_SPADE - - || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE - || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SPADE) - return true; - return false; - } - - public static Collection getPlayersAroundPoint(Location location, double distance) { - Collection players = new HashSet(); - for (Player player: Bukkit.getOnlinePlayers()) { - if (player.getLocation().distance(location) <= distance) { - players.add(player); - } - } - return players; - } - - public static void displayColoredParticle(Location loc, String hexVal) { - int R = 0; - int G = 0; - int B = 0; - - if(hexVal.length() <= 6){ - R = Integer.valueOf(hexVal.substring( 0, 2 ), 16); - G = Integer.valueOf(hexVal.substring( 2, 4 ), 16); - B = Integer.valueOf(hexVal.substring( 4, 6 ), 16); - if(R <= 0) - R=1; - }else if(hexVal.length() <= 7 && hexVal.substring(0, 1).equals("#")){ - R = Integer.valueOf(hexVal.substring( 1, 3 ), 16); - G = Integer.valueOf(hexVal.substring( 3, 5 ), 16); - B = Integer.valueOf(hexVal.substring( 5, 7 ), 16); - if(R <= 0) - R=1; - } - - ParticleEffect.RED_DUST.display((float) R, (float) G, (float) B, 0.004F, 0, loc, 256D); - } - - public static void displayColoredParticle(Location loc, String hexVal, float xOffset, float yOffset, float zOffset) { - int R = 0; - int G = 0; - int B = 0; - - if(hexVal.length() <= 6){ - R = Integer.valueOf(hexVal.substring( 0, 2 ), 16); - G = Integer.valueOf(hexVal.substring( 2, 4 ), 16); - B = Integer.valueOf(hexVal.substring( 4, 6 ), 16); - if(R <= 0) - R=1; - }else if(hexVal.length() <= 7 && hexVal.substring(0, 1).equals("#")){ - R = Integer.valueOf(hexVal.substring( 1, 3 ), 16); - G = Integer.valueOf(hexVal.substring( 3, 5 ), 16); - B = Integer.valueOf(hexVal.substring( 5, 7 ), 16); - if(R <= 0) - R=1; - } - - loc.setX(loc.getX() + Math.random() * (xOffset/2 - -(xOffset/2))); - loc.setY(loc.getY() + Math.random() * (yOffset/2 - -(yOffset/2))); - loc.setZ(loc.getZ() + Math.random() * (zOffset/2 - -(zOffset/2))); - - ParticleEffect.RED_DUST.display((float) R, (float) G, (float) B, 0.004F, 0, loc, 256D); - } - - public static void displayColoredParticle(Location loc, ParticleEffect type, String hexVal, float xOffset, float yOffset, float zOffset) { - int R = 0; - int G = 0; - int B = 0; - - if(hexVal.length() <= 6){ - R = Integer.valueOf(hexVal.substring( 0, 2 ), 16); - G = Integer.valueOf(hexVal.substring( 2, 4 ), 16); - B = Integer.valueOf(hexVal.substring( 4, 6 ), 16); - if(R <= 0) - R=1; - }else if(hexVal.length() <= 7 && hexVal.substring(0, 1).equals("#")){ - R = Integer.valueOf(hexVal.substring( 1, 3 ), 16); - G = Integer.valueOf(hexVal.substring( 3, 5 ), 16); - B = Integer.valueOf(hexVal.substring( 5, 7 ), 16); - if(R <= 0) - R=1; - } - - loc.setX(loc.getX() + Math.random() * (xOffset/2 - -(xOffset/2))); - loc.setY(loc.getY() + Math.random() * (yOffset/2 - -(yOffset/2))); - loc.setZ(loc.getZ() + Math.random() * (zOffset/2 - -(zOffset/2))); - - if(type == ParticleEffect.RED_DUST || type == ParticleEffect.REDSTONE) - ParticleEffect.RED_DUST.display((float) R, (float) G, (float) B, 0.004F, 0, loc, 256D); - else if(type == ParticleEffect.SPELL_MOB || type == ParticleEffect.MOB_SPELL) - ParticleEffect.SPELL_MOB.display((float) 255-R, (float) 255-G, (float) 255-B, 1, 0, loc, 256D); - else if(type == ParticleEffect.SPELL_MOB_AMBIENT || type == ParticleEffect.MOB_SPELL_AMBIENT) - ParticleEffect.SPELL_MOB_AMBIENT.display((float) 255-R, (float) 255-G, (float) 255-B, 1, 0, loc, 256D); - else - ParticleEffect.RED_DUST.display((float) 0, (float) 0, (float) 0, 0.004F, 0, loc, 256D); - } - - public static void displayParticleVector(Location loc, ParticleEffect type, float xTrans, float yTrans, float zTrans) { - if(type == ParticleEffect.FIREWORKS_SPARK) - ParticleEffect.FIREWORKS_SPARK.display((float) xTrans, (float) yTrans, (float) zTrans, 0.09F, 0, loc, 256D); - else if(type == ParticleEffect.SMOKE || type == ParticleEffect.SMOKE_NORMAL) - ParticleEffect.SMOKE.display((float) xTrans, (float) yTrans, (float) zTrans, 0.04F, 0, loc, 256D); - else if(type == ParticleEffect.LARGE_SMOKE || type == ParticleEffect.SMOKE_LARGE) - ParticleEffect.LARGE_SMOKE.display((float) xTrans, (float) yTrans, (float) zTrans, 0.04F, 0, loc, 256D); - else if(type == ParticleEffect.ENCHANTMENT_TABLE) - ParticleEffect.ENCHANTMENT_TABLE.display((float) xTrans, (float) yTrans, (float) zTrans, 0.5F, 0, loc, 256D); - else if(type == ParticleEffect.PORTAL) - ParticleEffect.PORTAL.display((float) xTrans, (float) yTrans, (float) zTrans, 0.5F, 0, loc, 256D); - else if(type == ParticleEffect.FLAME) - ParticleEffect.FLAME.display((float) xTrans, (float) yTrans, (float) zTrans, 0.04F, 0, loc, 256D); - else if(type == ParticleEffect.CLOUD) - ParticleEffect.CLOUD.display((float) xTrans, (float) yTrans, (float) zTrans, 0.04F, 0, loc, 256D); - else if(type == ParticleEffect.SNOW_SHOVEL) - ParticleEffect.SNOW_SHOVEL.display((float) xTrans, (float) yTrans, (float) zTrans, 0.2F, 0, loc, 256D); - else - ParticleEffect.RED_DUST.display((float) 0, (float) 0, (float) 0, 0.004F, 0, loc, 256D); - - } - - public static void reloadPlugin() { - DBConnection.sql.close(); - plugin.reloadConfig(); - GeneralMethods.stopBending(); - new AbilityModuleManager(plugin); - DBConnection.host = plugin.getConfig().getString("Storage.MySQL.host"); - DBConnection.port = plugin.getConfig().getInt("Storage.MySQL.port"); - DBConnection.pass = plugin.getConfig().getString("Storage.MySQL.pass"); - DBConnection.db = plugin.getConfig().getString("Storage.MySQL.db"); - DBConnection.user = plugin.getConfig().getString("Storage.MySQL.user"); - DBConnection.init(); - for (Player player: Bukkit.getOnlinePlayers()) { - GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); - } - } - - public static void removeBlock(Block block) { - if (isAdjacentToThreeOrMoreSources(block)) { - block.setType(Material.WATER); - block.setData((byte) 0x0); - } else { - block.setType(Material.AIR); - } - } - - public static void removeUnusableAbilities(String player) { - BendingPlayer bPlayer = getBendingPlayer(player); - HashMap slots = bPlayer.getAbilities(); - HashMap finalabilities = new HashMap(); - try { - for (int i: slots.keySet()) { - if (canBend(player, slots.get(i))) { - finalabilities.put(i, slots.get(i)); - } - } - bPlayer.setAbilities(finalabilities); - } catch (Exception ex) { - - } - - } - - public static Vector rotateVectorAroundVector(Vector axis, Vector rotator, - double degrees) { - double angle = Math.toRadians(degrees); - Vector rotation = axis.clone(); - Vector rotate = rotator.clone(); - rotation = rotation.normalize(); - - Vector thirdaxis = rotation.crossProduct(rotate).normalize() - .multiply(rotate.length()); - - return rotate.multiply(Math.cos(angle)).add( - thirdaxis.multiply(Math.sin(angle))); - } - - public static void saveElements(BendingPlayer bPlayer) { - if (bPlayer == null) return; - String uuid = bPlayer.uuid.toString(); - - StringBuilder elements = new StringBuilder(); - if (bPlayer.hasElement(Element.Air)) elements.append("a"); - if (bPlayer.hasElement(Element.Water)) elements.append("w"); - if (bPlayer.hasElement(Element.Earth)) elements.append("e"); - if (bPlayer.hasElement(Element.Fire)) elements.append("f"); - if (bPlayer.hasElement(Element.Chi)) elements.append("c"); - - DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'"); - } - - public static void saveAbility(BendingPlayer bPlayer, int slot, String ability) { - if (bPlayer == null) return; - String uuid = bPlayer.uuid.toString(); - - HashMap abilities = bPlayer.getAbilities(); - - DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + slot + " = '" + (abilities.get(slot) == null ? null : abilities.get(slot)) + "' WHERE uuid = '" + uuid + "'"); - } - - public static void savePermaRemoved(BendingPlayer bPlayer) { - if (bPlayer == null) return; - String uuid = bPlayer.uuid.toString(); - - boolean permaRemoved = bPlayer.permaRemoved; - DBConnection.sql.modifyQuery("UPDATE pk_players SET permaremoved = '" + (permaRemoved ? "true" : "false") + "' WHERE uuid = '" + uuid + "'"); - } - - public static void stopBending() { - List abilities = AbilityModuleManager.ability; - for (AbilityModule ab: abilities) { - ab.stop(); - } - - ArrayList combos = ComboManager.comboAbilityList; - for(ComboManager.ComboAbility c : combos) - if(c.getComboType() instanceof ComboAbilityModule) - ((ComboAbilityModule) c.getComboType()).stop(); - - AirMethods.stopBending(); - - EarthMethods.stopBending(); - - WaterMethods.stopBending(); - - FireMethods.stopBending(); - - ChiMethods.stopBending(); - - Flight.removeAll(); - TempBlock.removeAll(); - } - - - public static void setVelocity(Entity entity, Vector velocity){ - if (entity instanceof TNTPrimed){ - if (plugin.getConfig().getBoolean("Properties.BendingAffectFallingSand.TNT")) - entity.setVelocity(velocity.multiply(plugin.getConfig().getDouble("Properties.BendingAffectFallingSand.TNTStrengthMultiplier"))); - return; - } - if (entity instanceof FallingSand){ - if (plugin.getConfig().getBoolean("Properties.BendingAffectFallingSand.Normal")) - entity.setVelocity(velocity.multiply(plugin.getConfig().getDouble("Properties.BendingAffectFallingSand.NormalStrengthMultiplier"))); - return; - } - entity.setVelocity(velocity); - } - - public GeneralMethods(ProjectKorra plugin) { - GeneralMethods.plugin = plugin; - new AirMethods(plugin); - new ChiMethods(plugin); - new EarthMethods(plugin); - new FireMethods(plugin); - new WaterMethods(plugin); - } - - public static FallingBlock spawnFallingBlock(Location loc, int type) - { - return spawnFallingBlock(loc, type, (byte) 0); - } - - public static FallingBlock spawnFallingBlock(Location loc, Material type) - { - return spawnFallingBlock(loc, type, (byte) 0); - } - - - public static FallingBlock spawnFallingBlock(Location loc, int type, byte data) - { - return loc.getWorld().spawnFallingBlock(loc, type, data); - } - - - public static FallingBlock spawnFallingBlock(Location loc, Material type, byte data) - { - return loc.getWorld().spawnFallingBlock(loc, type, data); - } - - public static void playAvatarSound(Location loc) { - loc.getWorld().playSound(loc, Sound.ANVIL_LAND, 1, 10); - } - - public static Block getTopBlock(Location loc, int range){ - return getTopBlock(loc,range,range); - } - public static Block getTopBlock(Location loc, int positiveY, int negativeY) - { - /** - * Returns the top block based around loc. - * PositiveY is the maximum amount of distance it will check upward. - * Similarly, negativeY is for downward. - */ - Block block = loc.getBlock(); - Block blockHolder = block; - int y = 0; - //Only one of these while statements will go - while(blockHolder.getType() != Material.AIR && Math.abs(y) < Math.abs(positiveY)) - { - y++; - Block tempBlock = loc.clone().add(0,y,0).getBlock(); - if(tempBlock.getType() == Material.AIR) - return blockHolder; - blockHolder = tempBlock; - } - - while(blockHolder.getType() == Material.AIR && Math.abs(y) < Math.abs(negativeY)) - { - y--; - blockHolder = loc.clone().add(0,y,0).getBlock(); - if(blockHolder.getType() != Material.AIR) - return blockHolder; - - } - return null; - } - - public static Vector rotateXZ(Vector vec, double theta) - { - /** - * Rotates a vector around the Y plane. - */ - Vector vec2 = vec.clone(); - double x = vec2.getX(); - double z = vec2.getZ(); - vec2.setX(x * Math.cos(Math.toRadians(theta)) - z * Math.sin(Math.toRadians(theta))); - vec2.setZ(x * Math.sin(Math.toRadians(theta)) + z * Math.cos(Math.toRadians(theta))); - return vec2; - } - - public static int getMaxPresets(Player player) { - if (player.isOp()) return 500; - int cap = 0; - for (int i = 0; i <= 500; i++) { - if (player.hasPermission("bending.command.presets.create." + i)) cap = i; - } - return cap; - } - - public static boolean blockAbilities(Player player, List abilitiesToBlock, Location loc, double radius) { - /** - * Cycles through a list of ability names to check if any instances of - * the abilities exist at a specific location. If an instance of the ability is - * found then it will be removed, with the exception FireShield, and AirShield. - */ - boolean hasBlocked = false; - for(String ability : abilitiesToBlock){ - if(ability.equalsIgnoreCase("FireBlast")){ - hasBlocked = FireBlast.annihilateBlasts(loc, radius, player) || hasBlocked; - } - else if(ability.equalsIgnoreCase("EarthBlast")){ - hasBlocked = EarthBlast.annihilateBlasts(loc, radius, player) || hasBlocked; - } - else if(ability.equalsIgnoreCase("WaterManipulation")){ - hasBlocked = WaterManipulation.annihilateBlasts(loc, radius, player) || hasBlocked; - } - else if(ability.equalsIgnoreCase("AirSwipe")){ - hasBlocked = AirSwipe.removeSwipesAroundPoint(loc, radius) || hasBlocked; - } - else if(ability.equalsIgnoreCase("Combustion")){ - hasBlocked = Combustion.removeAroundPoint(loc, radius) || hasBlocked; - } - else if(ability.equalsIgnoreCase("FireShield")){ - hasBlocked = FireShield.isWithinShield(loc) || hasBlocked; - } - else if(ability.equalsIgnoreCase("AirShield")){ - hasBlocked = AirShield.isWithinShield(loc) || hasBlocked; - } - else if(ability.equalsIgnoreCase("WaterSpout")){ - hasBlocked = WaterSpout.removeSpouts(loc, radius, player) || hasBlocked; - } - else if(ability.equalsIgnoreCase("AirSpout")){ - hasBlocked = AirSpout.removeSpouts(loc, radius, player) || hasBlocked; - } - else if(ability.equalsIgnoreCase("Twister")){ - hasBlocked = AirCombo.removeAroundPoint(player, "Twister", loc, radius) || hasBlocked; - } - else if(ability.equalsIgnoreCase("AirStream")){ - hasBlocked = AirCombo.removeAroundPoint(player, "AirStream", loc, radius) || hasBlocked; - } - else if(ability.equalsIgnoreCase("AirSweep")){ - hasBlocked = AirCombo.removeAroundPoint(player, "AirSweep", loc, radius) || hasBlocked; - } - else if(ability.equalsIgnoreCase("FireKick")){ - hasBlocked = FireCombo.removeAroundPoint(player, "FireKick", loc, radius) || hasBlocked; - } - else if(ability.equalsIgnoreCase("FireSpin")){ - hasBlocked = FireCombo.removeAroundPoint(player, "FireSpin", loc, radius) || hasBlocked; - } - else if(ability.equalsIgnoreCase("FireWheel")){ - hasBlocked = FireCombo.removeAroundPoint(player, "FireWheel", loc, radius) || hasBlocked; - } - } - return hasBlocked; - } - - public static boolean hasRPG() { - if (Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG") != null) return true; - return false; - } - - public static Plugin getRPG() { - if (hasRPG()) { - return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG"); - } - return null; - } - - public static boolean hasItems() { - if (Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null) return true; - return false; - } - - public static Plugin getItems() { - if (hasItems()) { - return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems"); - } - return null; - } - - public static void writeToDebug(String message) { - try { - File dataFolder = plugin.getDataFolder(); - if (!dataFolder.exists()) { - dataFolder.mkdir(); - } - - File saveTo = new File(plugin.getDataFolder(), "debug.txt"); - if (!saveTo.exists()) { - saveTo.createNewFile(); - } - - FileWriter fw = new FileWriter(saveTo, true); - PrintWriter pw = new PrintWriter(fw); - pw.println(message); - pw.flush(); - pw.close(); - - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static String getCurrentDate() { - DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - Date date = new Date(); - return dateFormat.format(date); - } - - public static void runDebug() { - File debugFile = new File(plugin.getDataFolder(), "debug.txt"); - if (debugFile.exists()) { - debugFile.delete(); // We're starting brand new. - } - writeToDebug("ProjectKorra Debug: Paste this on http://pastie.org and put it in your bug report thread."); - writeToDebug("===================="); - writeToDebug(""); - writeToDebug(""); - writeToDebug("Date Created: " + getCurrentDate()); - writeToDebug("Bukkit Version: " + Bukkit.getServer().getVersion()); - writeToDebug(""); - writeToDebug("ProjectKorra (Core) Information"); - writeToDebug("===================="); - writeToDebug("Version: " + plugin.getDescription().getVersion()); - writeToDebug("Author: " + plugin.getDescription().getAuthors()); - if (hasRPG()) { - writeToDebug(""); - writeToDebug("ProjectKorra (RPG) Information"); - writeToDebug("===================="); - writeToDebug("Version: " + getRPG().getDescription().getVersion()); - writeToDebug("Author: " + getRPG().getDescription().getAuthors()); - } - if (hasItems()) { - writeToDebug(""); - writeToDebug("ProjectKorra (Items) Information"); - writeToDebug("===================="); - writeToDebug("Version: " + getItems().getDescription().getVersion()); - writeToDebug("Author: " + getItems().getDescription().getAuthors()); - } - writeToDebug(""); - writeToDebug("Ability Information"); - writeToDebug("===================="); - for (String ability: AbilityModuleManager.abilities) { - if (StockAbilities.isStockAbility(ability) && !GeneralMethods.isDisabledStockAbility(ability)) { - writeToDebug(ability + " - STOCK ABILITY"); - } else { - writeToDebug(ability + " - UNOFFICIAL ABILITY"); - } - } - writeToDebug(""); - writeToDebug("Supported Plugins"); - writeToDebug("===================="); - - boolean respectWorldGuard = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectWorldGuard"); - boolean respectPreciousStones = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectPreciousStones"); - boolean respectFactions = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectFactions"); - boolean respectTowny = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectTowny"); - boolean respectGriefPrevention = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectGriefPrevention"); - boolean respectLWC = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectLWC"); - PluginManager pm = Bukkit.getPluginManager(); - - Plugin wgp = pm.getPlugin("WorldGuard"); - Plugin psp = pm.getPlugin("PreciousStones"); - Plugin fcp = pm.getPlugin("Factions"); - Plugin twnp = pm.getPlugin("Towny"); - Plugin gpp = pm.getPlugin("GriefPrevention"); - Plugin massivecore = pm.getPlugin("MassiveCore"); - Plugin lwc = pm.getPlugin("LWC"); - - if (wgp != null && respectWorldGuard) { - writeToDebug("WorldGuard v" + wgp.getDescription().getVersion()); - } - if (psp != null && respectPreciousStones) { - writeToDebug("PreciousStones v" + psp.getDescription().getVersion()); - } - if (fcp != null && respectFactions) { - writeToDebug("Factions v" + fcp.getDescription().getVersion()); - } - if (massivecore != null && respectFactions) { - writeToDebug("MassiveCore v" + massivecore.getDescription().getVersion()); - } - if (twnp != null && respectTowny) { - writeToDebug("Towny v" + twnp.getDescription().getVersion()); - } - if (gpp != null && respectGriefPrevention) { - writeToDebug("GriefPrevention v" + gpp.getDescription().getVersion()); - } - if (lwc != null && respectLWC) { - writeToDebug("LWC v" + lwc.getDescription().getVersion()); - } - - writeToDebug(""); - writeToDebug("Plugins Hooking Into ProjectKorra (Core)"); - writeToDebug("===================="); - for (Plugin plugin: Bukkit.getPluginManager().getPlugins()) { - if (plugin.getDescription().getDepend() != null && plugin.getDescription().getDepend().contains("ProjectKorra")) { - writeToDebug(plugin.getDescription().getName() + " v" + plugin.getDescription().getVersion()); - } - } - } - - public static class BlockCacheElement { - private Player player; - private Block block; - private String ability; - private boolean allowed; - private long time; - - public BlockCacheElement(Player player, Block block, String ability, boolean allowed, long time) { - this.player = player; - this.block = block; - this.ability = ability; - this.allowed = allowed; - this.time = time; - } - - public Player getPlayer() { - return player; - } - - public void setPlayer(Player player) { - this.player = player; - } - - public Block getBlock() { - return block; - } - - public void setBlock(Block block) { - this.block = block; - } - - public long getTime() { - return time; - } - - public void setTime(long time) { - this.time = time; - } - - public boolean isAllowed() { - return allowed; - } - - public void setAllowed(boolean allowed) { - this.allowed = allowed; - } - - public String getAbility() { - return ability; - } - - public void setAbility(String ability) { - this.ability = ability; - } - - } - - public static void startCacheCleaner(final double period) { - new BukkitRunnable() { - public void run() { - for(ConcurrentHashMap map : blockProtectionCache.values()) { - for(Iterator i = map.keySet().iterator(); i.hasNext();) { - Block key = i.next(); - BlockCacheElement value = map.get(key); - - if(System.currentTimeMillis() - value.getTime() > period) { - map.remove(key); - } - } - } - } - }.runTaskTimer(ProjectKorra.plugin, 0, (long) (period / 20)); - } - - /** Checks if an entity is Undead **/ - 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; - } - -} +package com.projectkorra.ProjectKorra; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import me.ryanhamshire.GriefPrevention.GriefPrevention; +import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag; +import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.FallingSand; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import com.griefcraft.lwc.LWC; +import com.griefcraft.lwc.LWCPlugin; +import com.griefcraft.model.Protection; +import com.massivecraft.factions.engine.EngineMain; +import com.massivecraft.massivecore.ps.PS; +import com.palmergames.bukkit.towny.Towny; +import com.palmergames.bukkit.towny.TownyMessaging; +import com.palmergames.bukkit.towny.TownySettings; +import com.palmergames.bukkit.towny.object.Coord; +import com.palmergames.bukkit.towny.object.PlayerCache; +import com.palmergames.bukkit.towny.object.PlayerCache.TownBlockStatus; +import com.palmergames.bukkit.towny.object.TownyPermission; +import com.palmergames.bukkit.towny.object.TownyUniverse; +import com.palmergames.bukkit.towny.object.TownyWorld; +import com.palmergames.bukkit.towny.object.WorldCoord; +import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; +import com.palmergames.bukkit.towny.war.flagwar.TownyWar; +import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig; +import com.projectkorra.ProjectKorra.Ability.AbilityModule; +import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; +import com.projectkorra.ProjectKorra.Ability.StockAbilities; +import com.projectkorra.ProjectKorra.Ability.Combo.ComboAbilityModule; +import com.projectkorra.ProjectKorra.Ability.Combo.ComboModuleManager; +import com.projectkorra.ProjectKorra.Utilities.ParticleEffect; +import com.projectkorra.ProjectKorra.airbending.AirCombo; +import com.projectkorra.ProjectKorra.airbending.AirMethods; +import com.projectkorra.ProjectKorra.airbending.AirShield; +import com.projectkorra.ProjectKorra.airbending.AirSpout; +import com.projectkorra.ProjectKorra.airbending.AirSwipe; +import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; +import com.projectkorra.ProjectKorra.chiblocking.Paralyze; +import com.projectkorra.ProjectKorra.earthbending.EarthBlast; +import com.projectkorra.ProjectKorra.earthbending.EarthMethods; +import com.projectkorra.ProjectKorra.earthbending.EarthPassive; +import com.projectkorra.ProjectKorra.earthbending.MetalClips; +import com.projectkorra.ProjectKorra.firebending.Combustion; +import com.projectkorra.ProjectKorra.firebending.FireBlast; +import com.projectkorra.ProjectKorra.firebending.FireCombo; +import com.projectkorra.ProjectKorra.firebending.FireMethods; +import com.projectkorra.ProjectKorra.firebending.FireShield; +import com.projectkorra.ProjectKorra.waterbending.Bloodbending; +import com.projectkorra.ProjectKorra.waterbending.FreezeMelt; +import com.projectkorra.ProjectKorra.waterbending.WaterManipulation; +import com.projectkorra.ProjectKorra.waterbending.WaterMethods; +import com.projectkorra.ProjectKorra.waterbending.WaterSpout; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.protection.flags.DefaultFlag; + +import fr.neatmonster.nocheatplus.checks.CheckType; +import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; + + +@SuppressWarnings("deprecation") +public class GeneralMethods { + + static ProjectKorra plugin; + private static FileConfiguration config = ProjectKorra.plugin.getConfig(); + + public static Random rand = new Random(); + public static double CACHE_TIME = config.getDouble("Properties.RegionProtection.CacheBlockTime"); + + public static ConcurrentHashMap cooldowns = new ConcurrentHashMap(); + // Represents PlayerName, previously checked blocks, and whether they were true or false + public static ConcurrentHashMap> blockProtectionCache = new ConcurrentHashMap>(); + + public static Integer[] nonOpaque = {0, 6, 8, 9, 10, 11, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 66, 68, 69, 70, 72, + 75, 76, 77, 78, 83, 90, 93, 94, 104, 105, 106, 111, 115, 119, 127, 131, 132, 175}; + + // Stands for toggled = false while logging out + public static List toggedOut = new ArrayList(); + + /** + * Checks to see if an AbilityExists. Uses method {@link #getAbility(String)} to check if it exists. + * @param string Ability Name + * @return true if ability exists + */ + public static boolean abilityExists(String string) { + for (String st: AbilityModuleManager.abilities) { + if (string.equalsIgnoreCase(st)) + return true; + } + return false; + } + + public static boolean comboExists(String string) + { + for(ComboAbilityModule c : ComboModuleManager.combo) + if(string.equalsIgnoreCase(c.getName())) + return true; + + return false; + } + + public ComboAbilityModule getCombo(String name) + { + for(ComboAbilityModule c : ComboModuleManager.combo) + if(name.equalsIgnoreCase(c.getName())) + return c; + + return null; + } + + public static boolean isDisabledStockAbility(String string){ + for (String st : AbilityModuleManager.disabledStockAbilities){ + if (string.equalsIgnoreCase(st)) + return true; + } + return false; + } + + /** + * Binds a Ability to the hotbar slot that the player is on. + * @param player The player to bind to + * @param ability The ability name to Bind + * @see {@link #bindAbility(Player, String, int)} + */ + public static void bindAbility(Player player, String ability) { + int slot = player.getInventory().getHeldItemSlot() + 1; + bindAbility(player,ability, slot); + } + + /** + * Binds a Ability to a specific hotbar slot. + * Is cancelled if player has a MultiAbility bound. + * @param player The player to bind to + * @param ability + * @param slot + * @see {@link #bindAbility(Player, String)} + */ + public static void bindAbility(Player player, String ability, int slot) { + //Temp code to block modifications of binds, Should be replaced when bind event is added. + if(MultiAbilityManager.playerAbilities.containsKey(player)){ + player.sendMessage(ChatColor.RED + "You can't edit your binds right now!"); + return; + } + + BendingPlayer bPlayer = getBendingPlayer(player.getName()); + bPlayer.getAbilities().put(slot, ability); + + if (AirMethods.isAirAbility(ability)) { + player.sendMessage(AirMethods.getAirColor() + "Succesfully bound " + ability + " to slot " + slot); + } + else if (WaterMethods.isWaterAbility(ability)) { + player.sendMessage(WaterMethods.getWaterColor() + "Succesfully bound " + ability + " to slot " + slot); + } + else if (EarthMethods.isEarthAbility(ability)) { + player.sendMessage(EarthMethods.getEarthColor() + "Succesfully bound " + ability + " to slot " + slot); + } + else if (FireMethods.isFireAbility(ability)) { + player.sendMessage(FireMethods.getFireColor() + "Succesfully bound " + ability + " to slot " + slot); + } + else if (ChiMethods.isChiAbility(ability)) { + player.sendMessage(ChiMethods.getChiColor() + "Succesfully bound " + ability + " to slot " + slot); + } else { + player.sendMessage(getAvatarColor() + "Successfully bound " + ability + " to slot " + slot); + } + + saveAbility(bPlayer, slot, ability); + } + + /** + * Breaks a block and sets it to {@link Material#AIR AIR}. + * @param block The block to break + */ + public static void breakBlock(Block block) { + block.breakNaturally(new ItemStack(Material.AIR)); + } + + public static boolean canBind(String player, String ability) { + Player p = Bukkit.getPlayer(player); + if (p == null) return false; + if (!p.hasPermission("bending.ability." + ability)) return false; + if (AirMethods.isAirAbility(ability) && !isBender(player, Element.Air)) return false; + if (WaterMethods.isWaterAbility(ability) && !isBender(player, Element.Water)) return false; + if (EarthMethods.isEarthAbility(ability) && !isBender(player, Element.Earth)) return false; + if (FireMethods.isFireAbility(ability) && !isBender(player, Element.Fire)) return false; + if (ChiMethods.isChiAbility(ability) && !isBender(player, Element.Chi)) return false; + return true; + } + + /** + * Checks to see if a Player can bend a specific Ability. + * @param player The player name to check + * @param ability The Ability name to check + * @return true If player can bend specified ability and has the permissions to do so + */ + public static boolean canBend(String player, String ability) { + BendingPlayer bPlayer = getBendingPlayer(player); + Player p = Bukkit.getPlayer(player); + if (bPlayer == null) return false; + if (plugin.getConfig().getStringList("Properties.DisabledWorlds") != null && plugin.getConfig().getStringList("Properties.DisabledWorlds").contains(p.getWorld().getName())) return false; + if (Commands.isToggledForAll) return false; + if (!bPlayer.isToggled) return false; + if (p == null) return false; + if (cooldowns.containsKey(p.getName())) { + if (cooldowns.get(p.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) { + return false; + } + cooldowns.remove(p.getName()); + } + if (bPlayer.blockedChi) return false; + // if (bPlayer.isChiBlocked()) return false; + if (!p.hasPermission("bending.ability." + ability)) return false; + if (AirMethods.isAirAbility(ability) && !isBender(player, Element.Air)) return false; + if (WaterMethods.isWaterAbility(ability) && !isBender(player, Element.Water)) return false; + if (EarthMethods.isEarthAbility(ability) && !isBender(player, Element.Earth)) return false; + if (FireMethods.isFireAbility(ability) && !isBender(player, Element.Fire)) return false; + if (ChiMethods.isChiAbility(ability) && !isBender(player, Element.Chi)) return false; + +// if (isFlightAbility(ability) && !canAirFlight(plugin.getServer().getPlayer(player))) return false; +// if (isSpiritualProjectionAbility(ability) && !canUseSpiritualProjection(plugin.getServer().getPlayer(player))) return false; +// if (isCombustionbendingAbility(ability) && !canCombustionbend(plugin.getServer().getPlayer(player))) return false; +// if (isLightningbendingAbility(ability) && !canLightningbend(plugin.getServer().getPlayer(player))) return false; +// if (isSandbendingAbility(ability) && !canSandbend(plugin.getServer().getPlayer(player))) return false; +// if (isMetalbendingAbility(ability) && !canMetalbend(plugin.getServer().getPlayer(player))) return false; +// if (isLavabendingAbility(ability) && !canLavabend(plugin.getServer().getPlayer(player))) return false; +// if (isIcebendingAbility(ability) && !canIcebend(plugin.getServer().getPlayer(player))) return false; +// if (isHealingAbility(ability) && !canWaterHeal(plugin.getServer().getPlayer(player))) return false; +// if (isPlantbendingAbility(ability) && !canPlantbend(plugin.getServer().getPlayer(player))) return false; +// if (isBloodbendingAbility(ability) && !canBloodbend(plugin.getServer().getPlayer(player))) return false; + + + + if (isRegionProtectedFromBuild(p, ability, p.getLocation())) return false; + if (Paralyze.isParalyzed(p) || Bloodbending.isBloodbended(p)) return false; + if (MetalClips.isControlled(p)) return false; + if (BendingManager.events.get(p.getWorld()) != null && BendingManager.events.get(p.getWorld()).equalsIgnoreCase("SolarEclipse") && FireMethods.isFireAbility(ability)) return false; + if (BendingManager.events.get(p.getWorld()) != null && BendingManager.events.get(p.getWorld()).equalsIgnoreCase("LunarEclipse") && WaterMethods.isWaterAbility(ability)) return false; + return true; + } + + public static boolean canBendPassive(String player, Element element) { + BendingPlayer bPlayer = getBendingPlayer(player); + Player p = Bukkit.getPlayer(player); + if (bPlayer == null) return false; + if (p == null) return false; + if (!p.hasPermission("bending." + element.toString().toLowerCase() + ".passive")) return false; + if (!bPlayer.isToggled) return false; + if (!bPlayer.hasElement(element)) return false; + if (isRegionProtectedFromBuild(p, null, p.getLocation())) return false; + if (bPlayer.blockedChi) return false; + return true; + } + + public static boolean isSubAbility(String ability) { + if (AbilityModuleManager.subabilities.contains(ability)) return true; + return false; + } + + /** + * Creates a {@link BendingPlayer} with the data from the database. This runs when a player logs in. + * @param uuid The UUID of the player + * @param player The player name + * @throws SQLException + */ + public static void createBendingPlayer(final UUID uuid, final String player) { + new BukkitRunnable() { + @Override + public void run() { + createBendingPlayerAsynchronously(uuid, player); + } + }.runTaskAsynchronously(ProjectKorra.plugin); + } + + private static void createBendingPlayerAsynchronously(final UUID uuid, final String player) { + ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + uuid.toString() + "'"); + try { + if (!rs2.next()) { // Data doesn't exist, we want a completely new + // player. + new BendingPlayer(uuid, player, new ArrayList(), new HashMap(), false); + DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player) VALUES ('" + uuid.toString() + "', '" + player + "')"); + ProjectKorra.log.info("Created new BendingPlayer for " + player); + } else { + // The player has at least played before. + String player2 = rs2.getString("player"); + if (!player.equalsIgnoreCase(player2)) { + DBConnection.sql.modifyQuery("UPDATE pk_players SET player = '" + player + "' WHERE uuid = '" + uuid.toString() + "'"); + // They have changed names. + + ProjectKorra.log.info("Updating Player Name for " + player); + } + + String element = rs2.getString("element"); + String permaremoved = rs2.getString("permaremoved"); + boolean p = false; + final ArrayList elements = new ArrayList(); + if (element != null) { // Player has an element. + if (element.contains("a")) + elements.add(Element.Air); + if (element.contains("w")) + elements.add(Element.Water); + if (element.contains("e")) + elements.add(Element.Earth); + if (element.contains("f")) + elements.add(Element.Fire); + if (element.contains("c")) + elements.add(Element.Chi); + } + + final HashMap abilities = new HashMap(); + for (int i = 1; i <= 9; i++) { + String slot = rs2.getString("slot" + i); + + if (slot != null) { + abilities.put(i, slot); + } + } + + p = (permaremoved == null ? false : (permaremoved.equals("true") ? true : (permaremoved.equals("false") ? false : p))); + + final boolean boolean_p = p; + new BukkitRunnable() { + @Override + public void run() { + new BendingPlayer(uuid, player, elements, abilities, boolean_p); + } + }.runTask(ProjectKorra.plugin); + } + } catch (SQLException ex) { + ex.printStackTrace(); + } + } + + /** + * Damages an Entity by amount of damage specified. Starts a {@link EntityDamageByEntityEvent}. + * @param player The player dealing the damage + * @param entity The entity that is receiving the damage + * @param damage The amount of damage to deal + */ + public static void damageEntity(Player player, Entity entity, double damage) { + if (entity instanceof LivingEntity) { + if (entity instanceof Player) { + if (Commands.invincible.contains(((Player) entity).getName())) return; + } + if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { + NCPExemptionManager.exemptPermanently(player, CheckType.FIGHT_REACH); + } + ((LivingEntity) entity).damage(damage, player); + ((LivingEntity) entity).setLastDamageCause( + new EntityDamageByEntityEvent(player, entity, DamageCause.CUSTOM, damage)); + if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { + NCPExemptionManager.unexempt(player); + } + } + } + + /** + * Deserializes the configuration file "bendingPlayers.yml" of the old BendingPlugin and creates a converted.yml ready for conversion. + * @throws IOException If the "bendingPlayers.yml" file is not found + */ + public static void deserializeFile() { + File readFile = new File(".", "bendingPlayers.yml"); + File writeFile = new File(".", "converted.yml"); + if (readFile.exists()) { + try ( + DataInputStream input = new DataInputStream(new FileInputStream(readFile)); + BufferedReader reader = new BufferedReader(new InputStreamReader(input)); + + DataOutputStream output = new DataOutputStream(new FileOutputStream(writeFile)); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output)); + ){ + + String line; + while ((line = reader.readLine()) != null) { + if (!line.trim().contains("==: BendingPlayer")) { + writer.write(line + "\n"); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * Drops a {@code Collection} of items on a specified block. + * @param block The block to drop items on. + * @param items The items to drop. + */ + public static void dropItems(Block block, Collection items) { + for (ItemStack item : items) + block.getWorld().dropItem(block.getLocation(), item); + } + + /** + * Gets the ability from specified ability name. + * @param string The ability name + * @return Ability name if found in {@link AbilityModuleManager#abilities} + *

+ * else null + *

+ */ + public static String getAbility(String string) { + for (String st: AbilityModuleManager.abilities) { + if (st.equalsIgnoreCase(string)) return st; + } + return null; + } + + /** + * Gets the Element color from the Ability name specified. + * @param ability The ability name + *

+ * @return + * {@link #getChiColor()}
+ * {@link #getAirColor()}
+ * {@link #getWaterColor()}
+ * {@link #getEarthColor()}
+ * {@link #getFireColor()}
+ * else {@link #getAvatarColor()} + *

+ */ + public static ChatColor getAbilityColor(String ability) { + if (AbilityModuleManager.chiabilities.contains(ability)) return ChiMethods.getChiColor(); + if (AbilityModuleManager.airbendingabilities.contains(ability)) + { + if (AbilityModuleManager.subabilities.contains(ability)) return getSubBendingColor(Element.Air); + return AirMethods.getAirColor(); + } + if (AbilityModuleManager.waterbendingabilities.contains(ability)) + { + if (AbilityModuleManager.subabilities.contains(ability)) return getSubBendingColor(Element.Water); + return WaterMethods.getWaterColor(); + } + if (AbilityModuleManager.earthbendingabilities.contains(ability)) + { + if (AbilityModuleManager.subabilities.contains(ability)) return getSubBendingColor(Element.Earth); + return EarthMethods.getEarthColor(); + } + if (AbilityModuleManager.firebendingabilities.contains(ability)) + { + if (AbilityModuleManager.subabilities.contains(ability)) return getSubBendingColor(Element.Fire); + return FireMethods.getFireColor(); + } + + else return getAvatarColor(); + } + + /** + * Gets the AvatarColor from the config. + * @return Config specified ChatColor + */ + public static ChatColor getAvatarColor() { + return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Avatar")); + } + + /** + * Gets a {@link BendingPlayer} from specified player name. + * @param player The name of the Player + * @return The BendingPlayer object if {@link BendingPlayer#players} contains the player name + */ + public static BendingPlayer getBendingPlayer(String player) { + return BendingPlayer.players.get(player); + } + + /** + * Gets a {@code List} within the specified radius around the specified location. + * @param location The base location + * @param radius The block radius from location to include within the list of blocks + * @return The list of Blocks + */ + public static List getBlocksAroundPoint(Location location, double radius) { + List blocks = new ArrayList(); + + int xorg = location.getBlockX(); + int yorg = location.getBlockY(); + int zorg = location.getBlockZ(); + + int r = (int) radius * 4; + + for (int x = xorg - r; x <= xorg + r; x++) { + for (int y = yorg - r; y <= yorg + r; y++) { + for (int z = zorg - r; z <= zorg + r; z++) { + Block block = location.getWorld().getBlockAt(x, y, z); + if (block.getLocation().distance(location) <= radius) { + blocks.add(block); + } + } + } + } + + return blocks; + } + + /** + * Gets the Ability bound to the slot that the player is in. + * @param player The player to check + * @return The Ability name bounded to the slot + *

+ * else null + *

+ */ + public static String getBoundAbility(Player player) { + BendingPlayer bPlayer = getBendingPlayer(player.getName()); + if (bPlayer == null) return null; + + int slot = player.getInventory().getHeldItemSlot() + 1; + return bPlayer.getAbilities().get(slot); + } + + public static long getGlobalCooldown() { + return plugin.getConfig().getLong("Properties.GlobalCooldown"); + } + + public static BlockFace getCardinalDirection(Vector vector) { + BlockFace[] faces = { BlockFace.NORTH, BlockFace.NORTH_EAST, + BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, + BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST }; + Vector n, ne, e, se, s, sw, w, nw; + w = new Vector(-1, 0, 0); + n = new Vector(0, 0, -1); + s = n.clone().multiply(-1); + e = w.clone().multiply(-1); + ne = n.clone().add(e.clone()).normalize(); + se = s.clone().add(e.clone()).normalize(); + nw = n.clone().add(w.clone()).normalize(); + sw = s.clone().add(w.clone()).normalize(); + + Vector[] vectors = { n, ne, e, se, s, sw, w, nw }; + + double comp = 0; + int besti = 0; + for (int i = 0; i < vectors.length; i++) { + double dot = vector.dot(vectors[i]); + if (dot > comp) { + comp = dot; + besti = i; + } + } + + return faces[besti]; + + } + + public static List getCircle(Location loc, int radius, int height, boolean hollow, boolean sphere, int plusY){ + List circleblocks = new ArrayList(); + int cx = loc.getBlockX(); + int cy = loc.getBlockY(); + int cz = loc.getBlockZ(); + + for(int x = cx - radius; x <= cx + radius; x++){ + for (int z = cz - radius; z <= cz + radius; z++){ + for(int y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height); y++){ + double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0); + + if(dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1))){ + Location l = new Location(loc.getWorld(), x, y + plusY, z); + circleblocks.add(l); + } + } + } + } + + return circleblocks; + } + + public static Vector getDirection(Location location, Location destination) { + double x1, y1, z1; + double x0, y0, z0; + + x1 = destination.getX(); + y1 = destination.getY(); + z1 = destination.getZ(); + + x0 = location.getX(); + y0 = location.getY(); + z0 = location.getZ(); + + return new Vector(x1 - x0, y1 - y0, z1 - z0); + + } + + public static double getDistanceFromLine(Vector line, Location pointonline, + Location point) { + + Vector AP = new Vector(); + double Ax, Ay, Az; + Ax = pointonline.getX(); + Ay = pointonline.getY(); + Az = pointonline.getZ(); + + double Px, Py, Pz; + Px = point.getX(); + Py = point.getY(); + Pz = point.getZ(); + + AP.setX(Px - Ax); + AP.setY(Py - Ay); + AP.setZ(Pz - Az); + + return (AP.crossProduct(line).length()) / (line.length()); + } + + /** + * Gets a {@code Collection} of item drops from a single block. + * @param block The single block + * @param type The Material type to change the block into + * @param data The block data to change the block into + * @param breakitem Unused + * @return The item drops fromt the specified block + */ + public static Collection getDrops(Block block, Material type, byte data, ItemStack breakitem) { + BlockState tempstate = block.getState(); + block.setType(type); + block.setData(data); + Collection item = block.getDrops(); + tempstate.update(true); + return item; + } + + /** + * Gets a {@code List} of entities around a specified radius from the specified area + * @param location The base location + * @param radius The radius of blocks to look for entities from the location + * @return A list of entities around a point + */ + public static List getEntitiesAroundPoint(Location location, double radius) { + + List entities = location.getWorld().getEntities(); + List list = location.getWorld().getEntities(); + + for (Entity entity : entities) { + if (entity.getWorld() != location.getWorld()) { + list.remove(entity); + } else if (entity.getLocation().distance(location) > radius) { + list.remove(entity); + } + } + + return list; + + } + + @SuppressWarnings("incomplete-switch") + public static int getIntCardinalDirection(Vector vector) { + BlockFace face = getCardinalDirection(vector); + + switch (face) { + case SOUTH: + return 7; + case SOUTH_WEST: + return 6; + case WEST: + return 3; + case NORTH_WEST: + return 0; + case NORTH: + return 1; + case NORTH_EAST: + return 2; + case EAST: + return 5; + case SOUTH_EAST: + return 8; + } + + return 4; + + } + + @SuppressWarnings("incomplete-switch") + public static ChatColor getSubBendingColor(Element element) + { + switch(element) + { + case Fire: + return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.FireSub")); + case Air: + return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.AirSub")); + case Water: + return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.WaterSub")); + case Earth: + return ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.EarthSub")); + } + + return getAvatarColor(); + } + + public static Vector getOrthogonalVector(Vector axis, double degrees, double length) { + + Vector ortho = new Vector(axis.getY(), -axis.getX(), 0); + ortho = ortho.normalize(); + ortho = ortho.multiply(length); + + return rotateVectorAroundVector(axis, ortho, degrees); + + } + + public static Location getPointOnLine(Location origin, Location target, double distance) { + return origin.clone().add( + getDirection(origin, target).normalize().multiply(distance)); + + } + + @SuppressWarnings("unused") + public static Entity getTargetedEntity(Player player, double range, List avoid) { + double longestr = range + 1; + Entity target = null; + Location origin = player.getEyeLocation(); + Vector direction = player.getEyeLocation().getDirection().normalize(); + for (Entity entity : origin.getWorld().getEntities()) { + if (avoid.contains(entity)) + continue; + if (entity.getLocation().distance(origin) < longestr + && getDistanceFromLine(direction, origin, entity.getLocation()) < 2 + && (entity instanceof LivingEntity) + && entity.getEntityId() != player.getEntityId() + && entity.getLocation().distance(origin.clone().add(direction)) < + entity.getLocation().distance(origin.clone().add(direction.clone().multiply(-1)))) { + target = entity; + longestr = entity.getLocation().distance(origin); + } + } + if(target != null) { + List blklist = new ArrayList(); + blklist = GeneralMethods.getBlocksAlongLine(player.getLocation(), target.getLocation(), player.getWorld()); + for(Block isair:blklist) + { + if(GeneralMethods.isObstructed(origin, target.getLocation())) { + target = null; + break; + } + } + } + return target; + } + + public static List getBlocksAlongLine(Location ploc, Location tloc, World w) { + List blocks = new ArrayList(); + + //Next we will name each coordinate + int x1 = ploc.getBlockX(); + int y1 = ploc.getBlockY(); + int z1 = ploc.getBlockZ(); + + int x2 = tloc.getBlockX(); + int y2 = tloc.getBlockY(); + int z2 = tloc.getBlockZ(); + + //Then we create the following integers + int xMin, yMin, zMin; + int xMax, yMax, zMax; + int x, y, z; + + //Now we need to make sure xMin is always lower then xMax + if(x1 > x2){ //If x1 is a higher number then x2 + xMin = x2; + xMax = x1; + }else{ + xMin = x1; + xMax = x2; + } + //Same with Y + if(y1 > y2){ + yMin = y2; + yMax = y1; + }else{ + yMin = y1; + yMax = y2; + } + + //And Z + if(z1 > z2){ + zMin = z2; + zMax = z1; + }else{ + zMin = z1; + zMax = z2; + } + + //Now it's time for the loop + for(x = xMin; x <= xMax; x ++){ + for(y = yMin; y <= yMax; y ++){ + for(z = zMin; z <= zMax; z ++){ + Block b = new Location(w, x, y, z).getBlock(); + blocks.add(b); + } + } + } + + //And last but not least, we return with the list + return blocks; + } + + public static Location getTargetedLocation(Player player, double originselectrange, Integer... nonOpaque2) { + Location origin = player.getEyeLocation(); + Vector direction = origin.getDirection(); + + HashSet trans = new HashSet(); + trans.add((byte) 0); + + if (nonOpaque2 == null) { + trans = null; + } else { + for (int i : nonOpaque2) { + trans.add((byte) i); + } + } + + Block block = player.getTargetBlock(trans, (int) originselectrange + 1); + double distance = block.getLocation().distance(origin) - 1.5; + Location location = origin.add(direction.multiply(distance)); + + return location; + } + + public static Location getTargetedLocation(Player player, int range) { + return getTargetedLocation(player, range, 0); + } + + public static boolean hasPermission(Player player, String ability) { + if (player.hasPermission("bending.ability." + ability) && canBind(player.getName(), ability)) return true; + return false; + } + + public static boolean canView(Player player, String ability) { + if (player.hasPermission("bending.ability." + ability)) return true; + return false; + } + + public static boolean isAbilityInstalled(String name, String author) { + String ability = getAbility(name); + if (ability == null) return false; + if (AbilityModuleManager.authors.get(name).equalsIgnoreCase(author)) return true; + return false; + } + + public static boolean isAdjacentToThreeOrMoreSources(Block block) { + if (TempBlock.isTempBlock(block)) + return false; + int sources = 0; + byte full = 0x0; + BlockFace[] faces = { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, + BlockFace.SOUTH }; + for (BlockFace face : faces) { + Block blocki = block.getRelative(face); + if ((blocki.getType() == Material.LAVA || blocki.getType() == Material.STATIONARY_LAVA) + && blocki.getData() == full + && EarthPassive.canPhysicsChange(blocki)) + sources++; + if ((blocki.getType() == Material.WATER || blocki.getType() == Material.STATIONARY_WATER) + && blocki.getData() == full + && WaterManipulation.canPhysicsChange(blocki)) + sources++; + if (FreezeMelt.frozenblocks.containsKey(blocki)) { + //if (FreezeMelt.frozenblocks.get(blocki) == full) + //sources++; + } else if (blocki.getType() == Material.ICE) { + //sources++; + } + } + if (sources >= 2) + return true; + return false; + } + + public static boolean isBender(String player, Element element) { + BendingPlayer bPlayer = getBendingPlayer(player); + if (bPlayer == null) return false; + if (bPlayer.hasElement(element)) return true; + return false; + } + + public static boolean isHarmlessAbility(String ability) { + return AbilityModuleManager.harmlessabilities.contains(ability); + } + + public static boolean isImportEnabled() { + return plugin.getConfig().getBoolean("Properties.ImportEnabled"); + } + + public static boolean isObstructed(Location location1, Location location2) { + Vector loc1 = location1.toVector(); + Vector loc2 = location2.toVector(); + + Vector direction = loc2.subtract(loc1); + direction.normalize(); + + Location loc; + + double max = location1.distance(location2); + + for (double i = 0; i <= max; i++) { + loc = location1.clone().add(direction.clone().multiply(i)); + Material type = loc.getBlock().getType(); + if (type != Material.AIR + && !Arrays.asList(EarthMethods.getTransparentEarthbending()).contains( + type.getId())) + return true; + } + + return false; + } + + /* + * isRegionProtectedFromBuild is one of the most server intensive methods in the + * plugin. It uses a blockCache that keeps track of recent blocks that may have already been checked. + * Abilities like TremorSense call this ability 5 times per tick even though it only needs to check a single block, + * instead of doing all 5 of those checks this method will now look in the map first. + */ + public static boolean isRegionProtectedFromBuild(Player player, String ability, Location loc) { + if(!blockProtectionCache.containsKey(player.getName())) + blockProtectionCache.put(player.getName(), new ConcurrentHashMap()); + + ConcurrentHashMap blockMap = blockProtectionCache.get(player.getName()); + Block block = loc.getBlock(); + if(blockMap.containsKey(block)) { + BlockCacheElement elem = blockMap.get(block); + + // both abilities must be equal to each other to use the cache + if((ability == null && elem.getAbility() == null) + || (ability != null && elem.getAbility() != null && elem.getAbility().equals(ability))) { + return elem.isAllowed(); + } + } + + boolean value = isRegionProtectedFromBuildPostCache(player, ability, loc); + blockMap.put(block, new BlockCacheElement(player, block, ability, value, System.currentTimeMillis())); + return value; + } + + public static boolean isRegionProtectedFromBuildPostCache(Player player, String ability, Location loc) { + + boolean allowharmless = plugin.getConfig().getBoolean("Properties.RegionProtection.AllowHarmlessAbilities"); + boolean respectWorldGuard = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectWorldGuard"); + boolean respectPreciousStones = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectPreciousStones"); + boolean respectFactions = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectFactions"); + boolean respectTowny = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectTowny"); + boolean respectGriefPrevention = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectGriefPrevention"); + boolean respectLWC = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectLWC"); + + Set ignite = AbilityModuleManager.igniteabilities; + Set explode = AbilityModuleManager.explodeabilities; + + if (ability == null && allowharmless) + return false; + if (isHarmlessAbility(ability) && allowharmless) + return false; + + PluginManager pm = Bukkit.getPluginManager(); + + Plugin wgp = pm.getPlugin("WorldGuard"); + Plugin psp = pm.getPlugin("PreciousStones"); + Plugin fcp = pm.getPlugin("Factions"); + Plugin twnp = pm.getPlugin("Towny"); + Plugin gpp = pm.getPlugin("GriefPrevention"); + Plugin massivecore = pm.getPlugin("MassiveCore"); + Plugin lwc = pm.getPlugin("LWC"); + + + + for (Location location : new Location[] { loc, player.getLocation() }) { + World world = location.getWorld(); + + if (lwc != null && respectLWC) { + LWCPlugin lwcp = (LWCPlugin) lwc; + LWC lwc2 = lwcp.getLWC(); + Protection protection = lwc2.getProtectionCache().getProtection(location.getBlock()); + if (protection != null) { + if (!lwc2.canAccessProtection(player, protection)) { + return true; + } + } + } + if (wgp != null && respectWorldGuard && !player.hasPermission("worldguard.region.bypass." + world.getName())) { + WorldGuardPlugin wg = (WorldGuardPlugin) Bukkit + .getPluginManager().getPlugin("WorldGuard"); + if (!player.isOnline()) + return true; + + if (ignite.contains(ability)) { + if (!wg.hasPermission(player, "worldguard.override.lighter")) { + if (wg.getGlobalStateManager().get(world).blockLighter) + return true; + } + } + if (explode.contains(ability)) { + if (wg.getGlobalStateManager().get(location.getWorld()).blockTNTExplosions) + return true; + if (!wg.getRegionContainer().createQuery().testBuild(location, player, DefaultFlag.TNT)) + return true; + } + + if (!wg.canBuild(player, location.getBlock())) { + return true; + } + } + + if (psp != null && respectPreciousStones) { + PreciousStones ps = (PreciousStones) psp; + + if (ignite.contains(ability)) { + if (ps.getForceFieldManager().hasSourceField(location, + FieldFlag.PREVENT_FIRE)) + return true; + } + if (explode.contains(ability)) { + if (ps.getForceFieldManager().hasSourceField(location, + FieldFlag.PREVENT_EXPLOSIONS)) + return true; + } + +// if (ps.getForceFieldManager().hasSourceField(location, +// FieldFlag.PREVENT_PLACE)) +// return true; + + if (!PreciousStones.API().canBreak(player, location)) { + return true; + } + } + + if (fcp != null && massivecore != null && respectFactions) { + if (!EngineMain.canPlayerBuildAt(player, PS.valueOf(loc.getBlock()), false)) { + return true; + } else { + return false; + } + } + + if (twnp != null && respectTowny) { + Towny twn = (Towny) twnp; + + WorldCoord worldCoord; + + try { + TownyWorld tWorld = TownyUniverse.getDataSource().getWorld( + world.getName()); + worldCoord = new WorldCoord(tWorld.getName(), + Coord.parseCoord(location)); + + boolean bBuild = PlayerCacheUtil.getCachePermission(player, + location, 3, (byte) 0, + TownyPermission.ActionType.BUILD); + + if (ignite.contains(ability)) { + + } + + if (explode.contains(ability)) { + + } + + if (!bBuild) { + PlayerCache cache = twn.getCache(player); + TownBlockStatus status = cache.getStatus(); + + if (((status == TownBlockStatus.ENEMY) && TownyWarConfig + .isAllowingAttacks())) { + + try { + TownyWar.callAttackCellEvent(twn, player, + location.getBlock(), worldCoord); + } catch (Exception e) { + TownyMessaging.sendErrorMsg(player, + e.getMessage()); + } + + return true; + + } else if (status == TownBlockStatus.WARZONE) { + } else { + return true; + } + + if ((cache.hasBlockErrMsg())) + TownyMessaging.sendErrorMsg(player, + cache.getBlockErrMsg()); + } + + } catch (Exception e1) { + TownyMessaging.sendErrorMsg(player, TownySettings + .getLangString("msg_err_not_configured")); + } + + } + + if (gpp != null && respectGriefPrevention) { + Material type = player.getWorld().getBlockAt(location).getType(); + if (type == null) type = Material.AIR; + String reason = GriefPrevention.instance.allowBuild(player, location); // WORKING with WorldGuard 6.0 BETA 4 + + + if (ignite.contains(ability)) { + + } + + if (explode.contains(ability)) { + + } + + if (reason != null) + return true; + } + } + + return false; + } + + + public static boolean isSolid(Block block) { + if (Arrays.asList(nonOpaque).contains(block.getTypeId())) return false; + return true; + } + + public static boolean isWeapon(Material mat) { + if (mat == null) return false; + if (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE + || mat == Material.WOOD_SPADE || mat == Material.WOOD_SWORD + + || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE + || mat == Material.STONE_SPADE || mat == Material.STONE_SWORD + + || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE + || mat == Material.IRON_SWORD || mat == Material.IRON_SPADE + + || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE + || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SPADE) + return true; + return false; + } + + public static Collection getPlayersAroundPoint(Location location, double distance) { + Collection players = new HashSet(); + for (Player player: Bukkit.getOnlinePlayers()) { + if (player.getLocation().distance(location) <= distance) { + players.add(player); + } + } + return players; + } + + public static void displayColoredParticle(Location loc, String hexVal) { + int R = 0; + int G = 0; + int B = 0; + + if(hexVal.length() <= 6){ + R = Integer.valueOf(hexVal.substring( 0, 2 ), 16); + G = Integer.valueOf(hexVal.substring( 2, 4 ), 16); + B = Integer.valueOf(hexVal.substring( 4, 6 ), 16); + if(R <= 0) + R=1; + }else if(hexVal.length() <= 7 && hexVal.substring(0, 1).equals("#")){ + R = Integer.valueOf(hexVal.substring( 1, 3 ), 16); + G = Integer.valueOf(hexVal.substring( 3, 5 ), 16); + B = Integer.valueOf(hexVal.substring( 5, 7 ), 16); + if(R <= 0) + R=1; + } + + ParticleEffect.RED_DUST.display((float) R, (float) G, (float) B, 0.004F, 0, loc, 256D); + } + + public static void displayColoredParticle(Location loc, String hexVal, float xOffset, float yOffset, float zOffset) { + int R = 0; + int G = 0; + int B = 0; + + if(hexVal.length() <= 6){ + R = Integer.valueOf(hexVal.substring( 0, 2 ), 16); + G = Integer.valueOf(hexVal.substring( 2, 4 ), 16); + B = Integer.valueOf(hexVal.substring( 4, 6 ), 16); + if(R <= 0) + R=1; + }else if(hexVal.length() <= 7 && hexVal.substring(0, 1).equals("#")){ + R = Integer.valueOf(hexVal.substring( 1, 3 ), 16); + G = Integer.valueOf(hexVal.substring( 3, 5 ), 16); + B = Integer.valueOf(hexVal.substring( 5, 7 ), 16); + if(R <= 0) + R=1; + } + + loc.setX(loc.getX() + Math.random() * (xOffset/2 - -(xOffset/2))); + loc.setY(loc.getY() + Math.random() * (yOffset/2 - -(yOffset/2))); + loc.setZ(loc.getZ() + Math.random() * (zOffset/2 - -(zOffset/2))); + + ParticleEffect.RED_DUST.display((float) R, (float) G, (float) B, 0.004F, 0, loc, 256D); + } + + public static void displayColoredParticle(Location loc, ParticleEffect type, String hexVal, float xOffset, float yOffset, float zOffset) { + int R = 0; + int G = 0; + int B = 0; + + if(hexVal.length() <= 6){ + R = Integer.valueOf(hexVal.substring( 0, 2 ), 16); + G = Integer.valueOf(hexVal.substring( 2, 4 ), 16); + B = Integer.valueOf(hexVal.substring( 4, 6 ), 16); + if(R <= 0) + R=1; + }else if(hexVal.length() <= 7 && hexVal.substring(0, 1).equals("#")){ + R = Integer.valueOf(hexVal.substring( 1, 3 ), 16); + G = Integer.valueOf(hexVal.substring( 3, 5 ), 16); + B = Integer.valueOf(hexVal.substring( 5, 7 ), 16); + if(R <= 0) + R=1; + } + + loc.setX(loc.getX() + Math.random() * (xOffset/2 - -(xOffset/2))); + loc.setY(loc.getY() + Math.random() * (yOffset/2 - -(yOffset/2))); + loc.setZ(loc.getZ() + Math.random() * (zOffset/2 - -(zOffset/2))); + + if(type == ParticleEffect.RED_DUST || type == ParticleEffect.REDSTONE) + ParticleEffect.RED_DUST.display((float) R, (float) G, (float) B, 0.004F, 0, loc, 256D); + else if(type == ParticleEffect.SPELL_MOB || type == ParticleEffect.MOB_SPELL) + ParticleEffect.SPELL_MOB.display((float) 255-R, (float) 255-G, (float) 255-B, 1, 0, loc, 256D); + else if(type == ParticleEffect.SPELL_MOB_AMBIENT || type == ParticleEffect.MOB_SPELL_AMBIENT) + ParticleEffect.SPELL_MOB_AMBIENT.display((float) 255-R, (float) 255-G, (float) 255-B, 1, 0, loc, 256D); + else + ParticleEffect.RED_DUST.display((float) 0, (float) 0, (float) 0, 0.004F, 0, loc, 256D); + } + + public static void displayParticleVector(Location loc, ParticleEffect type, float xTrans, float yTrans, float zTrans) { + if(type == ParticleEffect.FIREWORKS_SPARK) + ParticleEffect.FIREWORKS_SPARK.display((float) xTrans, (float) yTrans, (float) zTrans, 0.09F, 0, loc, 256D); + else if(type == ParticleEffect.SMOKE || type == ParticleEffect.SMOKE_NORMAL) + ParticleEffect.SMOKE.display((float) xTrans, (float) yTrans, (float) zTrans, 0.04F, 0, loc, 256D); + else if(type == ParticleEffect.LARGE_SMOKE || type == ParticleEffect.SMOKE_LARGE) + ParticleEffect.LARGE_SMOKE.display((float) xTrans, (float) yTrans, (float) zTrans, 0.04F, 0, loc, 256D); + else if(type == ParticleEffect.ENCHANTMENT_TABLE) + ParticleEffect.ENCHANTMENT_TABLE.display((float) xTrans, (float) yTrans, (float) zTrans, 0.5F, 0, loc, 256D); + else if(type == ParticleEffect.PORTAL) + ParticleEffect.PORTAL.display((float) xTrans, (float) yTrans, (float) zTrans, 0.5F, 0, loc, 256D); + else if(type == ParticleEffect.FLAME) + ParticleEffect.FLAME.display((float) xTrans, (float) yTrans, (float) zTrans, 0.04F, 0, loc, 256D); + else if(type == ParticleEffect.CLOUD) + ParticleEffect.CLOUD.display((float) xTrans, (float) yTrans, (float) zTrans, 0.04F, 0, loc, 256D); + else if(type == ParticleEffect.SNOW_SHOVEL) + ParticleEffect.SNOW_SHOVEL.display((float) xTrans, (float) yTrans, (float) zTrans, 0.2F, 0, loc, 256D); + else + ParticleEffect.RED_DUST.display((float) 0, (float) 0, (float) 0, 0.004F, 0, loc, 256D); + + } + + public static void reloadPlugin() { + DBConnection.sql.close(); + plugin.reloadConfig(); + GeneralMethods.stopBending(); + new AbilityModuleManager(plugin); + DBConnection.host = plugin.getConfig().getString("Storage.MySQL.host"); + DBConnection.port = plugin.getConfig().getInt("Storage.MySQL.port"); + DBConnection.pass = plugin.getConfig().getString("Storage.MySQL.pass"); + DBConnection.db = plugin.getConfig().getString("Storage.MySQL.db"); + DBConnection.user = plugin.getConfig().getString("Storage.MySQL.user"); + DBConnection.init(); + for (Player player: Bukkit.getOnlinePlayers()) { + GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); + } + } + + public static void removeBlock(Block block) { + if (isAdjacentToThreeOrMoreSources(block)) { + block.setType(Material.WATER); + block.setData((byte) 0x0); + } else { + block.setType(Material.AIR); + } + } + + public static void removeUnusableAbilities(String player) { + BendingPlayer bPlayer = getBendingPlayer(player); + HashMap slots = bPlayer.getAbilities(); + HashMap finalabilities = new HashMap(); + try { + for (int i: slots.keySet()) { + if (canBend(player, slots.get(i))) { + finalabilities.put(i, slots.get(i)); + } + } + bPlayer.setAbilities(finalabilities); + } catch (Exception ex) { + + } + + } + + public static Vector rotateVectorAroundVector(Vector axis, Vector rotator, + double degrees) { + double angle = Math.toRadians(degrees); + Vector rotation = axis.clone(); + Vector rotate = rotator.clone(); + rotation = rotation.normalize(); + + Vector thirdaxis = rotation.crossProduct(rotate).normalize() + .multiply(rotate.length()); + + return rotate.multiply(Math.cos(angle)).add( + thirdaxis.multiply(Math.sin(angle))); + } + + public static void saveElements(BendingPlayer bPlayer) { + if (bPlayer == null) return; + String uuid = bPlayer.uuid.toString(); + + StringBuilder elements = new StringBuilder(); + if (bPlayer.hasElement(Element.Air)) elements.append("a"); + if (bPlayer.hasElement(Element.Water)) elements.append("w"); + if (bPlayer.hasElement(Element.Earth)) elements.append("e"); + if (bPlayer.hasElement(Element.Fire)) elements.append("f"); + if (bPlayer.hasElement(Element.Chi)) elements.append("c"); + + DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'"); + } + + public static void saveAbility(BendingPlayer bPlayer, int slot, String ability) { + if (bPlayer == null) return; + String uuid = bPlayer.uuid.toString(); + + //Temp code to block modifications of binds, Should be replaced when bind event is added. + if(MultiAbilityManager.playerAbilities.containsKey(Bukkit.getPlayer(bPlayer.getPlayerName()))) + return; + + HashMap abilities = bPlayer.getAbilities(); + + DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + slot + " = '" + (abilities.get(slot) == null ? null : abilities.get(slot)) + "' WHERE uuid = '" + uuid + "'"); + } + + public static void savePermaRemoved(BendingPlayer bPlayer) { + if (bPlayer == null) return; + String uuid = bPlayer.uuid.toString(); + + boolean permaRemoved = bPlayer.permaRemoved; + DBConnection.sql.modifyQuery("UPDATE pk_players SET permaremoved = '" + (permaRemoved ? "true" : "false") + "' WHERE uuid = '" + uuid + "'"); + } + + public static void stopBending() { + + List abilities = AbilityModuleManager.ability; + for (AbilityModule ab: abilities) { + ab.stop(); + } + + ArrayList combos = ComboManager.comboAbilityList; + for(ComboManager.ComboAbility c : combos) + if(c.getComboType() instanceof ComboAbilityModule) + ((ComboAbilityModule) c.getComboType()).stop(); + + AirMethods.stopBending(); + + EarthMethods.stopBending(); + + WaterMethods.stopBending(); + + FireMethods.stopBending(); + + ChiMethods.stopBending(); + + Flight.removeAll(); + TempBlock.removeAll(); + + MultiAbilityManager.removeAll(); + } + + + public static void setVelocity(Entity entity, Vector velocity){ + if (entity instanceof TNTPrimed){ + if (plugin.getConfig().getBoolean("Properties.BendingAffectFallingSand.TNT")) + entity.setVelocity(velocity.multiply(plugin.getConfig().getDouble("Properties.BendingAffectFallingSand.TNTStrengthMultiplier"))); + return; + } + if (entity instanceof FallingSand){ + if (plugin.getConfig().getBoolean("Properties.BendingAffectFallingSand.Normal")) + entity.setVelocity(velocity.multiply(plugin.getConfig().getDouble("Properties.BendingAffectFallingSand.NormalStrengthMultiplier"))); + return; + } + entity.setVelocity(velocity); + } + + public GeneralMethods(ProjectKorra plugin) { + GeneralMethods.plugin = plugin; + new AirMethods(plugin); + new ChiMethods(plugin); + new EarthMethods(plugin); + new FireMethods(plugin); + new WaterMethods(plugin); + } + + public static FallingBlock spawnFallingBlock(Location loc, int type) + { + return spawnFallingBlock(loc, type, (byte) 0); + } + + public static FallingBlock spawnFallingBlock(Location loc, Material type) + { + return spawnFallingBlock(loc, type, (byte) 0); + } + + + public static FallingBlock spawnFallingBlock(Location loc, int type, byte data) + { + return loc.getWorld().spawnFallingBlock(loc, type, data); + } + + + public static FallingBlock spawnFallingBlock(Location loc, Material type, byte data) + { + return loc.getWorld().spawnFallingBlock(loc, type, data); + } + + public static void playAvatarSound(Location loc) { + loc.getWorld().playSound(loc, Sound.ANVIL_LAND, 1, 10); + } + + public static Block getTopBlock(Location loc, int range){ + return getTopBlock(loc,range,range); + } + public static Block getTopBlock(Location loc, int positiveY, int negativeY) + { + /** + * Returns the top block based around loc. + * PositiveY is the maximum amount of distance it will check upward. + * Similarly, negativeY is for downward. + */ + Block block = loc.getBlock(); + Block blockHolder = block; + int y = 0; + //Only one of these while statements will go + while(blockHolder.getType() != Material.AIR && Math.abs(y) < Math.abs(positiveY)) + { + y++; + Block tempBlock = loc.clone().add(0,y,0).getBlock(); + if(tempBlock.getType() == Material.AIR) + return blockHolder; + blockHolder = tempBlock; + } + + while(blockHolder.getType() == Material.AIR && Math.abs(y) < Math.abs(negativeY)) + { + y--; + blockHolder = loc.clone().add(0,y,0).getBlock(); + if(blockHolder.getType() != Material.AIR) + return blockHolder; + + } + return null; + } + + public static Vector rotateXZ(Vector vec, double theta) + { + /** + * Rotates a vector around the Y plane. + */ + Vector vec2 = vec.clone(); + double x = vec2.getX(); + double z = vec2.getZ(); + vec2.setX(x * Math.cos(Math.toRadians(theta)) - z * Math.sin(Math.toRadians(theta))); + vec2.setZ(x * Math.sin(Math.toRadians(theta)) + z * Math.cos(Math.toRadians(theta))); + return vec2; + } + + public static int getMaxPresets(Player player) { + if (player.isOp()) return 500; + int cap = 0; + for (int i = 0; i <= 500; i++) { + if (player.hasPermission("bending.command.presets.create." + i)) cap = i; + } + return cap; + } + + public static boolean blockAbilities(Player player, List abilitiesToBlock, Location loc, double radius) { + /** + * Cycles through a list of ability names to check if any instances of + * the abilities exist at a specific location. If an instance of the ability is + * found then it will be removed, with the exception FireShield, and AirShield. + */ + boolean hasBlocked = false; + for(String ability : abilitiesToBlock){ + if(ability.equalsIgnoreCase("FireBlast")){ + hasBlocked = FireBlast.annihilateBlasts(loc, radius, player) || hasBlocked; + } + else if(ability.equalsIgnoreCase("EarthBlast")){ + hasBlocked = EarthBlast.annihilateBlasts(loc, radius, player) || hasBlocked; + } + else if(ability.equalsIgnoreCase("WaterManipulation")){ + hasBlocked = WaterManipulation.annihilateBlasts(loc, radius, player) || hasBlocked; + } + else if(ability.equalsIgnoreCase("AirSwipe")){ + hasBlocked = AirSwipe.removeSwipesAroundPoint(loc, radius) || hasBlocked; + } + else if(ability.equalsIgnoreCase("Combustion")){ + hasBlocked = Combustion.removeAroundPoint(loc, radius) || hasBlocked; + } + else if(ability.equalsIgnoreCase("FireShield")){ + hasBlocked = FireShield.isWithinShield(loc) || hasBlocked; + } + else if(ability.equalsIgnoreCase("AirShield")){ + hasBlocked = AirShield.isWithinShield(loc) || hasBlocked; + } + else if(ability.equalsIgnoreCase("WaterSpout")){ + hasBlocked = WaterSpout.removeSpouts(loc, radius, player) || hasBlocked; + } + else if(ability.equalsIgnoreCase("AirSpout")){ + hasBlocked = AirSpout.removeSpouts(loc, radius, player) || hasBlocked; + } + else if(ability.equalsIgnoreCase("Twister")){ + hasBlocked = AirCombo.removeAroundPoint(player, "Twister", loc, radius) || hasBlocked; + } + else if(ability.equalsIgnoreCase("AirStream")){ + hasBlocked = AirCombo.removeAroundPoint(player, "AirStream", loc, radius) || hasBlocked; + } + else if(ability.equalsIgnoreCase("AirSweep")){ + hasBlocked = AirCombo.removeAroundPoint(player, "AirSweep", loc, radius) || hasBlocked; + } + else if(ability.equalsIgnoreCase("FireKick")){ + hasBlocked = FireCombo.removeAroundPoint(player, "FireKick", loc, radius) || hasBlocked; + } + else if(ability.equalsIgnoreCase("FireSpin")){ + hasBlocked = FireCombo.removeAroundPoint(player, "FireSpin", loc, radius) || hasBlocked; + } + else if(ability.equalsIgnoreCase("FireWheel")){ + hasBlocked = FireCombo.removeAroundPoint(player, "FireWheel", loc, radius) || hasBlocked; + } + } + return hasBlocked; + } + + public static boolean hasRPG() { + if (Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG") != null) return true; + return false; + } + + public static Plugin getRPG() { + if (hasRPG()) { + return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG"); + } + return null; + } + + public static boolean hasItems() { + if (Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null) return true; + return false; + } + + public static Plugin getItems() { + if (hasItems()) { + return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems"); + } + return null; + } + + public static void writeToDebug(String message) { + try { + File dataFolder = plugin.getDataFolder(); + if (!dataFolder.exists()) { + dataFolder.mkdir(); + } + + File saveTo = new File(plugin.getDataFolder(), "debug.txt"); + if (!saveTo.exists()) { + saveTo.createNewFile(); + } + + FileWriter fw = new FileWriter(saveTo, true); + PrintWriter pw = new PrintWriter(fw); + pw.println(message); + pw.flush(); + pw.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static String getCurrentDate() { + DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + Date date = new Date(); + return dateFormat.format(date); + } + + public static void runDebug() { + File debugFile = new File(plugin.getDataFolder(), "debug.txt"); + if (debugFile.exists()) { + debugFile.delete(); // We're starting brand new. + } + writeToDebug("ProjectKorra Debug: Paste this on http://pastie.org and put it in your bug report thread."); + writeToDebug("===================="); + writeToDebug(""); + writeToDebug(""); + writeToDebug("Date Created: " + getCurrentDate()); + writeToDebug("Bukkit Version: " + Bukkit.getServer().getVersion()); + writeToDebug(""); + writeToDebug("ProjectKorra (Core) Information"); + writeToDebug("===================="); + writeToDebug("Version: " + plugin.getDescription().getVersion()); + writeToDebug("Author: " + plugin.getDescription().getAuthors()); + if (hasRPG()) { + writeToDebug(""); + writeToDebug("ProjectKorra (RPG) Information"); + writeToDebug("===================="); + writeToDebug("Version: " + getRPG().getDescription().getVersion()); + writeToDebug("Author: " + getRPG().getDescription().getAuthors()); + } + if (hasItems()) { + writeToDebug(""); + writeToDebug("ProjectKorra (Items) Information"); + writeToDebug("===================="); + writeToDebug("Version: " + getItems().getDescription().getVersion()); + writeToDebug("Author: " + getItems().getDescription().getAuthors()); + } + writeToDebug(""); + writeToDebug("Ability Information"); + writeToDebug("===================="); + for (String ability: AbilityModuleManager.abilities) { + if (StockAbilities.isStockAbility(ability) && !GeneralMethods.isDisabledStockAbility(ability)) { + writeToDebug(ability + " - STOCK ABILITY"); + } else { + writeToDebug(ability + " - UNOFFICIAL ABILITY"); + } + } + writeToDebug(""); + writeToDebug("Supported Plugins"); + writeToDebug("===================="); + + boolean respectWorldGuard = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectWorldGuard"); + boolean respectPreciousStones = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectPreciousStones"); + boolean respectFactions = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectFactions"); + boolean respectTowny = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectTowny"); + boolean respectGriefPrevention = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectGriefPrevention"); + boolean respectLWC = plugin.getConfig().getBoolean("Properties.RegionProtection.RespectLWC"); + PluginManager pm = Bukkit.getPluginManager(); + + Plugin wgp = pm.getPlugin("WorldGuard"); + Plugin psp = pm.getPlugin("PreciousStones"); + Plugin fcp = pm.getPlugin("Factions"); + Plugin twnp = pm.getPlugin("Towny"); + Plugin gpp = pm.getPlugin("GriefPrevention"); + Plugin massivecore = pm.getPlugin("MassiveCore"); + Plugin lwc = pm.getPlugin("LWC"); + + if (wgp != null && respectWorldGuard) { + writeToDebug("WorldGuard v" + wgp.getDescription().getVersion()); + } + if (psp != null && respectPreciousStones) { + writeToDebug("PreciousStones v" + psp.getDescription().getVersion()); + } + if (fcp != null && respectFactions) { + writeToDebug("Factions v" + fcp.getDescription().getVersion()); + } + if (massivecore != null && respectFactions) { + writeToDebug("MassiveCore v" + massivecore.getDescription().getVersion()); + } + if (twnp != null && respectTowny) { + writeToDebug("Towny v" + twnp.getDescription().getVersion()); + } + if (gpp != null && respectGriefPrevention) { + writeToDebug("GriefPrevention v" + gpp.getDescription().getVersion()); + } + if (lwc != null && respectLWC) { + writeToDebug("LWC v" + lwc.getDescription().getVersion()); + } + + writeToDebug(""); + writeToDebug("Plugins Hooking Into ProjectKorra (Core)"); + writeToDebug("===================="); + for (Plugin plugin: Bukkit.getPluginManager().getPlugins()) { + if (plugin.getDescription().getDepend() != null && plugin.getDescription().getDepend().contains("ProjectKorra")) { + writeToDebug(plugin.getDescription().getName() + " v" + plugin.getDescription().getVersion()); + } + } + } + + public static class BlockCacheElement { + private Player player; + private Block block; + private String ability; + private boolean allowed; + private long time; + + public BlockCacheElement(Player player, Block block, String ability, boolean allowed, long time) { + this.player = player; + this.block = block; + this.ability = ability; + this.allowed = allowed; + this.time = time; + } + + public Player getPlayer() { + return player; + } + + public void setPlayer(Player player) { + this.player = player; + } + + public Block getBlock() { + return block; + } + + public void setBlock(Block block) { + this.block = block; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public boolean isAllowed() { + return allowed; + } + + public void setAllowed(boolean allowed) { + this.allowed = allowed; + } + + public String getAbility() { + return ability; + } + + public void setAbility(String ability) { + this.ability = ability; + } + + } + + public static void startCacheCleaner(final double period) { + new BukkitRunnable() { + public void run() { + for(ConcurrentHashMap map : blockProtectionCache.values()) { + for(Iterator i = map.keySet().iterator(); i.hasNext();) { + Block key = i.next(); + BlockCacheElement value = map.get(key); + + if(System.currentTimeMillis() - value.getTime() > period) { + map.remove(key); + } + } + } + } + }.runTaskTimer(ProjectKorra.plugin, 0, (long) (period / 20)); + } + + /** Checks if an entity is Undead **/ + 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; + } + +} From bb6c333323df6a9090acbcfa868d42c01e00f7da Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 30 May 2015 03:07:52 +0100 Subject: [PATCH 02/25] Added to player quit event to clean up any multi abilities the player had active. --- .../projectkorra/ProjectKorra/PKListener.java | 2880 +++++++++-------- 1 file changed, 1441 insertions(+), 1439 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/PKListener.java b/src/com/projectkorra/ProjectKorra/PKListener.java index 3ef1dff3..e4b7de17 100644 --- a/src/com/projectkorra/ProjectKorra/PKListener.java +++ b/src/com/projectkorra/ProjectKorra/PKListener.java @@ -1,1439 +1,1441 @@ -package com.projectkorra.ProjectKorra; - -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; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockFormEvent; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockIgniteEvent; -import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDamageByBlockEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntityInteractEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.EntityTargetLivingEntityEvent; -import org.bukkit.event.entity.EntityTeleportEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.entity.ProjectileLaunchEvent; -import org.bukkit.event.entity.SlimeSplitEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType.SlotType; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerAnimationEvent; -import org.bukkit.event.player.PlayerFishEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerKickEvent; -import org.bukkit.event.player.PlayerMoveEvent; -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.PotionEffectType; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; - -import com.projectkorra.ProjectKorra.ComboManager.ClickType; -import com.projectkorra.ProjectKorra.Ability.AvatarState; -import com.projectkorra.ProjectKorra.CustomEvents.PlayerGrappleEvent; -import com.projectkorra.ProjectKorra.Objects.Preset; -import com.projectkorra.ProjectKorra.Utilities.GrapplingHookAPI; -import com.projectkorra.ProjectKorra.Utilities.HorizontalVelocityChangeEvent; -import com.projectkorra.ProjectKorra.airbending.AirBlast; -import com.projectkorra.ProjectKorra.airbending.AirBubble; -import com.projectkorra.ProjectKorra.airbending.AirBurst; -import com.projectkorra.ProjectKorra.airbending.AirMethods; -import com.projectkorra.ProjectKorra.airbending.AirScooter; -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.FlightAbility; -import com.projectkorra.ProjectKorra.airbending.Suffocate; -import com.projectkorra.ProjectKorra.airbending.Tornado; -import com.projectkorra.ProjectKorra.chiblocking.AcrobatStance; -import com.projectkorra.ProjectKorra.chiblocking.ChiComboManager; -import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; -import com.projectkorra.ProjectKorra.chiblocking.ChiPassive; -import com.projectkorra.ProjectKorra.chiblocking.HighJump; -import com.projectkorra.ProjectKorra.chiblocking.Paralyze; -import com.projectkorra.ProjectKorra.chiblocking.QuickStrike; -import com.projectkorra.ProjectKorra.chiblocking.RapidPunch; -import com.projectkorra.ProjectKorra.chiblocking.Smokescreen; -import com.projectkorra.ProjectKorra.chiblocking.SwiftKick; -import com.projectkorra.ProjectKorra.chiblocking.WarriorStance; -import com.projectkorra.ProjectKorra.earthbending.Catapult; -import com.projectkorra.ProjectKorra.earthbending.Collapse; -import com.projectkorra.ProjectKorra.earthbending.CompactColumn; -import com.projectkorra.ProjectKorra.earthbending.EarthArmor; -import com.projectkorra.ProjectKorra.earthbending.EarthBlast; -import com.projectkorra.ProjectKorra.earthbending.EarthColumn; -import com.projectkorra.ProjectKorra.earthbending.EarthGrab; -import com.projectkorra.ProjectKorra.earthbending.EarthMethods; -import com.projectkorra.ProjectKorra.earthbending.EarthPassive; -import com.projectkorra.ProjectKorra.earthbending.EarthSmash; -import com.projectkorra.ProjectKorra.earthbending.EarthTunnel; -import com.projectkorra.ProjectKorra.earthbending.EarthWall; -import com.projectkorra.ProjectKorra.earthbending.Extraction; -import com.projectkorra.ProjectKorra.earthbending.LavaFlow; -import com.projectkorra.ProjectKorra.earthbending.LavaFlow.AbilityType; -import com.projectkorra.ProjectKorra.earthbending.LavaSurge; -import com.projectkorra.ProjectKorra.earthbending.LavaWave; -import com.projectkorra.ProjectKorra.earthbending.MetalClips; -import com.projectkorra.ProjectKorra.earthbending.Shockwave; -import com.projectkorra.ProjectKorra.earthbending.Tremorsense; -import com.projectkorra.ProjectKorra.firebending.ArcOfFire; -import com.projectkorra.ProjectKorra.firebending.Combustion; -import com.projectkorra.ProjectKorra.firebending.Enflamed; -import com.projectkorra.ProjectKorra.firebending.Extinguish; -import com.projectkorra.ProjectKorra.firebending.FireBlast; -import com.projectkorra.ProjectKorra.firebending.FireBurst; -import com.projectkorra.ProjectKorra.firebending.FireJet; -import com.projectkorra.ProjectKorra.firebending.FireMethods; -import com.projectkorra.ProjectKorra.firebending.FireShield; -import com.projectkorra.ProjectKorra.firebending.FireStream; -import com.projectkorra.ProjectKorra.firebending.Fireball; -import com.projectkorra.ProjectKorra.firebending.HeatControl; -import com.projectkorra.ProjectKorra.firebending.Illumination; -import com.projectkorra.ProjectKorra.firebending.Lightning; -import com.projectkorra.ProjectKorra.firebending.RingOfFire; -import com.projectkorra.ProjectKorra.firebending.WallOfFire; -import com.projectkorra.ProjectKorra.waterbending.Bloodbending; -import com.projectkorra.ProjectKorra.waterbending.FreezeMelt; -import com.projectkorra.ProjectKorra.waterbending.IceBlast; -import com.projectkorra.ProjectKorra.waterbending.IceSpike2; -import com.projectkorra.ProjectKorra.waterbending.Melt; -import com.projectkorra.ProjectKorra.waterbending.OctopusForm; -import com.projectkorra.ProjectKorra.waterbending.Torrent; -import com.projectkorra.ProjectKorra.waterbending.WaterManipulation; -import com.projectkorra.ProjectKorra.waterbending.WaterMethods; -import com.projectkorra.ProjectKorra.waterbending.WaterPassive; -import com.projectkorra.ProjectKorra.waterbending.WaterSpout; -import com.projectkorra.ProjectKorra.waterbending.WaterWall; -import com.projectkorra.ProjectKorra.waterbending.WaterWave; -import com.projectkorra.ProjectKorra.waterbending.Wave; - -public class PKListener implements Listener { - - ProjectKorra plugin; - - public PKListener(ProjectKorra plugin) { - this.plugin = plugin; - } - - public static HashMap noFallEntities = new HashMap(); // Grappling Hooks - public static HashMap noGrapplePlayers = new HashMap(); // Grappling Hooks - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onEntityDamageByBlock(EntityDamageByBlockEvent event) { - if (event.getCause().equals(DamageCause.BLOCK_EXPLOSION)) { - if (event.getDamager() == null) { - event.setCancelled(true); - } - } - - if (event.getDamager() != null) { - if (LavaWave.isBlockInWave(event.getDamager())) { - event.setCancelled(true); - } - } - - } - - @EventHandler - public void onHorizontalCollision(HorizontalVelocityChangeEvent e) - { - if(!plugin.getConfig().getBoolean("Properties.HorizontalCollisionPhysics.Enabled")) - return; - - if(e.getEntity() instanceof LivingEntity) - { - if(e.getEntity().getEntityId() != e.getInstigator().getEntityId()) - { - double minimumDistance = plugin.getConfig().getDouble("Properties.HorizontalCollisionPhysics.WallDamageMinimumDistance"); - double damage = ((e.getDistanceTraveled() - minimumDistance) < 0 ? 0 : e.getDistanceTraveled() - minimumDistance) / (e.getDifference().length()); - if(damage > 0) - GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), damage); - } - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerGrapple(PlayerGrappleEvent event) { - if (event.isCancelled()) return; - if (!plugin.getConfig().getBoolean("Properties.CustomItems.GrapplingHook.Enable")) return; - - Player player = event.getPlayer(); - if (!GeneralMethods.isBender(player.getName(), Element.Chi) && (!GeneralMethods.isBender(player.getName(), Element.Earth) || !EarthMethods.canMetalbend(player))) { - event.setCancelled(true); - return; - } - if (GeneralMethods.isBender(player.getName(), Element.Chi) && !player.hasPermission("bending.chi.grapplinghook")) { - event.setCancelled(true); - return; - } - - if (GeneralMethods.isBender(player.getName(), Element.Earth) && !player.hasPermission("bending.earth.grapplinghook")) { - event.setCancelled(true); - return; - } - if (Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player) || Bloodbending.isBloodbended(player) || Suffocate.isBreathbent(player)) { - event.setCancelled(true); - } - - event.getHookItem().setDurability((short) - 10); - if (noGrapplePlayers.containsKey(player.getName())) { - return; - } - - Entity e = event.getPulledEntity(); - Location loc = event.getPullLocation(); - - if (player.equals(e)) { - if (player.getLocation().distance(loc) < 3) { // Too close - GrapplingHookAPI.pullPlayerSlightly(player, loc); - } else { - GrapplingHookAPI.pullEntityToLocation(player, loc); - } - - if (GrapplingHookAPI.addUse(player, event.getHookItem())) { - GrapplingHookAPI.playGrappleSound(player.getLocation()); - } - GrapplingHookAPI.addPlayerCooldown(player, 100); - } - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onProjectileHit(ProjectileHitEvent event) { - Integer id = event.getEntity().getEntityId(); - if (Smokescreen.snowballs.contains(id)) { - Location loc = event.getEntity().getLocation(); - Smokescreen.playEffect(loc); - for (Entity en: GeneralMethods.getEntitiesAroundPoint(loc, Smokescreen.radius)) { - Smokescreen.applyBlindness(en); - } - 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")); - //// } - //// } - // } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void fishEvent(PlayerFishEvent event) { - if (event.isCancelled()) return; - Player player = event.getPlayer(); - if (GrapplingHookAPI.isGrapplingHook(player.getItemInHand())) { - if (event.getState() == PlayerFishEvent.State.IN_GROUND) { - Location loc = event.getHook().getLocation(); - for (Entity ent: event.getHook().getNearbyEntities(1.5, 1, 1.5)) { - if (ent instanceof Item) { - PlayerGrappleEvent e = new PlayerGrappleEvent(player, ent, player.getLocation()); - plugin.getServer().getPluginManager().callEvent(e); - return; - } - } - - PlayerGrappleEvent e = new PlayerGrappleEvent(player, player, loc); - plugin.getServer().getPluginManager().callEvent(e); - } - } - } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerInteraction(PlayerInteractEvent event) { - if (event.isCancelled()) return; - Player player = event.getPlayer(); - - if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { - GeneralMethods.cooldowns.put(player.getName(), System.currentTimeMillis()); - ComboManager.addComboAbility(player, ClickType.RIGHTCLICK); - String ability = GeneralMethods.getBoundAbility(player); - if(ability != null && ability.equalsIgnoreCase("EarthSmash")) - new EarthSmash(player, EarthSmash.ClickType.RIGHTCLICK); - } - if (Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player) || Bloodbending.isBloodbended(player) || Suffocate.isBreathbent(player)) { - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockPlace(BlockPlaceEvent event) { - if (event.isCancelled()) return; - Player player = event.getPlayer(); - GeneralMethods.cooldowns.put(player.getName(), System.currentTimeMillis()); - if (Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player) || Bloodbending.isBloodbended(player) || Suffocate.isBreathbent(player)) { - event.setCancelled(true); - } - } - - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockFlowTo(BlockFromToEvent event) { - if (event.isCancelled()) return; - Block toblock = event.getToBlock(); - Block fromblock = event.getBlock(); - if (EarthMethods.isLava(fromblock)) { - event.setCancelled(!EarthPassive.canFlowFromTo(fromblock, toblock)); - } - if (WaterMethods.isWater(fromblock)) { - event.setCancelled(!AirBubble.canFlowTo(toblock)); - if (!event.isCancelled()) { - event.setCancelled(!WaterManipulation.canFlowFromTo(fromblock, - toblock)); - } - if (!event.isCancelled()) { - if (Illumination.blocks.containsKey(toblock)) - toblock.setType(Material.AIR); - } - } - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent e) { - Player player = e.getPlayer(); - GeneralMethods.createBendingPlayer(e.getPlayer().getUniqueId(), player.getName()); - } - - public static void login(BendingPlayer pl) { - ProjectKorra plugin = ProjectKorra.plugin; - Player player = Bukkit.getPlayer(pl.getUUID()); - - if (player == null) { - return; - } - - if (GeneralMethods.toggedOut.contains(player.getUniqueId())) { - GeneralMethods.getBendingPlayer(player.getName()).isToggled = false; - player.sendMessage(ChatColor.YELLOW + "Reminder, you toggled your bending before signing off. Enable it again with /bending toggle."); - } - - Preset.loadPresets(player); - String append = ""; - boolean chatEnabled = ProjectKorra.plugin.getConfig().getBoolean("Properties.Chat.Enable"); - if ((player.hasPermission("bending.avatar") || GeneralMethods.getBendingPlayer(player.getName()).elements.size() > 1) && chatEnabled) { - append = plugin.getConfig().getString("Properties.Chat.Prefixes.Avatar"); - } else if (GeneralMethods.isBender(player.getName(), Element.Air) && chatEnabled) { - append = plugin.getConfig().getString("Properties.Chat.Prefixes.Air"); - } else if (GeneralMethods.isBender(player.getName(), Element.Water) && chatEnabled) { - append = plugin.getConfig().getString("Properties.Chat.Prefixes.Water"); - } else if (GeneralMethods.isBender(player.getName(), Element.Earth) && chatEnabled) { - append = plugin.getConfig().getString("Properties.Chat.Prefixes.Earth"); - } else if (GeneralMethods.isBender(player.getName(), Element.Fire) && chatEnabled) { - append = plugin.getConfig().getString("Properties.Chat.Prefixes.Fire"); - } else if (GeneralMethods.isBender(player.getName(), Element.Chi) && chatEnabled) { - append = plugin.getConfig().getString("Properties.Chat.Prefixes.Chi"); - } - - if (chatEnabled) { - player.setDisplayName(append + player.getName()); - } - - // Handle the AirSpout/WaterSpout login glitches - if (player.getGameMode() != GameMode.CREATIVE) { - HashMap bound = GeneralMethods.getBendingPlayer(player.getName()).getAbilities(); - for (String str : bound.values()) { - if (str.equalsIgnoreCase("AirSpout") || str.equalsIgnoreCase("WaterSpout")) { - final Player fplayer = player; - new BukkitRunnable() { - public void run() { - fplayer.setFlying(false); - fplayer.setAllowFlight(false); - } - }.runTaskLater(ProjectKorra.plugin, 2); - break; - } - } - } - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - - Player player = event.getPlayer(); - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - if (bPlayer != null) { - if (GeneralMethods.toggedOut.contains(player.getUniqueId()) && bPlayer.isToggled()) - GeneralMethods.toggedOut.remove(player.getUniqueId()); - if (!bPlayer.isToggled()) - GeneralMethods.toggedOut.add(player.getUniqueId()); - } - - if (Commands.invincible.contains(event.getPlayer().getName())) { - Commands.invincible.remove(event.getPlayer().getName()); - } - Preset.unloadPreset(player); - BendingPlayer.players.remove(event.getPlayer().getName()); - if (EarthArmor.instances.containsKey(event.getPlayer())) { - EarthArmor.removeEffect(event.getPlayer()); - event.getPlayer().removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); - } - - for(Player p : MetalClips.instances.keySet()) - { - if(MetalClips.instances.get(p).getTarget() != null && - MetalClips.instances.get(p).getTarget().getEntityId() == event.getPlayer().getEntityId()) - { - MetalClips.instances.get(p).remove(); - } - } - - com.projectkorra.ProjectKorra.airbending.FlightAbility.remove(event.getPlayer()); - } - - @EventHandler - public void playerIsKicked(PlayerKickEvent event) { - if(event.isCancelled()) return; - - com.projectkorra.ProjectKorra.airbending.FlightAbility.remove(event.getPlayer()); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerSneak(PlayerToggleSneakEvent event) { - Player player = event.getPlayer(); - - if (event.isCancelled()) return; - - if(player.isSneaking()) - ComboManager.addComboAbility(player, ComboManager.ClickType.SHIFTUP); - else - ComboManager.addComboAbility(player, ComboManager.ClickType.SHIFTDOWN); - - if(Suffocate.isBreathbent(player)) { - if(!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterManipulation")) { - event.setCancelled(true); - } - } - - if (Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player) || Bloodbending.isBloodbended(player)) { - event.setCancelled(true); - return; - } - - AirScooter.check(player); - - String abil = GeneralMethods.getBoundAbility(player); - if (abil == null) { - return; - } - - if (ChiMethods.isChiBlocked(player.getName())) { - event.setCancelled(true); - return; - } - - if (!player.isSneaking() && GeneralMethods.canBend(player.getName(), abil)) { - if (GeneralMethods.isDisabledStockAbility(abil)) - return; - if (AirMethods.isAirAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) { - return; - } - if (abil.equalsIgnoreCase("Tornado")) { - new Tornado(player); - } - if (abil.equalsIgnoreCase("AirBlast")) { - AirBlast.setOrigin(player); - } - if (abil.equalsIgnoreCase("AirBurst")) { - new AirBurst(player); - } - if (abil.equalsIgnoreCase("AirSuction")) { - AirSuction.setOrigin(player); - } - if (abil.equalsIgnoreCase("AirSwipe")) { - AirSwipe.charge(player); - } - if (abil.equalsIgnoreCase("AirShield")) { - new AirShield(player); - } - if(abil.equalsIgnoreCase("Suffocate")) { - new Suffocate(player); - } - if(abil.equalsIgnoreCase("Flight")) { - if(player.isSneaking() || !AirMethods.canAirFlight(player)) return; - new com.projectkorra.ProjectKorra.airbending.FlightAbility(player); - } - - } - - if (WaterMethods.isWaterAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) { - return; - } - if (abil.equalsIgnoreCase("Bloodbending")) { - new Bloodbending(player); - } - if (abil.equalsIgnoreCase("IceBlast")) { - new IceBlast(player); - } - if (abil.equalsIgnoreCase("IceSpike")) { - new IceSpike2(player); - } - if (abil.equalsIgnoreCase("OctopusForm")) { - OctopusForm.form(player); - } - if (abil.equalsIgnoreCase("PhaseChange")) { - new Melt(player); - } - if (abil.equalsIgnoreCase("WaterManipulation")) { - new WaterManipulation(player); - } - if (abil.equalsIgnoreCase("Surge")) { - WaterWall.form(player); - } - if (abil.equalsIgnoreCase("Torrent")) { - Torrent.create(player); - } - } - - if (EarthMethods.isEarthAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) { - return; - } - if (abil.equalsIgnoreCase("EarthBlast")) { - new EarthBlast(player); - } - if (abil.equalsIgnoreCase("RaiseEarth")) { - new EarthWall(player); - } - if (abil.equalsIgnoreCase("Collapse")) { - new Collapse(player); - } - if (abil.equalsIgnoreCase("Shockwave")) { - new Shockwave(player); - } - if (abil.equalsIgnoreCase("EarthGrab")) { - EarthGrab.EarthGrabSelf(player); - } - if (abil.equalsIgnoreCase("EarthTunnel")) { - new EarthTunnel(player); - } - - if (abil.equalsIgnoreCase("Tremorsense")) { - GeneralMethods.getBendingPlayer(player.getName()).toggleTremorsense(); - } - - if (abil.equalsIgnoreCase("Extraction")) { - new Extraction(player); - } - - if(abil.equalsIgnoreCase("MetalClips")) - { - if(MetalClips.instances.containsKey(player)) - { - if(MetalClips.instances.get(player).getTarget() == null) - MetalClips.instances.get(player).magnet(); - else - MetalClips.instances.get(player).control(); - } - else - new MetalClips(player, 1); - } - -// if (abil.equalsIgnoreCase("LavaSurge")) { -// new LavaSurge(player); -// } - - if (abil.equalsIgnoreCase("LavaFlow")) { - new LavaFlow(player,LavaFlow.AbilityType.SHIFT); - } - if (abil.equalsIgnoreCase("EarthSmash")) { - new EarthSmash(player, EarthSmash.ClickType.SHIFT); - } - - } - - if (FireMethods.isFireAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) { - return; - } - if (abil.equalsIgnoreCase("Blaze")) { - new RingOfFire(player); - } - if (abil.equalsIgnoreCase("FireBlast")) { - new Fireball(player); - } - if (abil.equalsIgnoreCase("HeatControl")) { - new HeatControl(player); - } - if (abil.equalsIgnoreCase("FireBurst")) { - new FireBurst(player); - } - if (abil.equalsIgnoreCase("FireShield")) { - FireShield.shield(player); - } - if (abil.equalsIgnoreCase("Lightning")) { - new Lightning(player); - } - if (abil.equalsIgnoreCase("Combustion")) { - new Combustion(player); - } - } - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockIgnite(BlockIgniteEvent event) { - if (event.isCancelled()) return; - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerMove(PlayerMoveEvent event) { - if (event.isCancelled()) return; - - Player player = event.getPlayer(); - if (Paralyze.isParalyzed(player)) { - event.setCancelled(true); - return; - } - - if(ChiComboManager.isParalyzed(player)) - { - event.setTo(event.getFrom()); - return; - } - - if (Suffocate.isBreathbent(player)) { - Location loc = event.getFrom(); - Location toLoc = player.getLocation(); - - if (loc.getX() != toLoc.getX() || loc.getY() != toLoc.getY() || loc.getZ() != toLoc.getZ()) { - event.setCancelled(true); - return; - } - } - - if (WaterSpout.instances.containsKey(event.getPlayer()) || AirSpout.getPlayers().contains(event.getPlayer())) { - Vector vel = new Vector(); - vel.setX(event.getTo().getX() - event.getFrom().getX()); - vel.setY(event.getTo().getY() - event.getFrom().getY()); - vel.setZ(event.getTo().getZ() - event.getFrom().getZ()); - // You now know the old velocity. Set to match recommended velocity - double currspeed = vel.length(); - double maxspeed = .15; - if (currspeed > maxspeed) { - // only if moving set a factor - // double recspeed = 0.6; - // vel = vel.ultiply(recspeed * currspeed); - vel = vel.normalize().multiply(maxspeed); - // apply the new velocity (MAY REQUIRE A SCHEDULED TASK - // INSTEAD!) - event.getPlayer().setVelocity(vel); - } - } - - if (Bloodbending.isBloodbended(player)) { - double distance1, distance2; - Location loc = Bloodbending.getBloodbendingLocation(player); - distance1 = event.getFrom().distance(loc); - distance2 = event.getTo().distance(loc); - if (distance2 > distance1) { - player.setVelocity(new Vector(0, 0, 0)); - } - } - - if(FlightAbility.instances.containsKey(event.getPlayer().getName())) { - if(com.projectkorra.ProjectKorra.airbending.FlightAbility.isHovering(event.getPlayer())) { - Location loc = event.getFrom(); - Location toLoc = player.getLocation(); - - if (loc.getX() != toLoc.getX() || loc.getY() != toLoc.getY() || loc.getZ() != toLoc.getZ()) { - event.setCancelled(true); - return; - } - } - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityTargetLiving(EntityTargetLivingEntityEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity)) { - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onTarget(EntityTargetEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity)) { - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) - event.setCancelled(true); - - if (event.getEntityType() == EntityType.FALLING_BLOCK) { - if (LavaSurge.falling.contains(entity)) { - LavaSurge.falling.remove(entity); - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void onEntityExplode(EntityExplodeEvent event) { - if (event.isCancelled()) return; - - for (Block block : event.blockList()) { - EarthBlast blast = EarthBlast.getBlastFromSource(block); - - if (blast != null) { - blast.cancel(); - } - if (FreezeMelt.frozenblocks.containsKey(block)) { - FreezeMelt.thaw(block); - } - if (WaterWall.wallblocks.containsKey(block)) { - block.setType(Material.AIR); - } - if (!Wave.canThaw(block)) { - Wave.thaw(block); - } - if (EarthMethods.movedearth.containsKey(block)) { - EarthMethods.removeRevertIndex(block); - } - } - - - - } - - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityExplodeEvent(EntityExplodeEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (entity != null) - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) - || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityInteractEvent(EntityInteractEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityShootBowEvent(EntityShootBowEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityTeleportEvent(EntityTeleportEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityProjectileLaunchEvent(ProjectileLaunchEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntitySlimeSplitEvent(SlimeSplitEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) - event.setCancelled(true); - } - - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerSwing(PlayerAnimationEvent event) { - if (event.isCancelled()) return; - - Player player = event.getPlayer(); - ComboManager.addComboAbility(player, ComboManager.ClickType.LEFTCLICK); - - if(Suffocate.isBreathbent(player)) { - if(!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterManipulation")) { - event.setCancelled(true); - } - } - - if (Bloodbending.isBloodbended(player) || Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player)) { - event.setCancelled(true); - return; - } - - if (ChiMethods.isChiBlocked(player.getName())) { - event.setCancelled(true); - return; - } - - AirScooter.check(player); - - String abil = GeneralMethods.getBoundAbility(player); - if (abil == null) return; - if (GeneralMethods.canBend(player.getName(), abil)) { - if (GeneralMethods.isDisabledStockAbility(abil)) - return; - - if (AirMethods.isAirAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) { - return; - } - if (abil.equalsIgnoreCase("AirBlast")) { - new AirBlast(player); - } - if (abil.equalsIgnoreCase("AirSuction")) { - new AirSuction(player); - } - if (abil.equalsIgnoreCase("AirBurst")) { - AirBurst.coneBurst(player); - } - if (abil.equalsIgnoreCase("AirScooter")) { - new AirScooter(player); - } - if (abil.equalsIgnoreCase("AirSpout")) { - new AirSpout(player); - } - if (abil.equalsIgnoreCase("AirSwipe")) { - new AirSwipe(player); - } - if(abil.equalsIgnoreCase("Flight")) { - if(!ProjectKorra.plugin.getConfig().getBoolean("Abilities.Air.Flight.HoverEnabled") - || !AirMethods.canAirFlight(player)) return; - - if(com.projectkorra.ProjectKorra.airbending.FlightAbility.instances.containsKey(event.getPlayer().getName())) { - if(com.projectkorra.ProjectKorra.airbending.FlightAbility.isHovering(event.getPlayer())) { - com.projectkorra.ProjectKorra.airbending.FlightAbility.setHovering(event.getPlayer(), false); - }else{ - com.projectkorra.ProjectKorra.airbending.FlightAbility.setHovering(event.getPlayer(), true); - } - } - } - } - if (WaterMethods.isWaterAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) { - return; - } - if (abil.equalsIgnoreCase("Bloodbending")) { - Bloodbending.launch(player); - } - if (abil.equalsIgnoreCase("IceBlast")) { - IceBlast.activate(player); - } - if (abil.equalsIgnoreCase("IceSpike")) { - IceSpike2.activate(player); - } - if (abil.equalsIgnoreCase("OctopusForm")) { - new OctopusForm(player); - } - if (abil.equalsIgnoreCase("PhaseChange")) { - new FreezeMelt(player); - } - if (abil.equalsIgnoreCase("WaterSpout")) { - new WaterSpout(player); - } - if (abil.equalsIgnoreCase("WaterManipulation")) { - WaterManipulation.moveWater(player); - } - if (abil.equalsIgnoreCase("Surge")) { - new WaterWall(player); - } - if (abil.equalsIgnoreCase("Torrent")) { - new Torrent(player); - } - } - - if (EarthMethods.isEarthAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) { - return; - } - if (abil.equalsIgnoreCase("Catapult")) { - new Catapult(player); - } - - if (abil.equalsIgnoreCase("EarthBlast")) { - EarthBlast.throwEarth(player); - } - - if (abil.equalsIgnoreCase("RaiseEarth")) { - new EarthColumn(player); - } - - if (abil.equalsIgnoreCase("Collapse")) { - new CompactColumn(player); - } - if (abil.equalsIgnoreCase("Shockwave")) { - Shockwave.coneShockwave(player); - } - if (abil.equalsIgnoreCase("EarthArmor")) { - new EarthArmor(player); - } - - if (abil.equalsIgnoreCase("EarthGrab")) { - new EarthGrab(player); - } - - if (abil.equalsIgnoreCase("Tremorsense")) { - new Tremorsense(player); - } - - if(abil.equalsIgnoreCase("MetalClips")) - { - if(!MetalClips.instances.containsKey(player)) - new MetalClips(player, 0); - else if(MetalClips.instances.containsKey(player)) - if(MetalClips.instances.get(player).metalclips < (player.hasPermission("bending.ability.MetalClips.4clips") ? 4 : 3)) - MetalClips.instances.get(player).shootMetal(); - else - MetalClips.instances.get(player).launch(); - } - - if (abil.equalsIgnoreCase("LavaSurge")) { - if(LavaSurge.instances.containsKey(player)) - LavaSurge.instances.get(player).launch(); - } - - if (abil.equalsIgnoreCase("LavaFlow")) { - new LavaFlow(player,AbilityType.CLICK); - } - - if (abil.equalsIgnoreCase("EarthSmash")) { - new EarthSmash(player, EarthSmash.ClickType.LEFTCLICK); - } - } - if (FireMethods.isFireAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) { - return; - } - - if (abil.equalsIgnoreCase("Blaze")) { - new ArcOfFire(player); - } - if (abil.equalsIgnoreCase("FireBlast")) { - new FireBlast(player); - } - if (abil.equalsIgnoreCase("FireJet")) { - new FireJet(player); - } - if (abil.equalsIgnoreCase("HeatControl")) { - new Extinguish(player); - } - if (abil.equalsIgnoreCase("Illumination")) { - new Illumination(player); - } - if (abil.equalsIgnoreCase("FireBurst")) { - FireBurst.coneBurst(player); - } - if (abil.equalsIgnoreCase("FireShield")) { - new FireShield(player); - } - if (abil.equalsIgnoreCase("WallOfFire")) { - new WallOfFire(player); - } - if (abil.equalsIgnoreCase("Combustion")) { - Combustion.explode(player); - } - } - - if (ChiMethods.isChiAbility(abil)) { - if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { - return; - } - if (abil.equalsIgnoreCase("HighJump")) { - new HighJump(player); - } - if (abil.equalsIgnoreCase("RapidPunch")) { - new RapidPunch(player); - } - if (abil.equalsIgnoreCase("Paralyze")) { - // - } - if (abil.equalsIgnoreCase("Smokescreen")) { - new Smokescreen(player); - } - if (abil.equalsIgnoreCase("WarriorStance")) { - new WarriorStance(player); - } - - if (abil.equalsIgnoreCase("AcrobatStance")) { - new AcrobatStance(player); - } - - if (abil.equalsIgnoreCase("QuickStrike")) - { - new QuickStrike(player); - } - - if (abil.equalsIgnoreCase("SwiftKick")) - { - new SwiftKick(player); - } - } - - if (abil.equalsIgnoreCase("AvatarState")) { - new AvatarState(player); - } - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onInventoryClick(InventoryClickEvent event) { - if (event.isCancelled()) return; - - for(Player p : MetalClips.instances.keySet()) - { - if(MetalClips.instances.get(p).getTarget() != null) - if(MetalClips.instances.get(p).getTarget().getEntityId() == event.getWhoClicked().getEntityId()) - event.setCancelled(true); - } - - if (event.getSlotType() == SlotType.ARMOR - && !EarthArmor.canRemoveArmor((Player) event.getWhoClicked())) - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerDeath(PlayerDeathEvent event) { - if (EarthArmor.instances.containsKey(event.getEntity())) { - List drops = event.getDrops(); - List newdrops = new ArrayList(); - for (int i = 0; i < drops.size(); i++) { - if (!(drops.get(i).getType() == Material.LEATHER_BOOTS - || drops.get(i).getType() == Material.LEATHER_CHESTPLATE - || drops.get(i).getType() == Material.LEATHER_HELMET - || drops.get(i).getType() == Material.LEATHER_LEGGINGS || drops - .get(i).getType() == Material.AIR)) - newdrops.add((drops.get(i))); - } - if (EarthArmor.instances.get(event.getEntity()).oldarmor != null) { - for (ItemStack is : EarthArmor.instances.get(event.getEntity()).oldarmor) { - if (!(is.getType() == Material.AIR)) - newdrops.add(is); - } - } - event.getDrops().clear(); - event.getDrops().addAll(newdrops); - EarthArmor.removeEffect(event.getEntity()); - } - if (MetalClips.instances.containsKey(event.getEntity())) { - MetalClips.instances.get(event.getEntity()).remove(); - List drops = event.getDrops(); - List newdrops = new ArrayList(); - for (int i = 0; i < drops.size(); i++) { - if (!(drops.get(i).getType() == Material.IRON_HELMET - || drops.get(i).getType() == Material.IRON_CHESTPLATE - || drops.get(i).getType() == Material.IRON_LEGGINGS - || drops.get(i).getType() == Material.IRON_BOOTS - || drops.get(i).getType() == Material.AIR)) - newdrops.add((drops.get(i))); - } - event.getDrops().clear(); - event.getDrops().addAll(newdrops); - - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { - if (event.isCancelled()) return; - - Player p = event.getPlayer(); - if (Tornado.getPlayers().contains(p) || Bloodbending.isBloodbended(p) || Suffocate.isBreathbent(p) - || FireJet.getPlayers().contains(p) - || AvatarState.getPlayers().contains(p)) { - event.setCancelled(p.getGameMode() != GameMode.CREATIVE); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityCombust(EntityCombustEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - Block block = entity.getLocation().getBlock(); - if (FireStream.ignitedblocks.containsKey(block) && entity instanceof LivingEntity) { - new Enflamed(entity, FireStream.ignitedblocks.get(block)); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityDamageBlock(EntityDamageByBlockEvent event) { - - } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onEntityDamageEvent(EntityDamageEvent event) { - if (event.isCancelled()) return; - - Entity entity = event.getEntity(); - - 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); - } - - if (entity instanceof Player) { - Player player = (Player) entity; - if (GeneralMethods.getBoundAbility(player) != null && GeneralMethods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) { - if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK) { - player.setFireTicks(0); - event.setCancelled(true); - } - } - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockMeltEvent(BlockFadeEvent event) { - if (event.isCancelled()) return; - - Block block = event.getBlock(); - if (block.getType() == Material.FIRE) { - return; - } - event.setCancelled(Illumination.blocks.containsKey(block)); - if (!event.isCancelled()) { - event.setCancelled(!WaterManipulation.canPhysicsChange(block)); - } - if (!event.isCancelled()) { - event.setCancelled(!EarthPassive.canPhysicsChange(block)); - } - if (!event.isCancelled()) { - event.setCancelled(FreezeMelt.frozenblocks.containsKey(block)); - } - if (!event.isCancelled()) { - event.setCancelled(!Wave.canThaw(block)); - } - if (!event.isCancelled()) { - event.setCancelled(!Torrent.canThaw(block)); - } - if (FireStream.ignitedblocks.containsKey(block)) { - FireStream.remove(block); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockBreak(BlockBreakEvent event) { - if (event.isCancelled()) return; - - Block block = event.getBlock(); - Player player = event.getPlayer(); - if (WaterWall.wasBrokenFor(player, block) - || OctopusForm.wasBrokenFor(player, block) - || Torrent.wasBrokenFor(player, block) - || WaterWave.wasBrokenFor(player, block)){ - event.setCancelled(true); - return; - } - EarthBlast blast = EarthBlast.getBlastFromSource(block); - if (blast != null) { - blast.cancel(); - } - - if (FreezeMelt.frozenblocks.containsKey(block)) { - FreezeMelt.thaw(block); - event.setCancelled(true); - // } else if (!WalkOnWater.canThaw(block)) { - // WalkOnWater.thaw(block); - } else if (WaterWall.wallblocks.containsKey(block)) { - WaterWall.thaw(block); - event.setCancelled(true); - } else if (Illumination.blocks.containsKey(block)) { - event.setCancelled(true); - // } else if (Illumination.blocks.containsKey(block - // .getRelative(BlockFace.UP))) { - // event.setCancelled(true); - } else if (!Wave.canThaw(block)) { - Wave.thaw(block); - event.setCancelled(true); - // event.setCancelled(true); - } else if (EarthMethods.movedearth.containsKey(block)) { - // Methods.removeEarthbendedBlockIndex(block); - EarthMethods.removeRevertIndex(block); - } else if (TempBlock.isTempBlock(block)) { - TempBlock.revertBlock(block, Material.AIR); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerChat(AsyncPlayerChatEvent event) { - if (event.isCancelled()) return; - - if (!plugin.getConfig().getBoolean("Properties.Chat.Enable")) { - return; - } - - Player player = event.getPlayer(); - ChatColor color = ChatColor.WHITE; - - if (player.hasPermission("bending.avatar") || GeneralMethods.getBendingPlayer(player.getName()).elements.size() > 1) { - color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Avatar")); - } else if (GeneralMethods.isBender(player.getName(), Element.Air)) { - color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Air")); - } else if (GeneralMethods.isBender(player.getName(), Element.Water)) { - color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Water")); - } else if (GeneralMethods.isBender(player.getName(), Element.Earth)) { - color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Earth")); - } else if (GeneralMethods.isBender(player.getName(), Element.Fire)) { - color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Fire")); - } else if (GeneralMethods.isBender(player.getName(), Element.Chi)) { - color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Chi")); - } - - String format = plugin.getConfig().getString("Properties.Chat.Format"); - format = format.replace("", "%2$s"); - format = format.replace("", color + player.getDisplayName() + ChatColor.RESET); - event.setFormat(format); - - } - - @EventHandler - public void onEntitySuffocatedByTempBlocks(EntityDamageEvent event) { - if(event.isCancelled()) return; - - if(event.getCause() == DamageCause.SUFFOCATION) { - if(TempBlock.isTempBlock(event.getEntity().getLocation().add(0, 1, 0).getBlock())) { - event.setCancelled(true); - } - } - } - - @EventHandler - public void onPlayerDamageByPlayer(EntityDamageByEntityEvent e) { - if (e.isCancelled()) return; - - Entity source = e.getDamager(); - Entity entity = e.getEntity(); - Fireball fireball = Fireball.getFireball(source); - - if (fireball != null) { - e.setCancelled(true); - fireball.dealDamage(entity); - return; - } - - // if (Combustion.fireballs.contains(source.getEntityId())) { - // e.setCancelled(true); - // } - - if (Paralyze.isParalyzed(e.getDamager()) - || ChiComboManager.isParalyzed(e.getDamager())) { - e.setCancelled(true); - return; - } - - if(entity instanceof Player) { - Suffocate.remove((Player) entity); - } - - Entity en = e.getEntity(); - if (en instanceof Player) { - // Player p = (Player) en; // This is the player getting hurt. - if (e.getDamager() instanceof Player) { // This is the player hitting someone. - Player sourceplayer = (Player) e.getDamager(); - Player targetplayer = (Player) e.getEntity(); - if (GeneralMethods.canBendPassive(sourceplayer.getName(), Element.Chi)) { - if (GeneralMethods.isBender(sourceplayer.getName(), Element.Chi) && e.getCause() == DamageCause.ENTITY_ATTACK && e.getDamage() == 1) { - if (GeneralMethods.isWeapon(sourceplayer.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { - return; - } - if (ChiPassive.willChiBlock(sourceplayer, targetplayer)) { - if (GeneralMethods.getBoundAbility(sourceplayer) != null && GeneralMethods.getBoundAbility(sourceplayer).equalsIgnoreCase("Paralyze")) { - new Paralyze(sourceplayer, targetplayer); - } else { - 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 (GeneralMethods.canBendPassive(sourceplayer.getName(), Element.Chi)) { - if (GeneralMethods.isWeapon(sourceplayer.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { - return; - } - if (e.getCause() == DamageCause.ENTITY_ATTACK) { - if (GeneralMethods.getBoundAbility(sourceplayer) != null && GeneralMethods.getBoundAbility(sourceplayer).equalsIgnoreCase("Paralyze") && e.getDamage() == 1) { - if (ChiPassive.willChiBlock(sourceplayer, targetplayer)) { - new Paralyze(sourceplayer, targetplayer); - } - } - } - } - } - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onPlayerDamage(EntityDamageEvent event) { - if (event.isCancelled()) return; - - if (event.getEntity() instanceof Player) { - Player player = (Player) event.getEntity(); - - if (GeneralMethods.isBender(player.getName(), Element.Earth) && event.getCause() == DamageCause.FALL) { - Shockwave.fallShockwave(player); - } - - if (GeneralMethods.isBender(player.getName(), Element.Air) && event.getCause() == DamageCause.FALL && GeneralMethods.canBendPassive(player.getName(), Element.Air)) { - new Flight(player); - player.setAllowFlight(true); - AirBurst.fallBurst(player); - player.setFallDistance(0); - event.setDamage(0D); - event.setCancelled(true); - } - - if (!event.isCancelled() && GeneralMethods.isBender(player.getName(), Element.Water) && event.getCause() == DamageCause.FALL && GeneralMethods.canBendPassive(player.getName(), Element.Water)) { - if (WaterPassive.applyNoFall(player)) { - new Flight(player); - player.setAllowFlight(true); - player.setFallDistance(0); - event.setDamage(0D); - event.setCancelled(true); - } - } - - if (!event.isCancelled() - && GeneralMethods.isBender(player.getName(), Element.Earth) - && event.getCause() == DamageCause.FALL - && GeneralMethods.canBendPassive(player.getName(), Element.Earth)) { - if (EarthPassive.softenLanding(player)) { - new Flight(player); - player.setAllowFlight(true); - player.setFallDistance(0); - event.setDamage(0D); - event.setCancelled(true); - } - } - - if (!event.isCancelled() - && GeneralMethods.isBender(player.getName(), Element.Chi) - && event.getCause() == DamageCause.FALL - && GeneralMethods.canBendPassive(player.getName(), Element.Chi)) { - if (player.isSprinting()) { - event.setDamage(0); - event.setCancelled(true); - } else { - double initdamage = event.getDamage(); - double newdamage = event.getDamage() * ChiPassive.FallReductionFactor; - double finaldamage = initdamage - newdamage; - event.setDamage(finaldamage); - } - } - - if (!event.isCancelled() && event.getCause() == DamageCause.FALL) { - Player source = Flight.getLaunchedBy(player); - if (source != null) { - event.setCancelled(true); - GeneralMethods.damageEntity(source, player, event.getDamage()); - } - } - - if (GeneralMethods.canBendPassive(player.getName(), Element.Fire) - && GeneralMethods.isBender(player.getName(), Element.Fire) - && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) { - event.setCancelled(!Extinguish.canBurn(player)); - } - - if (GeneralMethods.isBender(player.getName(), Element.Earth) - && event.getCause() == DamageCause.SUFFOCATION && TempBlock.isTempBlock(player.getEyeLocation().getBlock())) { - event.setDamage(0D); - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockPhysics(BlockPhysicsEvent event) { - if (event.isCancelled()) return; - - Block block = event.getBlock(); - event.setCancelled(!WaterManipulation.canPhysicsChange(block)); - event.setCancelled(!EarthPassive.canPhysicsChange(block)); - if (!event.isCancelled()) - event.setCancelled(Illumination.blocks.containsKey(block)); - if (!event.isCancelled()) - event.setCancelled(EarthMethods.tempnophysics.contains(block)); - } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockForm(BlockFormEvent event) { - if (event.isCancelled()) return; - - if (TempBlock.isTempBlock(event.getBlock())) - event.setCancelled(true); - if (!WaterManipulation.canPhysicsChange(event.getBlock())) - event.setCancelled(true); - if (!EarthPassive.canPhysicsChange(event.getBlock())) - event.setCancelled(true); - } - - - -} +package com.projectkorra.ProjectKorra; + +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; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageByBlockEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityInteractEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.EntityTeleportEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.entity.SlimeSplitEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerAnimationEvent; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerMoveEvent; +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.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import com.projectkorra.ProjectKorra.ComboManager.ClickType; +import com.projectkorra.ProjectKorra.Ability.AvatarState; +import com.projectkorra.ProjectKorra.CustomEvents.PlayerGrappleEvent; +import com.projectkorra.ProjectKorra.Objects.Preset; +import com.projectkorra.ProjectKorra.Utilities.GrapplingHookAPI; +import com.projectkorra.ProjectKorra.Utilities.HorizontalVelocityChangeEvent; +import com.projectkorra.ProjectKorra.airbending.AirBlast; +import com.projectkorra.ProjectKorra.airbending.AirBubble; +import com.projectkorra.ProjectKorra.airbending.AirBurst; +import com.projectkorra.ProjectKorra.airbending.AirMethods; +import com.projectkorra.ProjectKorra.airbending.AirScooter; +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.FlightAbility; +import com.projectkorra.ProjectKorra.airbending.Suffocate; +import com.projectkorra.ProjectKorra.airbending.Tornado; +import com.projectkorra.ProjectKorra.chiblocking.AcrobatStance; +import com.projectkorra.ProjectKorra.chiblocking.ChiComboManager; +import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; +import com.projectkorra.ProjectKorra.chiblocking.ChiPassive; +import com.projectkorra.ProjectKorra.chiblocking.HighJump; +import com.projectkorra.ProjectKorra.chiblocking.Paralyze; +import com.projectkorra.ProjectKorra.chiblocking.QuickStrike; +import com.projectkorra.ProjectKorra.chiblocking.RapidPunch; +import com.projectkorra.ProjectKorra.chiblocking.Smokescreen; +import com.projectkorra.ProjectKorra.chiblocking.SwiftKick; +import com.projectkorra.ProjectKorra.chiblocking.WarriorStance; +import com.projectkorra.ProjectKorra.earthbending.Catapult; +import com.projectkorra.ProjectKorra.earthbending.Collapse; +import com.projectkorra.ProjectKorra.earthbending.CompactColumn; +import com.projectkorra.ProjectKorra.earthbending.EarthArmor; +import com.projectkorra.ProjectKorra.earthbending.EarthBlast; +import com.projectkorra.ProjectKorra.earthbending.EarthColumn; +import com.projectkorra.ProjectKorra.earthbending.EarthGrab; +import com.projectkorra.ProjectKorra.earthbending.EarthMethods; +import com.projectkorra.ProjectKorra.earthbending.EarthPassive; +import com.projectkorra.ProjectKorra.earthbending.EarthSmash; +import com.projectkorra.ProjectKorra.earthbending.EarthTunnel; +import com.projectkorra.ProjectKorra.earthbending.EarthWall; +import com.projectkorra.ProjectKorra.earthbending.Extraction; +import com.projectkorra.ProjectKorra.earthbending.LavaFlow; +import com.projectkorra.ProjectKorra.earthbending.LavaFlow.AbilityType; +import com.projectkorra.ProjectKorra.earthbending.LavaSurge; +import com.projectkorra.ProjectKorra.earthbending.LavaWave; +import com.projectkorra.ProjectKorra.earthbending.MetalClips; +import com.projectkorra.ProjectKorra.earthbending.Shockwave; +import com.projectkorra.ProjectKorra.earthbending.Tremorsense; +import com.projectkorra.ProjectKorra.firebending.ArcOfFire; +import com.projectkorra.ProjectKorra.firebending.Combustion; +import com.projectkorra.ProjectKorra.firebending.Enflamed; +import com.projectkorra.ProjectKorra.firebending.Extinguish; +import com.projectkorra.ProjectKorra.firebending.FireBlast; +import com.projectkorra.ProjectKorra.firebending.FireBurst; +import com.projectkorra.ProjectKorra.firebending.FireJet; +import com.projectkorra.ProjectKorra.firebending.FireMethods; +import com.projectkorra.ProjectKorra.firebending.FireShield; +import com.projectkorra.ProjectKorra.firebending.FireStream; +import com.projectkorra.ProjectKorra.firebending.Fireball; +import com.projectkorra.ProjectKorra.firebending.HeatControl; +import com.projectkorra.ProjectKorra.firebending.Illumination; +import com.projectkorra.ProjectKorra.firebending.Lightning; +import com.projectkorra.ProjectKorra.firebending.RingOfFire; +import com.projectkorra.ProjectKorra.firebending.WallOfFire; +import com.projectkorra.ProjectKorra.waterbending.Bloodbending; +import com.projectkorra.ProjectKorra.waterbending.FreezeMelt; +import com.projectkorra.ProjectKorra.waterbending.IceBlast; +import com.projectkorra.ProjectKorra.waterbending.IceSpike2; +import com.projectkorra.ProjectKorra.waterbending.Melt; +import com.projectkorra.ProjectKorra.waterbending.OctopusForm; +import com.projectkorra.ProjectKorra.waterbending.Torrent; +import com.projectkorra.ProjectKorra.waterbending.WaterManipulation; +import com.projectkorra.ProjectKorra.waterbending.WaterMethods; +import com.projectkorra.ProjectKorra.waterbending.WaterPassive; +import com.projectkorra.ProjectKorra.waterbending.WaterSpout; +import com.projectkorra.ProjectKorra.waterbending.WaterWall; +import com.projectkorra.ProjectKorra.waterbending.WaterWave; +import com.projectkorra.ProjectKorra.waterbending.Wave; + +public class PKListener implements Listener { + + ProjectKorra plugin; + + public PKListener(ProjectKorra plugin) { + this.plugin = plugin; + } + + public static HashMap noFallEntities = new HashMap(); // Grappling Hooks + public static HashMap noGrapplePlayers = new HashMap(); // Grappling Hooks + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onEntityDamageByBlock(EntityDamageByBlockEvent event) { + if (event.getCause().equals(DamageCause.BLOCK_EXPLOSION)) { + if (event.getDamager() == null) { + event.setCancelled(true); + } + } + + if (event.getDamager() != null) { + if (LavaWave.isBlockInWave(event.getDamager())) { + event.setCancelled(true); + } + } + + } + + @EventHandler + public void onHorizontalCollision(HorizontalVelocityChangeEvent e) + { + if(!plugin.getConfig().getBoolean("Properties.HorizontalCollisionPhysics.Enabled")) + return; + + if(e.getEntity() instanceof LivingEntity) + { + if(e.getEntity().getEntityId() != e.getInstigator().getEntityId()) + { + double minimumDistance = plugin.getConfig().getDouble("Properties.HorizontalCollisionPhysics.WallDamageMinimumDistance"); + double damage = ((e.getDistanceTraveled() - minimumDistance) < 0 ? 0 : e.getDistanceTraveled() - minimumDistance) / (e.getDifference().length()); + if(damage > 0) + GeneralMethods.damageEntity(e.getInstigator(), e.getEntity(), damage); + } + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerGrapple(PlayerGrappleEvent event) { + if (event.isCancelled()) return; + if (!plugin.getConfig().getBoolean("Properties.CustomItems.GrapplingHook.Enable")) return; + + Player player = event.getPlayer(); + if (!GeneralMethods.isBender(player.getName(), Element.Chi) && (!GeneralMethods.isBender(player.getName(), Element.Earth) || !EarthMethods.canMetalbend(player))) { + event.setCancelled(true); + return; + } + if (GeneralMethods.isBender(player.getName(), Element.Chi) && !player.hasPermission("bending.chi.grapplinghook")) { + event.setCancelled(true); + return; + } + + if (GeneralMethods.isBender(player.getName(), Element.Earth) && !player.hasPermission("bending.earth.grapplinghook")) { + event.setCancelled(true); + return; + } + if (Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player) || Bloodbending.isBloodbended(player) || Suffocate.isBreathbent(player)) { + event.setCancelled(true); + } + + event.getHookItem().setDurability((short) - 10); + if (noGrapplePlayers.containsKey(player.getName())) { + return; + } + + Entity e = event.getPulledEntity(); + Location loc = event.getPullLocation(); + + if (player.equals(e)) { + if (player.getLocation().distance(loc) < 3) { // Too close + GrapplingHookAPI.pullPlayerSlightly(player, loc); + } else { + GrapplingHookAPI.pullEntityToLocation(player, loc); + } + + if (GrapplingHookAPI.addUse(player, event.getHookItem())) { + GrapplingHookAPI.playGrappleSound(player.getLocation()); + } + GrapplingHookAPI.addPlayerCooldown(player, 100); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onProjectileHit(ProjectileHitEvent event) { + Integer id = event.getEntity().getEntityId(); + if (Smokescreen.snowballs.contains(id)) { + Location loc = event.getEntity().getLocation(); + Smokescreen.playEffect(loc); + for (Entity en: GeneralMethods.getEntitiesAroundPoint(loc, Smokescreen.radius)) { + Smokescreen.applyBlindness(en); + } + 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")); + //// } + //// } + // } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void fishEvent(PlayerFishEvent event) { + if (event.isCancelled()) return; + Player player = event.getPlayer(); + if (GrapplingHookAPI.isGrapplingHook(player.getItemInHand())) { + if (event.getState() == PlayerFishEvent.State.IN_GROUND) { + Location loc = event.getHook().getLocation(); + for (Entity ent: event.getHook().getNearbyEntities(1.5, 1, 1.5)) { + if (ent instanceof Item) { + PlayerGrappleEvent e = new PlayerGrappleEvent(player, ent, player.getLocation()); + plugin.getServer().getPluginManager().callEvent(e); + return; + } + } + + PlayerGrappleEvent e = new PlayerGrappleEvent(player, player, loc); + plugin.getServer().getPluginManager().callEvent(e); + } + } + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerInteraction(PlayerInteractEvent event) { + if (event.isCancelled()) return; + Player player = event.getPlayer(); + + if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { + GeneralMethods.cooldowns.put(player.getName(), System.currentTimeMillis()); + ComboManager.addComboAbility(player, ClickType.RIGHTCLICK); + String ability = GeneralMethods.getBoundAbility(player); + if(ability != null && ability.equalsIgnoreCase("EarthSmash")) + new EarthSmash(player, EarthSmash.ClickType.RIGHTCLICK); + } + if (Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player) || Bloodbending.isBloodbended(player) || Suffocate.isBreathbent(player)) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockPlace(BlockPlaceEvent event) { + if (event.isCancelled()) return; + Player player = event.getPlayer(); + GeneralMethods.cooldowns.put(player.getName(), System.currentTimeMillis()); + if (Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player) || Bloodbending.isBloodbended(player) || Suffocate.isBreathbent(player)) { + event.setCancelled(true); + } + } + + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockFlowTo(BlockFromToEvent event) { + if (event.isCancelled()) return; + Block toblock = event.getToBlock(); + Block fromblock = event.getBlock(); + if (EarthMethods.isLava(fromblock)) { + event.setCancelled(!EarthPassive.canFlowFromTo(fromblock, toblock)); + } + if (WaterMethods.isWater(fromblock)) { + event.setCancelled(!AirBubble.canFlowTo(toblock)); + if (!event.isCancelled()) { + event.setCancelled(!WaterManipulation.canFlowFromTo(fromblock, + toblock)); + } + if (!event.isCancelled()) { + if (Illumination.blocks.containsKey(toblock)) + toblock.setType(Material.AIR); + } + } + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent e) { + Player player = e.getPlayer(); + GeneralMethods.createBendingPlayer(e.getPlayer().getUniqueId(), player.getName()); + } + + public static void login(BendingPlayer pl) { + ProjectKorra plugin = ProjectKorra.plugin; + Player player = Bukkit.getPlayer(pl.getUUID()); + + if (player == null) { + return; + } + + if (GeneralMethods.toggedOut.contains(player.getUniqueId())) { + GeneralMethods.getBendingPlayer(player.getName()).isToggled = false; + player.sendMessage(ChatColor.YELLOW + "Reminder, you toggled your bending before signing off. Enable it again with /bending toggle."); + } + + Preset.loadPresets(player); + String append = ""; + boolean chatEnabled = ProjectKorra.plugin.getConfig().getBoolean("Properties.Chat.Enable"); + if ((player.hasPermission("bending.avatar") || GeneralMethods.getBendingPlayer(player.getName()).elements.size() > 1) && chatEnabled) { + append = plugin.getConfig().getString("Properties.Chat.Prefixes.Avatar"); + } else if (GeneralMethods.isBender(player.getName(), Element.Air) && chatEnabled) { + append = plugin.getConfig().getString("Properties.Chat.Prefixes.Air"); + } else if (GeneralMethods.isBender(player.getName(), Element.Water) && chatEnabled) { + append = plugin.getConfig().getString("Properties.Chat.Prefixes.Water"); + } else if (GeneralMethods.isBender(player.getName(), Element.Earth) && chatEnabled) { + append = plugin.getConfig().getString("Properties.Chat.Prefixes.Earth"); + } else if (GeneralMethods.isBender(player.getName(), Element.Fire) && chatEnabled) { + append = plugin.getConfig().getString("Properties.Chat.Prefixes.Fire"); + } else if (GeneralMethods.isBender(player.getName(), Element.Chi) && chatEnabled) { + append = plugin.getConfig().getString("Properties.Chat.Prefixes.Chi"); + } + + if (chatEnabled) { + player.setDisplayName(append + player.getName()); + } + + // Handle the AirSpout/WaterSpout login glitches + if (player.getGameMode() != GameMode.CREATIVE) { + HashMap bound = GeneralMethods.getBendingPlayer(player.getName()).getAbilities(); + for (String str : bound.values()) { + if (str.equalsIgnoreCase("AirSpout") || str.equalsIgnoreCase("WaterSpout")) { + final Player fplayer = player; + new BukkitRunnable() { + public void run() { + fplayer.setFlying(false); + fplayer.setAllowFlight(false); + } + }.runTaskLater(ProjectKorra.plugin, 2); + break; + } + } + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + + Player player = event.getPlayer(); + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + if (bPlayer != null) { + if (GeneralMethods.toggedOut.contains(player.getUniqueId()) && bPlayer.isToggled()) + GeneralMethods.toggedOut.remove(player.getUniqueId()); + if (!bPlayer.isToggled()) + GeneralMethods.toggedOut.add(player.getUniqueId()); + } + + MultiAbilityManager.remove(player); + + if (Commands.invincible.contains(event.getPlayer().getName())) { + Commands.invincible.remove(event.getPlayer().getName()); + } + Preset.unloadPreset(player); + BendingPlayer.players.remove(event.getPlayer().getName()); + if (EarthArmor.instances.containsKey(event.getPlayer())) { + EarthArmor.removeEffect(event.getPlayer()); + event.getPlayer().removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); + } + + for(Player p : MetalClips.instances.keySet()) + { + if(MetalClips.instances.get(p).getTarget() != null && + MetalClips.instances.get(p).getTarget().getEntityId() == event.getPlayer().getEntityId()) + { + MetalClips.instances.get(p).remove(); + } + } + + com.projectkorra.ProjectKorra.airbending.FlightAbility.remove(event.getPlayer()); + } + + @EventHandler + public void playerIsKicked(PlayerKickEvent event) { + if(event.isCancelled()) return; + + com.projectkorra.ProjectKorra.airbending.FlightAbility.remove(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerSneak(PlayerToggleSneakEvent event) { + Player player = event.getPlayer(); + + if (event.isCancelled()) return; + + if(player.isSneaking()) + ComboManager.addComboAbility(player, ComboManager.ClickType.SHIFTUP); + else + ComboManager.addComboAbility(player, ComboManager.ClickType.SHIFTDOWN); + + if(Suffocate.isBreathbent(player)) { + if(!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterManipulation")) { + event.setCancelled(true); + } + } + + if (Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player) || Bloodbending.isBloodbended(player)) { + event.setCancelled(true); + return; + } + + AirScooter.check(player); + + String abil = GeneralMethods.getBoundAbility(player); + if (abil == null) { + return; + } + + if (ChiMethods.isChiBlocked(player.getName())) { + event.setCancelled(true); + return; + } + + if (!player.isSneaking() && GeneralMethods.canBend(player.getName(), abil)) { + if (GeneralMethods.isDisabledStockAbility(abil)) + return; + if (AirMethods.isAirAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) { + return; + } + if (abil.equalsIgnoreCase("Tornado")) { + new Tornado(player); + } + if (abil.equalsIgnoreCase("AirBlast")) { + AirBlast.setOrigin(player); + } + if (abil.equalsIgnoreCase("AirBurst")) { + new AirBurst(player); + } + if (abil.equalsIgnoreCase("AirSuction")) { + AirSuction.setOrigin(player); + } + if (abil.equalsIgnoreCase("AirSwipe")) { + AirSwipe.charge(player); + } + if (abil.equalsIgnoreCase("AirShield")) { + new AirShield(player); + } + if(abil.equalsIgnoreCase("Suffocate")) { + new Suffocate(player); + } + if(abil.equalsIgnoreCase("Flight")) { + if(player.isSneaking() || !AirMethods.canAirFlight(player)) return; + new com.projectkorra.ProjectKorra.airbending.FlightAbility(player); + } + + } + + if (WaterMethods.isWaterAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) { + return; + } + if (abil.equalsIgnoreCase("Bloodbending")) { + new Bloodbending(player); + } + if (abil.equalsIgnoreCase("IceBlast")) { + new IceBlast(player); + } + if (abil.equalsIgnoreCase("IceSpike")) { + new IceSpike2(player); + } + if (abil.equalsIgnoreCase("OctopusForm")) { + OctopusForm.form(player); + } + if (abil.equalsIgnoreCase("PhaseChange")) { + new Melt(player); + } + if (abil.equalsIgnoreCase("WaterManipulation")) { + new WaterManipulation(player); + } + if (abil.equalsIgnoreCase("Surge")) { + WaterWall.form(player); + } + if (abil.equalsIgnoreCase("Torrent")) { + Torrent.create(player); + } + } + + if (EarthMethods.isEarthAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) { + return; + } + if (abil.equalsIgnoreCase("EarthBlast")) { + new EarthBlast(player); + } + if (abil.equalsIgnoreCase("RaiseEarth")) { + new EarthWall(player); + } + if (abil.equalsIgnoreCase("Collapse")) { + new Collapse(player); + } + if (abil.equalsIgnoreCase("Shockwave")) { + new Shockwave(player); + } + if (abil.equalsIgnoreCase("EarthGrab")) { + EarthGrab.EarthGrabSelf(player); + } + if (abil.equalsIgnoreCase("EarthTunnel")) { + new EarthTunnel(player); + } + + if (abil.equalsIgnoreCase("Tremorsense")) { + GeneralMethods.getBendingPlayer(player.getName()).toggleTremorsense(); + } + + if (abil.equalsIgnoreCase("Extraction")) { + new Extraction(player); + } + + if(abil.equalsIgnoreCase("MetalClips")) + { + if(MetalClips.instances.containsKey(player)) + { + if(MetalClips.instances.get(player).getTarget() == null) + MetalClips.instances.get(player).magnet(); + else + MetalClips.instances.get(player).control(); + } + else + new MetalClips(player, 1); + } + +// if (abil.equalsIgnoreCase("LavaSurge")) { +// new LavaSurge(player); +// } + + if (abil.equalsIgnoreCase("LavaFlow")) { + new LavaFlow(player,LavaFlow.AbilityType.SHIFT); + } + if (abil.equalsIgnoreCase("EarthSmash")) { + new EarthSmash(player, EarthSmash.ClickType.SHIFT); + } + + } + + if (FireMethods.isFireAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) { + return; + } + if (abil.equalsIgnoreCase("Blaze")) { + new RingOfFire(player); + } + if (abil.equalsIgnoreCase("FireBlast")) { + new Fireball(player); + } + if (abil.equalsIgnoreCase("HeatControl")) { + new HeatControl(player); + } + if (abil.equalsIgnoreCase("FireBurst")) { + new FireBurst(player); + } + if (abil.equalsIgnoreCase("FireShield")) { + FireShield.shield(player); + } + if (abil.equalsIgnoreCase("Lightning")) { + new Lightning(player); + } + if (abil.equalsIgnoreCase("Combustion")) { + new Combustion(player); + } + } + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockIgnite(BlockIgniteEvent event) { + if (event.isCancelled()) return; + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerMove(PlayerMoveEvent event) { + if (event.isCancelled()) return; + + Player player = event.getPlayer(); + if (Paralyze.isParalyzed(player)) { + event.setCancelled(true); + return; + } + + if(ChiComboManager.isParalyzed(player)) + { + event.setTo(event.getFrom()); + return; + } + + if (Suffocate.isBreathbent(player)) { + Location loc = event.getFrom(); + Location toLoc = player.getLocation(); + + if (loc.getX() != toLoc.getX() || loc.getY() != toLoc.getY() || loc.getZ() != toLoc.getZ()) { + event.setCancelled(true); + return; + } + } + + if (WaterSpout.instances.containsKey(event.getPlayer()) || AirSpout.getPlayers().contains(event.getPlayer())) { + Vector vel = new Vector(); + vel.setX(event.getTo().getX() - event.getFrom().getX()); + vel.setY(event.getTo().getY() - event.getFrom().getY()); + vel.setZ(event.getTo().getZ() - event.getFrom().getZ()); + // You now know the old velocity. Set to match recommended velocity + double currspeed = vel.length(); + double maxspeed = .15; + if (currspeed > maxspeed) { + // only if moving set a factor + // double recspeed = 0.6; + // vel = vel.ultiply(recspeed * currspeed); + vel = vel.normalize().multiply(maxspeed); + // apply the new velocity (MAY REQUIRE A SCHEDULED TASK + // INSTEAD!) + event.getPlayer().setVelocity(vel); + } + } + + if (Bloodbending.isBloodbended(player)) { + double distance1, distance2; + Location loc = Bloodbending.getBloodbendingLocation(player); + distance1 = event.getFrom().distance(loc); + distance2 = event.getTo().distance(loc); + if (distance2 > distance1) { + player.setVelocity(new Vector(0, 0, 0)); + } + } + + if(FlightAbility.instances.containsKey(event.getPlayer().getName())) { + if(com.projectkorra.ProjectKorra.airbending.FlightAbility.isHovering(event.getPlayer())) { + Location loc = event.getFrom(); + Location toLoc = player.getLocation(); + + if (loc.getX() != toLoc.getX() || loc.getY() != toLoc.getY() || loc.getZ() != toLoc.getZ()) { + event.setCancelled(true); + return; + } + } + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityTargetLiving(EntityTargetLivingEntityEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity)) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onTarget(EntityTargetEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity)) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) + event.setCancelled(true); + + if (event.getEntityType() == EntityType.FALLING_BLOCK) { + if (LavaSurge.falling.contains(entity)) { + LavaSurge.falling.remove(entity); + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onEntityExplode(EntityExplodeEvent event) { + if (event.isCancelled()) return; + + for (Block block : event.blockList()) { + EarthBlast blast = EarthBlast.getBlastFromSource(block); + + if (blast != null) { + blast.cancel(); + } + if (FreezeMelt.frozenblocks.containsKey(block)) { + FreezeMelt.thaw(block); + } + if (WaterWall.wallblocks.containsKey(block)) { + block.setType(Material.AIR); + } + if (!Wave.canThaw(block)) { + Wave.thaw(block); + } + if (EarthMethods.movedearth.containsKey(block)) { + EarthMethods.removeRevertIndex(block); + } + } + + + + } + + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityExplodeEvent(EntityExplodeEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (entity != null) + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) + || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityInteractEvent(EntityInteractEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityShootBowEvent(EntityShootBowEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityTeleportEvent(EntityTeleportEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityProjectileLaunchEvent(ProjectileLaunchEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntitySlimeSplitEvent(SlimeSplitEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + if (Paralyze.isParalyzed(entity) || ChiComboManager.isParalyzed(entity) || Bloodbending.isBloodbended(entity) || Suffocate.isBreathbent(entity)) + event.setCancelled(true); + } + + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerSwing(PlayerAnimationEvent event) { + if (event.isCancelled()) return; + + Player player = event.getPlayer(); + ComboManager.addComboAbility(player, ComboManager.ClickType.LEFTCLICK); + + if(Suffocate.isBreathbent(player)) { + if(!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterManipulation")) { + event.setCancelled(true); + } + } + + if (Bloodbending.isBloodbended(player) || Paralyze.isParalyzed(player) || ChiComboManager.isParalyzed(player)) { + event.setCancelled(true); + return; + } + + if (ChiMethods.isChiBlocked(player.getName())) { + event.setCancelled(true); + return; + } + + AirScooter.check(player); + + String abil = GeneralMethods.getBoundAbility(player); + if (abil == null) return; + if (GeneralMethods.canBend(player.getName(), abil)) { + if (GeneralMethods.isDisabledStockAbility(abil)) + return; + + if (AirMethods.isAirAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) { + return; + } + if (abil.equalsIgnoreCase("AirBlast")) { + new AirBlast(player); + } + if (abil.equalsIgnoreCase("AirSuction")) { + new AirSuction(player); + } + if (abil.equalsIgnoreCase("AirBurst")) { + AirBurst.coneBurst(player); + } + if (abil.equalsIgnoreCase("AirScooter")) { + new AirScooter(player); + } + if (abil.equalsIgnoreCase("AirSpout")) { + new AirSpout(player); + } + if (abil.equalsIgnoreCase("AirSwipe")) { + new AirSwipe(player); + } + if(abil.equalsIgnoreCase("Flight")) { + if(!ProjectKorra.plugin.getConfig().getBoolean("Abilities.Air.Flight.HoverEnabled") + || !AirMethods.canAirFlight(player)) return; + + if(com.projectkorra.ProjectKorra.airbending.FlightAbility.instances.containsKey(event.getPlayer().getName())) { + if(com.projectkorra.ProjectKorra.airbending.FlightAbility.isHovering(event.getPlayer())) { + com.projectkorra.ProjectKorra.airbending.FlightAbility.setHovering(event.getPlayer(), false); + }else{ + com.projectkorra.ProjectKorra.airbending.FlightAbility.setHovering(event.getPlayer(), true); + } + } + } + } + if (WaterMethods.isWaterAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) { + return; + } + if (abil.equalsIgnoreCase("Bloodbending")) { + Bloodbending.launch(player); + } + if (abil.equalsIgnoreCase("IceBlast")) { + IceBlast.activate(player); + } + if (abil.equalsIgnoreCase("IceSpike")) { + IceSpike2.activate(player); + } + if (abil.equalsIgnoreCase("OctopusForm")) { + new OctopusForm(player); + } + if (abil.equalsIgnoreCase("PhaseChange")) { + new FreezeMelt(player); + } + if (abil.equalsIgnoreCase("WaterSpout")) { + new WaterSpout(player); + } + if (abil.equalsIgnoreCase("WaterManipulation")) { + WaterManipulation.moveWater(player); + } + if (abil.equalsIgnoreCase("Surge")) { + new WaterWall(player); + } + if (abil.equalsIgnoreCase("Torrent")) { + new Torrent(player); + } + } + + if (EarthMethods.isEarthAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) { + return; + } + if (abil.equalsIgnoreCase("Catapult")) { + new Catapult(player); + } + + if (abil.equalsIgnoreCase("EarthBlast")) { + EarthBlast.throwEarth(player); + } + + if (abil.equalsIgnoreCase("RaiseEarth")) { + new EarthColumn(player); + } + + if (abil.equalsIgnoreCase("Collapse")) { + new CompactColumn(player); + } + if (abil.equalsIgnoreCase("Shockwave")) { + Shockwave.coneShockwave(player); + } + if (abil.equalsIgnoreCase("EarthArmor")) { + new EarthArmor(player); + } + + if (abil.equalsIgnoreCase("EarthGrab")) { + new EarthGrab(player); + } + + if (abil.equalsIgnoreCase("Tremorsense")) { + new Tremorsense(player); + } + + if(abil.equalsIgnoreCase("MetalClips")) + { + if(!MetalClips.instances.containsKey(player)) + new MetalClips(player, 0); + else if(MetalClips.instances.containsKey(player)) + if(MetalClips.instances.get(player).metalclips < (player.hasPermission("bending.ability.MetalClips.4clips") ? 4 : 3)) + MetalClips.instances.get(player).shootMetal(); + else + MetalClips.instances.get(player).launch(); + } + + if (abil.equalsIgnoreCase("LavaSurge")) { + if(LavaSurge.instances.containsKey(player)) + LavaSurge.instances.get(player).launch(); + } + + if (abil.equalsIgnoreCase("LavaFlow")) { + new LavaFlow(player,AbilityType.CLICK); + } + + if (abil.equalsIgnoreCase("EarthSmash")) { + new EarthSmash(player, EarthSmash.ClickType.LEFTCLICK); + } + } + if (FireMethods.isFireAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) { + return; + } + + if (abil.equalsIgnoreCase("Blaze")) { + new ArcOfFire(player); + } + if (abil.equalsIgnoreCase("FireBlast")) { + new FireBlast(player); + } + if (abil.equalsIgnoreCase("FireJet")) { + new FireJet(player); + } + if (abil.equalsIgnoreCase("HeatControl")) { + new Extinguish(player); + } + if (abil.equalsIgnoreCase("Illumination")) { + new Illumination(player); + } + if (abil.equalsIgnoreCase("FireBurst")) { + FireBurst.coneBurst(player); + } + if (abil.equalsIgnoreCase("FireShield")) { + new FireShield(player); + } + if (abil.equalsIgnoreCase("WallOfFire")) { + new WallOfFire(player); + } + if (abil.equalsIgnoreCase("Combustion")) { + Combustion.explode(player); + } + } + + if (ChiMethods.isChiAbility(abil)) { + if (GeneralMethods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { + return; + } + if (abil.equalsIgnoreCase("HighJump")) { + new HighJump(player); + } + if (abil.equalsIgnoreCase("RapidPunch")) { + new RapidPunch(player); + } + if (abil.equalsIgnoreCase("Paralyze")) { + // + } + if (abil.equalsIgnoreCase("Smokescreen")) { + new Smokescreen(player); + } + if (abil.equalsIgnoreCase("WarriorStance")) { + new WarriorStance(player); + } + + if (abil.equalsIgnoreCase("AcrobatStance")) { + new AcrobatStance(player); + } + + if (abil.equalsIgnoreCase("QuickStrike")) + { + new QuickStrike(player); + } + + if (abil.equalsIgnoreCase("SwiftKick")) + { + new SwiftKick(player); + } + } + + if (abil.equalsIgnoreCase("AvatarState")) { + new AvatarState(player); + } + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onInventoryClick(InventoryClickEvent event) { + if (event.isCancelled()) return; + + for(Player p : MetalClips.instances.keySet()) + { + if(MetalClips.instances.get(p).getTarget() != null) + if(MetalClips.instances.get(p).getTarget().getEntityId() == event.getWhoClicked().getEntityId()) + event.setCancelled(true); + } + + if (event.getSlotType() == SlotType.ARMOR + && !EarthArmor.canRemoveArmor((Player) event.getWhoClicked())) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerDeath(PlayerDeathEvent event) { + if (EarthArmor.instances.containsKey(event.getEntity())) { + List drops = event.getDrops(); + List newdrops = new ArrayList(); + for (int i = 0; i < drops.size(); i++) { + if (!(drops.get(i).getType() == Material.LEATHER_BOOTS + || drops.get(i).getType() == Material.LEATHER_CHESTPLATE + || drops.get(i).getType() == Material.LEATHER_HELMET + || drops.get(i).getType() == Material.LEATHER_LEGGINGS || drops + .get(i).getType() == Material.AIR)) + newdrops.add((drops.get(i))); + } + if (EarthArmor.instances.get(event.getEntity()).oldarmor != null) { + for (ItemStack is : EarthArmor.instances.get(event.getEntity()).oldarmor) { + if (!(is.getType() == Material.AIR)) + newdrops.add(is); + } + } + event.getDrops().clear(); + event.getDrops().addAll(newdrops); + EarthArmor.removeEffect(event.getEntity()); + } + if (MetalClips.instances.containsKey(event.getEntity())) { + MetalClips.instances.get(event.getEntity()).remove(); + List drops = event.getDrops(); + List newdrops = new ArrayList(); + for (int i = 0; i < drops.size(); i++) { + if (!(drops.get(i).getType() == Material.IRON_HELMET + || drops.get(i).getType() == Material.IRON_CHESTPLATE + || drops.get(i).getType() == Material.IRON_LEGGINGS + || drops.get(i).getType() == Material.IRON_BOOTS + || drops.get(i).getType() == Material.AIR)) + newdrops.add((drops.get(i))); + } + event.getDrops().clear(); + event.getDrops().addAll(newdrops); + + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { + if (event.isCancelled()) return; + + Player p = event.getPlayer(); + if (Tornado.getPlayers().contains(p) || Bloodbending.isBloodbended(p) || Suffocate.isBreathbent(p) + || FireJet.getPlayers().contains(p) + || AvatarState.getPlayers().contains(p)) { + event.setCancelled(p.getGameMode() != GameMode.CREATIVE); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityCombust(EntityCombustEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + Block block = entity.getLocation().getBlock(); + if (FireStream.ignitedblocks.containsKey(block) && entity instanceof LivingEntity) { + new Enflamed(entity, FireStream.ignitedblocks.get(block)); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityDamageBlock(EntityDamageByBlockEvent event) { + + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityDamageEvent(EntityDamageEvent event) { + if (event.isCancelled()) return; + + Entity entity = event.getEntity(); + + 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); + } + + if (entity instanceof Player) { + Player player = (Player) entity; + if (GeneralMethods.getBoundAbility(player) != null && GeneralMethods.getBoundAbility(player).equalsIgnoreCase("HeatControl")) { + if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK) { + player.setFireTicks(0); + event.setCancelled(true); + } + } + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockMeltEvent(BlockFadeEvent event) { + if (event.isCancelled()) return; + + Block block = event.getBlock(); + if (block.getType() == Material.FIRE) { + return; + } + event.setCancelled(Illumination.blocks.containsKey(block)); + if (!event.isCancelled()) { + event.setCancelled(!WaterManipulation.canPhysicsChange(block)); + } + if (!event.isCancelled()) { + event.setCancelled(!EarthPassive.canPhysicsChange(block)); + } + if (!event.isCancelled()) { + event.setCancelled(FreezeMelt.frozenblocks.containsKey(block)); + } + if (!event.isCancelled()) { + event.setCancelled(!Wave.canThaw(block)); + } + if (!event.isCancelled()) { + event.setCancelled(!Torrent.canThaw(block)); + } + if (FireStream.ignitedblocks.containsKey(block)) { + FireStream.remove(block); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockBreak(BlockBreakEvent event) { + if (event.isCancelled()) return; + + Block block = event.getBlock(); + Player player = event.getPlayer(); + if (WaterWall.wasBrokenFor(player, block) + || OctopusForm.wasBrokenFor(player, block) + || Torrent.wasBrokenFor(player, block) + || WaterWave.wasBrokenFor(player, block)){ + event.setCancelled(true); + return; + } + EarthBlast blast = EarthBlast.getBlastFromSource(block); + if (blast != null) { + blast.cancel(); + } + + if (FreezeMelt.frozenblocks.containsKey(block)) { + FreezeMelt.thaw(block); + event.setCancelled(true); + // } else if (!WalkOnWater.canThaw(block)) { + // WalkOnWater.thaw(block); + } else if (WaterWall.wallblocks.containsKey(block)) { + WaterWall.thaw(block); + event.setCancelled(true); + } else if (Illumination.blocks.containsKey(block)) { + event.setCancelled(true); + // } else if (Illumination.blocks.containsKey(block + // .getRelative(BlockFace.UP))) { + // event.setCancelled(true); + } else if (!Wave.canThaw(block)) { + Wave.thaw(block); + event.setCancelled(true); + // event.setCancelled(true); + } else if (EarthMethods.movedearth.containsKey(block)) { + // Methods.removeEarthbendedBlockIndex(block); + EarthMethods.removeRevertIndex(block); + } else if (TempBlock.isTempBlock(block)) { + TempBlock.revertBlock(block, Material.AIR); + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerChat(AsyncPlayerChatEvent event) { + if (event.isCancelled()) return; + + if (!plugin.getConfig().getBoolean("Properties.Chat.Enable")) { + return; + } + + Player player = event.getPlayer(); + ChatColor color = ChatColor.WHITE; + + if (player.hasPermission("bending.avatar") || GeneralMethods.getBendingPlayer(player.getName()).elements.size() > 1) { + color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Avatar")); + } else if (GeneralMethods.isBender(player.getName(), Element.Air)) { + color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Air")); + } else if (GeneralMethods.isBender(player.getName(), Element.Water)) { + color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Water")); + } else if (GeneralMethods.isBender(player.getName(), Element.Earth)) { + color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Earth")); + } else if (GeneralMethods.isBender(player.getName(), Element.Fire)) { + color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Fire")); + } else if (GeneralMethods.isBender(player.getName(), Element.Chi)) { + color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Chi")); + } + + String format = plugin.getConfig().getString("Properties.Chat.Format"); + format = format.replace("", "%2$s"); + format = format.replace("", color + player.getDisplayName() + ChatColor.RESET); + event.setFormat(format); + + } + + @EventHandler + public void onEntitySuffocatedByTempBlocks(EntityDamageEvent event) { + if(event.isCancelled()) return; + + if(event.getCause() == DamageCause.SUFFOCATION) { + if(TempBlock.isTempBlock(event.getEntity().getLocation().add(0, 1, 0).getBlock())) { + event.setCancelled(true); + } + } + } + + @EventHandler + public void onPlayerDamageByPlayer(EntityDamageByEntityEvent e) { + if (e.isCancelled()) return; + + Entity source = e.getDamager(); + Entity entity = e.getEntity(); + Fireball fireball = Fireball.getFireball(source); + + if (fireball != null) { + e.setCancelled(true); + fireball.dealDamage(entity); + return; + } + + // if (Combustion.fireballs.contains(source.getEntityId())) { + // e.setCancelled(true); + // } + + if (Paralyze.isParalyzed(e.getDamager()) + || ChiComboManager.isParalyzed(e.getDamager())) { + e.setCancelled(true); + return; + } + + if(entity instanceof Player) { + Suffocate.remove((Player) entity); + } + + Entity en = e.getEntity(); + if (en instanceof Player) { + // Player p = (Player) en; // This is the player getting hurt. + if (e.getDamager() instanceof Player) { // This is the player hitting someone. + Player sourceplayer = (Player) e.getDamager(); + Player targetplayer = (Player) e.getEntity(); + if (GeneralMethods.canBendPassive(sourceplayer.getName(), Element.Chi)) { + if (GeneralMethods.isBender(sourceplayer.getName(), Element.Chi) && e.getCause() == DamageCause.ENTITY_ATTACK && e.getDamage() == 1) { + if (GeneralMethods.isWeapon(sourceplayer.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { + return; + } + if (ChiPassive.willChiBlock(sourceplayer, targetplayer)) { + if (GeneralMethods.getBoundAbility(sourceplayer) != null && GeneralMethods.getBoundAbility(sourceplayer).equalsIgnoreCase("Paralyze")) { + new Paralyze(sourceplayer, targetplayer); + } else { + 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 (GeneralMethods.canBendPassive(sourceplayer.getName(), Element.Chi)) { + if (GeneralMethods.isWeapon(sourceplayer.getItemInHand().getType()) && !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) { + return; + } + if (e.getCause() == DamageCause.ENTITY_ATTACK) { + if (GeneralMethods.getBoundAbility(sourceplayer) != null && GeneralMethods.getBoundAbility(sourceplayer).equalsIgnoreCase("Paralyze") && e.getDamage() == 1) { + if (ChiPassive.willChiBlock(sourceplayer, targetplayer)) { + new Paralyze(sourceplayer, targetplayer); + } + } + } + } + } + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerDamage(EntityDamageEvent event) { + if (event.isCancelled()) return; + + if (event.getEntity() instanceof Player) { + Player player = (Player) event.getEntity(); + + if (GeneralMethods.isBender(player.getName(), Element.Earth) && event.getCause() == DamageCause.FALL) { + Shockwave.fallShockwave(player); + } + + if (GeneralMethods.isBender(player.getName(), Element.Air) && event.getCause() == DamageCause.FALL && GeneralMethods.canBendPassive(player.getName(), Element.Air)) { + new Flight(player); + player.setAllowFlight(true); + AirBurst.fallBurst(player); + player.setFallDistance(0); + event.setDamage(0D); + event.setCancelled(true); + } + + if (!event.isCancelled() && GeneralMethods.isBender(player.getName(), Element.Water) && event.getCause() == DamageCause.FALL && GeneralMethods.canBendPassive(player.getName(), Element.Water)) { + if (WaterPassive.applyNoFall(player)) { + new Flight(player); + player.setAllowFlight(true); + player.setFallDistance(0); + event.setDamage(0D); + event.setCancelled(true); + } + } + + if (!event.isCancelled() + && GeneralMethods.isBender(player.getName(), Element.Earth) + && event.getCause() == DamageCause.FALL + && GeneralMethods.canBendPassive(player.getName(), Element.Earth)) { + if (EarthPassive.softenLanding(player)) { + new Flight(player); + player.setAllowFlight(true); + player.setFallDistance(0); + event.setDamage(0D); + event.setCancelled(true); + } + } + + if (!event.isCancelled() + && GeneralMethods.isBender(player.getName(), Element.Chi) + && event.getCause() == DamageCause.FALL + && GeneralMethods.canBendPassive(player.getName(), Element.Chi)) { + if (player.isSprinting()) { + event.setDamage(0); + event.setCancelled(true); + } else { + double initdamage = event.getDamage(); + double newdamage = event.getDamage() * ChiPassive.FallReductionFactor; + double finaldamage = initdamage - newdamage; + event.setDamage(finaldamage); + } + } + + if (!event.isCancelled() && event.getCause() == DamageCause.FALL) { + Player source = Flight.getLaunchedBy(player); + if (source != null) { + event.setCancelled(true); + GeneralMethods.damageEntity(source, player, event.getDamage()); + } + } + + if (GeneralMethods.canBendPassive(player.getName(), Element.Fire) + && GeneralMethods.isBender(player.getName(), Element.Fire) + && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) { + event.setCancelled(!Extinguish.canBurn(player)); + } + + if (GeneralMethods.isBender(player.getName(), Element.Earth) + && event.getCause() == DamageCause.SUFFOCATION && TempBlock.isTempBlock(player.getEyeLocation().getBlock())) { + event.setDamage(0D); + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockPhysics(BlockPhysicsEvent event) { + if (event.isCancelled()) return; + + Block block = event.getBlock(); + event.setCancelled(!WaterManipulation.canPhysicsChange(block)); + event.setCancelled(!EarthPassive.canPhysicsChange(block)); + if (!event.isCancelled()) + event.setCancelled(Illumination.blocks.containsKey(block)); + if (!event.isCancelled()) + event.setCancelled(EarthMethods.tempnophysics.contains(block)); + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockForm(BlockFormEvent event) { + if (event.isCancelled()) return; + + if (TempBlock.isTempBlock(event.getBlock())) + event.setCancelled(true); + if (!WaterManipulation.canPhysicsChange(event.getBlock())) + event.setCancelled(true); + if (!EarthPassive.canPhysicsChange(event.getBlock())) + event.setCancelled(true); + } + + + +} From 1719628d3364e09cf02a7575d0522ffb3e15c6a9 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 30 May 2015 03:08:11 +0100 Subject: [PATCH 03/25] Added the managers for the MultiAbility --- .../ProjectKorra/ProjectKorra.java | 180 +++++++++--------- 1 file changed, 92 insertions(+), 88 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/ProjectKorra.java b/src/com/projectkorra/ProjectKorra/ProjectKorra.java index c557a3d4..b601fd6b 100644 --- a/src/com/projectkorra/ProjectKorra/ProjectKorra.java +++ b/src/com/projectkorra/ProjectKorra/ProjectKorra.java @@ -1,88 +1,92 @@ -package com.projectkorra.ProjectKorra; - -import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; -import com.projectkorra.ProjectKorra.Ability.Combo.ComboModuleManager; -import com.projectkorra.ProjectKorra.Objects.Preset; -import com.projectkorra.ProjectKorra.Utilities.CraftingRecipes; -import com.projectkorra.ProjectKorra.airbending.AirbendingManager; -import com.projectkorra.ProjectKorra.chiblocking.ChiComboManager; -import com.projectkorra.ProjectKorra.chiblocking.ChiblockingManager; -import com.projectkorra.ProjectKorra.earthbending.EarthbendingManager; -import com.projectkorra.ProjectKorra.firebending.FirebendingManager; -import com.projectkorra.ProjectKorra.waterbending.WaterbendingManager; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.IOException; -import java.util.logging.Logger; - -public class ProjectKorra extends JavaPlugin { - - public static long time_step = 1; - public static ProjectKorra plugin; - public static Logger log; - - @Override - public void onEnable() { - ProjectKorra.log = this.getLogger(); - plugin = this; - new ConfigManager(this); - - new GeneralMethods(this); - new Commands(this); - new AbilityModuleManager(this); - new ComboModuleManager(); - new ComboManager(); - new ChiComboManager(); - - ConfigManager.configCheck(); - - DBConnection.host = getConfig().getString("Storage.MySQL.host"); - DBConnection.port = getConfig().getInt("Storage.MySQL.port"); - DBConnection.pass = getConfig().getString("Storage.MySQL.pass"); - DBConnection.db = getConfig().getString("Storage.MySQL.db"); - DBConnection.user = getConfig().getString("Storage.MySQL.user"); - - getServer().getScheduler().scheduleSyncRepeatingTask(this, new BendingManager(this), 0, 1); - getServer().getScheduler().scheduleSyncRepeatingTask(this, new AirbendingManager(this), 0, 1); - getServer().getScheduler().scheduleSyncRepeatingTask(this, new WaterbendingManager(this), 0, 1); - getServer().getScheduler().scheduleSyncRepeatingTask(this, new EarthbendingManager(this), 0, 1); - getServer().getScheduler().scheduleSyncRepeatingTask(this, new FirebendingManager(this), 0, 1); - getServer().getScheduler().scheduleSyncRepeatingTask(this, new ChiblockingManager(this), 0, 1); - - DBConnection.init(); - if (DBConnection.isOpen() == false) return; - - for (Player player: Bukkit.getOnlinePlayers()) { - GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); - Preset.loadPresets(player); - } - getServer().getPluginManager().registerEvents(new PKListener(this), this); - - - getServer().getScheduler().runTaskTimerAsynchronously(this, new RevertChecker(this), 0, 200); - - try { - MetricsLite metrics = new MetricsLite(this); - metrics.start(); - } catch (IOException e) { - e.printStackTrace(); - } - - GeneralMethods.deserializeFile(); - GeneralMethods.startCacheCleaner(GeneralMethods.CACHE_TIME); - new CraftingRecipes(this); - } - - @Override - public void onDisable() { - GeneralMethods.stopBending(); - if (DBConnection.isOpen == false) return; - DBConnection.sql.close(); - } - - public void stopPlugin() { - getServer().getPluginManager().disablePlugin(plugin); - } -} +package com.projectkorra.ProjectKorra; + +import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; +import com.projectkorra.ProjectKorra.Ability.Combo.ComboModuleManager; +import com.projectkorra.ProjectKorra.Ability.MultiAbility.MultiAbilityModuleManager; +import com.projectkorra.ProjectKorra.Objects.Preset; +import com.projectkorra.ProjectKorra.Utilities.CraftingRecipes; +import com.projectkorra.ProjectKorra.airbending.AirbendingManager; +import com.projectkorra.ProjectKorra.chiblocking.ChiComboManager; +import com.projectkorra.ProjectKorra.chiblocking.ChiblockingManager; +import com.projectkorra.ProjectKorra.earthbending.EarthbendingManager; +import com.projectkorra.ProjectKorra.firebending.FirebendingManager; +import com.projectkorra.ProjectKorra.waterbending.WaterbendingManager; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.IOException; +import java.util.logging.Logger; + +public class ProjectKorra extends JavaPlugin { + + public static long time_step = 1; + public static ProjectKorra plugin; + public static Logger log; + + @Override + public void onEnable() { + ProjectKorra.log = this.getLogger(); + plugin = this; + new ConfigManager(this); + + new GeneralMethods(this); + new Commands(this); + new AbilityModuleManager(this); + new MultiAbilityModuleManager(); + new MultiAbilityManager(); + new ComboModuleManager(); + new ComboManager(); + new ChiComboManager(); + + ConfigManager.configCheck(); + + DBConnection.host = getConfig().getString("Storage.MySQL.host"); + DBConnection.port = getConfig().getInt("Storage.MySQL.port"); + DBConnection.pass = getConfig().getString("Storage.MySQL.pass"); + DBConnection.db = getConfig().getString("Storage.MySQL.db"); + DBConnection.user = getConfig().getString("Storage.MySQL.user"); + + getServer().getScheduler().scheduleSyncRepeatingTask(this, new BendingManager(this), 0, 1); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new AirbendingManager(this), 0, 1); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new WaterbendingManager(this), 0, 1); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new EarthbendingManager(this), 0, 1); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new FirebendingManager(this), 0, 1); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new ChiblockingManager(this), 0, 1); + + DBConnection.init(); + if (DBConnection.isOpen() == false) return; + + for (Player player: Bukkit.getOnlinePlayers()) { + GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); + Preset.loadPresets(player); + } + getServer().getPluginManager().registerEvents(new PKListener(this), this); + + + getServer().getScheduler().runTaskTimerAsynchronously(this, new RevertChecker(this), 0, 200); + + try { + MetricsLite metrics = new MetricsLite(this); + metrics.start(); + } catch (IOException e) { + e.printStackTrace(); + } + + GeneralMethods.deserializeFile(); + GeneralMethods.startCacheCleaner(GeneralMethods.CACHE_TIME); + new CraftingRecipes(this); + } + + @Override + public void onDisable() { + GeneralMethods.stopBending(); + if (DBConnection.isOpen == false) return; + DBConnection.sql.close(); + } + + public void stopPlugin() { + getServer().getPluginManager().disablePlugin(plugin); + } +} From 3cbd93712b60bb1e5218b639a301456e2590fa10 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 30 May 2015 03:08:56 +0100 Subject: [PATCH 04/25] Added MultiAbilityManager - Manager for most methods and managers for multiabilities. --- .../ProjectKorra/MultiAbilityManager.java | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 src/com/projectkorra/ProjectKorra/MultiAbilityManager.java diff --git a/src/com/projectkorra/ProjectKorra/MultiAbilityManager.java b/src/com/projectkorra/ProjectKorra/MultiAbilityManager.java new file mode 100644 index 00000000..c41f9128 --- /dev/null +++ b/src/com/projectkorra/ProjectKorra/MultiAbilityManager.java @@ -0,0 +1,143 @@ +package com.projectkorra.ProjectKorra; + +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import com.projectkorra.ProjectKorra.Ability.MultiAbility.MultiAbilityModule; +import com.projectkorra.ProjectKorra.Ability.MultiAbility.MultiAbilityModuleManager; + +public class MultiAbilityManager { + + public static ConcurrentHashMap> playerAbilities = new ConcurrentHashMap>(); + public static ConcurrentHashMap playerSlot = new ConcurrentHashMap(); + public static ConcurrentHashMap playerBoundAbility = new ConcurrentHashMap(); + + public MultiAbilityManager() { + manage(); + } + + /** + * Binds the "Fake" abilities. + * @param player + * @param multiAbility + */ + public static void bindMultiAbility(Player player, String multiAbility){ + if(playerAbilities.containsKey(player)) + unbindMultiAbility(player); + playerSlot.put(player, player.getInventory().getHeldItemSlot()); + playerBoundAbility.put(player, multiAbility); + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + HashMap currAbilities = new HashMap(); + for(int i : bPlayer.getAbilities().keySet()){ + currAbilities.put(i, bPlayer.getAbilities().get(i)); + } + playerAbilities.put(player, currAbilities); + + List modes = MultiAbilityModuleManager.multiAbilities.get(multiAbility); + + bPlayer.getAbilities().clear(); + for(int i = 0; i < modes.size(); i++) + bPlayer.getAbilities().put(i+1, modes.get(i)); + + if(player.isOnline()){ + bPlayer.addCooldown("MAM_Setup", 1L); //Support for bending scoreboards. + player.getInventory().setHeldItemSlot(0); + } + } + + /** + * Unbinds the "Fake" abilities. + * @param player + */ + public static void unbindMultiAbility(Player player){ + if(playerAbilities.containsKey(player)){ + HashMap prevBinds = playerAbilities.get(player); + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + int lastNonNull = -1; + for(int i = 1; i < 10; i++){ + if(prevBinds.get(i) != null) + lastNonNull = i; + bPlayer.getAbilities().put(i, prevBinds.get(i)); + } + if(lastNonNull > -1) + GeneralMethods.saveAbility(bPlayer, lastNonNull, prevBinds.get(lastNonNull)); + + if(player.isOnline()) + bPlayer.addCooldown("MAM_Setup", 1L); //Support for bending scoreboards. + playerAbilities.remove(player); + } + + if(playerSlot.containsKey(player)){ + if(player.isOnline()) + player.getInventory().setHeldItemSlot(playerSlot.get(player)); + playerSlot.remove(player); + }else{ + if(player.isOnline()) + player.getInventory().setHeldItemSlot(0); + } + + if(playerBoundAbility.containsKey(player)) + playerBoundAbility.remove(player); + } + + /** + * MultiAbility equivalent of GeneralMethods.getBoundAbility() + * @param player + * @param multiAbility + * @return + */ + public static boolean hasMultiAbilityBound(Player player, String multiAbility){ + if(playerAbilities.containsKey(player)){ + if(!MultiAbilityModuleManager.multiAbilities.get(multiAbility).contains(GeneralMethods.getBoundAbility(player)) && GeneralMethods.getBoundAbility(player) != null) + return false; + return true; + } + return false; + } + + public static void manage(){ + new BukkitRunnable() { + public void run() { + scrollHotBarSlots(); + } + }.runTaskTimer(ProjectKorra.plugin, 0, 1); + } + + public static void scrollHotBarSlots(){ + if(!playerAbilities.isEmpty()){ + for(Player player : playerAbilities.keySet()){ + if(playerBoundAbility.containsKey(player)){ + if(GeneralMethods.getBoundAbility(player) == null){ + if(MultiAbilityModuleManager.multiAbilities.containsKey(playerBoundAbility.get(player))){ + if(player.getInventory().getHeldItemSlot() > MultiAbilityModuleManager.multiAbilities.get(playerBoundAbility.get(player)).size()){ + player.getInventory().setHeldItemSlot(MultiAbilityModuleManager.multiAbilities.get(playerBoundAbility.get(player)).size() - 1); + }else{ + player.getInventory().setHeldItemSlot(0); + } + } + } + } + } + } + } + + public static void remove(Player player){ + playerAbilities.remove(player); + playerBoundAbility.remove(player); + playerSlot.remove(player); + } + + public static void removeAll(){ + List abilities = MultiAbilityModuleManager.multiAbility; + for(MultiAbilityModule mam: abilities) + mam.stop(); + + playerAbilities.clear(); + playerSlot.clear(); + playerBoundAbility.clear(); + } +} From 30724904bc7f126a6e5d5f7b80d8c78ae77a4a91 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 30 May 2015 03:10:19 +0100 Subject: [PATCH 05/25] Added classes for MultiAbilityModules. Allows for creation of multiabilities. --- .../MultiAbility/MultiAbilityModule.java | 133 ++++++++++++++++++ .../MultiAbilityModuleManager.java | 100 +++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModule.java create mode 100644 src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModuleManager.java diff --git a/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModule.java b/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModule.java new file mode 100644 index 00000000..d774565d --- /dev/null +++ b/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModule.java @@ -0,0 +1,133 @@ +package com.projectkorra.ProjectKorra.Ability.MultiAbility; + +import java.util.ArrayList; + +import com.projectkorra.ProjectKorra.SubElement; +import com.projectkorra.ProjectKorra.Utilities.AbilityLoadable; + +public abstract class MultiAbilityModule extends AbilityLoadable implements Cloneable { + + public MultiAbilityModule(String name) { + super(name); + } + + /** + * Called when the ability is loaded by PK. This is where the developer registers Listeners and Permissions. + */ + public abstract void onThisLoad(); + + /** + * Accessor Method to get the version of the ability. + * + * @return The version of the ability as a String. + */ + public abstract String getVersion(); + + /** + * Accessor Method to get the Element of the ability. + * It is recommended to use the Element ENUM to get the returned String. + * This can be an empty String, in which case the ability will not belong to any element (such as AvatarState). + * + * @return The Element the ability belongs to. + */ + public abstract String getElement(); + + /** + * Accessor Method to get the name of the author. + * + * @return The name of the author. + */ + public abstract String getAuthor(); + + /** + * Accessor Method to get the description of the ability. + * This String is sent to any player who runs /pk display ability. + * + * @return The Description of the ability. + */ + public abstract String getDescription(); + + /** + * Accessor Method to get whether this ability uses sneaking to operate. + * Some features of the ProjectKorra plugin only work when this is false. (Fast Swimming for Waterbenders) + * + * @return Whether or not the ability uses the sneak key. + */ + public boolean isShiftAbility(){ + return true; + } + + /** + * Accessor Method to get whether this ability harms entities. + * AirSpout is an example of a harmless ability. For AirSpout, this returns true. + * IceBlast is an example of a harmful ability. For IceBlast, this returns false. + * Torrent is an example of both a harmless and a harmful ability. For Torrent, this returns false. + * + * @return Whether of not the ability can hurt entities. + */ + public abstract boolean isHarmlessAbility(); + + /** + * Accessor Method to get whether this ability can set fire to blocks. + * + * @return Whether or not this ability can ignite blocks. + */ + public boolean isIgniteAbility(){ + return false; + } + + /** + * Accessor Method to get whether this ability can create explosions. + * + * @return Whether or not this ability creates explosions. + */ + public boolean isExplodeAbility(){ + return false; + } + + /** + * Accessor Method to get which SubElement the ability belongs to. + * If isSubAbility() returns true, the developer absolutely must implement this as well. + * + * List of sub-elements: + * + * Water: + * Icebending. + * Bloodbending. + * Plantbending. + * Healing. + * + * Earth: + * Sandbending. + * Metalbending. + * Lavabending. + * + * Fire: + * Combustion. + * Lightning. + * + * Air: + * Flight. + * SpiritualProjection. + * + * @return The SubElement the ability belongs to. + */ + public SubElement getSubElement(){ + return null; + } + + /** + * Returns what abilities should be bound when ability is used. Colors can be used on these abilities! + * @return + */ + public abstract ArrayList getAbilities(); + + /** + * Void Method called whenever ProjectKorra stops and the ability is unloaded. + * + */ + public void stop(){ + + } + +} diff --git a/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModuleManager.java b/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModuleManager.java new file mode 100644 index 00000000..c56f36d7 --- /dev/null +++ b/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModuleManager.java @@ -0,0 +1,100 @@ +package com.projectkorra.ProjectKorra.Ability.MultiAbility; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import com.projectkorra.ProjectKorra.Element; +import com.projectkorra.ProjectKorra.ProjectKorra; +import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; +import com.projectkorra.ProjectKorra.Ability.StockAbilities; +import com.projectkorra.ProjectKorra.Utilities.AbilityLoader; + +public class MultiAbilityModuleManager +{ + private final AbilityLoader loader; + public static List multiAbility; + public static HashMap> multiAbilities; + + public MultiAbilityModuleManager() + { + final File path = new File(ProjectKorra.plugin.getDataFolder().toString() + "/MultiAbilities/"); + if (!path.exists()) + { + path.mkdir(); + } + + loader = new AbilityLoader(ProjectKorra.plugin, path, new Object[] {}); + multiAbility = loader.load(MultiAbilityModule.class); + multiAbilities = new HashMap>(); + + loadMAModules(); + } + + private void loadMAModules() + { + for(MultiAbilityModule mam : multiAbility) + { + mam.onThisLoad(); + AbilityModuleManager.abilities.add(mam.getName()); + for (StockAbilities a: StockAbilities.values()) { + if (a.name().equalsIgnoreCase(mam.getName())){ + AbilityModuleManager.disabledStockAbilities.add(a.name()); + } + } + if (mam.getElement() == Element.Air.toString()) AbilityModuleManager.airbendingabilities.add(mam.getName()); + if (mam.getElement() == Element.Water.toString()) AbilityModuleManager.waterbendingabilities.add(mam.getName()); + if (mam.getElement() == Element.Earth.toString()) AbilityModuleManager.earthbendingabilities.add(mam.getName()); + if (mam.getElement() == Element.Fire.toString()) AbilityModuleManager.firebendingabilities.add(mam.getName()); + if (mam.getElement() == Element.Chi.toString()) AbilityModuleManager.chiabilities.add(mam.getName()); + AbilityModuleManager.shiftabilities.add(mam.getName()); + if (mam.isHarmlessAbility()) AbilityModuleManager.harmlessabilities.add(mam.getName()); + + if (mam.getSubElement() != null) + { + AbilityModuleManager.subabilities.add(mam.getName()); + switch(mam.getSubElement()) + { + case Bloodbending: + AbilityModuleManager.bloodabilities.add(mam.getName()); + break; + case Combustion: + AbilityModuleManager.combustionabilities.add(mam.getName()); + break; + case Flight: + AbilityModuleManager.flightabilities.add(mam.getName()); + break; + case Healing: + AbilityModuleManager.healingabilities.add(mam.getName()); + break; + case Icebending: + AbilityModuleManager.iceabilities.add(mam.getName()); + break; + case Lavabending: + AbilityModuleManager.lavaabilities.add(mam.getName()); + break; + case Lightning: + AbilityModuleManager.lightningabilities.add(mam.getName()); + break; + case Metalbending: + AbilityModuleManager.metalabilities.add(mam.getName()); + break; + case Plantbending: + AbilityModuleManager.plantabilities.add(mam.getName()); + break; + case Sandbending: + AbilityModuleManager.sandabilities.add(mam.getName()); + break; + case SpiritualProjection: + AbilityModuleManager.spiritualprojectionabilities.add(mam.getName()); + break; + } + } + + multiAbilities.put(mam.getName(), mam.getAbilities()); + AbilityModuleManager.descriptions.put(mam.getName(), mam.getDescription()); + AbilityModuleManager.authors.put(mam.getName(), mam.getAuthor()); + } + } +} \ No newline at end of file From f1608728d4cca94446e33f198264e9e5100185e4 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 30 May 2015 14:48:29 +0100 Subject: [PATCH 06/25] Added config options for WaterArms, these might need nerfing. --- .../ProjectKorra/ConfigManager.java | 1605 +++++++++-------- 1 file changed, 832 insertions(+), 773 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/ConfigManager.java b/src/com/projectkorra/ProjectKorra/ConfigManager.java index d610a0fa..9802016f 100644 --- a/src/com/projectkorra/ProjectKorra/ConfigManager.java +++ b/src/com/projectkorra/ProjectKorra/ConfigManager.java @@ -1,773 +1,832 @@ -package com.projectkorra.ProjectKorra; - -import org.bukkit.configuration.file.FileConfiguration; - -import java.util.ArrayList; - -public class ConfigManager { - - static ProjectKorra plugin; - - public ConfigManager(ProjectKorra plugin) { - ConfigManager.plugin = plugin; - configCheck(); - } - - public static void configCheck() { - - FileConfiguration config = ProjectKorra.plugin.getConfig(); - - ArrayList earthbendable = new ArrayList(); - earthbendable.add("STONE"); - earthbendable.add("CLAY"); - earthbendable.add("COAL_ORE"); - earthbendable.add("DIAMOND_ORE"); - earthbendable.add("DIRT"); - earthbendable.add("GOLD_ORE"); - earthbendable.add("GRASS"); - earthbendable.add("GRAVEL"); - earthbendable.add("IRON_ORE"); - earthbendable.add("LAPIS_ORE"); - earthbendable.add("NETHERRACK"); - earthbendable.add("REDSTONE_ORE"); - earthbendable.add("SAND"); - earthbendable.add("SANDSTONE"); - earthbendable.add("MYCEL"); - - ArrayList metals = new ArrayList(); - metals.add("IRON_BLOCK"); - metals.add("GOLD_BLOCK"); - metals.add("QUARTZ_BLOCK"); - - config.addDefault("Properties.Chat.Enable", true); - config.addDefault("Properties.Chat.Format", ": "); - config.addDefault("Properties.Chat.Prefixes.Air", "[Airbender]"); - config.addDefault("Properties.Chat.Prefixes.Water", "[Waterbender]"); - config.addDefault("Properties.Chat.Prefixes.Earth", "[Earthbender]"); - config.addDefault("Properties.Chat.Prefixes.Fire", "[Firebender]"); - config.addDefault("Properties.Chat.Prefixes.Chi", "[Chiblocker]"); - config.addDefault("Properties.Chat.Prefixes.Avatar", "[Avatar]"); - config.addDefault("Properties.Chat.Colors.Avatar", "DARK_PURPLE"); - config.addDefault("Properties.Chat.Colors.Air", "GRAY"); - config.addDefault("Properties.Chat.Colors.AirSub", "DARK_GRAY"); - config.addDefault("Properties.Chat.Colors.Water", "AQUA"); - config.addDefault("Properties.Chat.Colors.WaterSub", "DARK_AQUA"); - config.addDefault("Properties.Chat.Colors.Earth", "GREEN"); - config.addDefault("Properties.Chat.Colors.EarthSub", "DARK_GREEN"); - config.addDefault("Properties.Chat.Colors.Fire", "RED"); - config.addDefault("Properties.Chat.Colors.FireSub", "DARK_RED"); - config.addDefault("Properties.Chat.Colors.Chi", "GOLD"); - - config.addDefault("Properties.ImportEnabled", true); - config.addDefault("Properties.BendingAffectFallingSand.Normal", true); - config.addDefault("Properties.BendingAffectFallingSand.NormalStrengthMultiplier", 1.0); - config.addDefault("Properties.BendingAffectFallingSand.TNT", true); - config.addDefault("Properties.BendingAffectFallingSand.TNTStrengthMultiplier", 1.0); - config.addDefault("Properties.GlobalCooldown", 500); - config.addDefault("Properties.SeaLevel", 62); - - config.addDefault("Properties.HorizontalCollisionPhysics.Enabled", true); - config.addDefault("Properties.HorizontalCollisionPhysics.WallDamageMinimumDistance", 5.0); - - config.addDefault("Properties.CustomItems.GrapplingHook.Enable", true); - config.addDefault("Properties.CustomItems.GrapplingHook.IronUses", 25); - config.addDefault("Properties.CustomItems.GrapplingHook.GoldUses", 50); - - config.addDefault("Properties.RegionProtection.AllowHarmlessAbilities", true); - config.addDefault("Properties.RegionProtection.RespectWorldGuard", true); - config.addDefault("Properties.RegionProtection.RespectGriefPrevention", true); - config.addDefault("Properties.RegionProtection.RespectFactions", true); - config.addDefault("Properties.RegionProtection.RespectTowny", true); - config.addDefault("Properties.RegionProtection.RespectPreciousStones", true); - config.addDefault("Properties.RegionProtection.RespectLWC", true); - config.addDefault("Properties.RegionProtection.CacheBlockTime", 5000); - - config.addDefault("Properties.TagAPI.Enabled", true); - - config.addDefault("Properties.Air.CanBendWithWeapons", false); - config.addDefault("Properties.Air.Particles", "smoke"); - config.addDefault("Properties.Air.PlaySound", true); - - config.addDefault("Properties.Water.CanBendWithWeapons", true); - config.addDefault("Properties.Water.NightFactor", 1.5); - config.addDefault("Properties.Water.FullMoonFactor", 3.0); - config.addDefault("Properties.Water.CanBendPackedIce", true); - config.addDefault("Properties.Water.PlaySound", true); - - config.addDefault("Properties.Earth.RevertEarthbending", true); - config.addDefault("Properties.Earth.SafeRevert", true); - config.addDefault("Properties.Earth.RevertCheckTime", 300000); - config.addDefault("Properties.Earth.CanBendWithWeapons", true); - config.addDefault("Properties.Earth.EarthbendableBlocks", earthbendable); - config.addDefault("Properties.Earth.MetalBlocks", metals); - config.addDefault("Properties.Earth.MetalPowerFactor", 1.5); - config.addDefault("Properties.Earth.PlaySound", true); - - config.addDefault("Properties.Fire.CanBendWithWeapons", true); - config.addDefault("Properties.Fire.DayFactor", 1.5); - config.addDefault("Properties.Fire.PlaySound", true); - - config.addDefault("Properties.Chi.CanBendWithWeapons", true); - - ArrayList disabledWorlds = new ArrayList(); - disabledWorlds.add("TestWorld"); - disabledWorlds.add("TestWorld2"); - config.addDefault("Properties.DisabledWorlds", disabledWorlds); - - config.addDefault("Abilities.AvatarState.Enabled", true); - config.addDefault("Abilities.AvatarState.Description", "The signature ability of the Avatar, this is a toggle. Click to activate to become " - + "nearly unstoppable. While in the Avatar State, the user takes severely reduced damage from " - + "all sources, regenerates health rapidly, and is granted extreme speed. Nearly all abilities " - + "are incredibly amplified in this state. Additionally, AirShield and FireJet become toggle-able " - + "abilities and last until you deactivate them or the Avatar State. Click again with the Avatar " - + "State selected to deactivate it."); - config.addDefault("Abilities.AvatarState.Cooldown", 7200000); - config.addDefault("Abilities.AvatarState.Duration", 480000); - config.addDefault("Abilities.AvatarState.PowerMultiplier", 5); - config.addDefault("Abilities.AvatarState.PotionEffects.Regeneration.Enabled", true); - config.addDefault("Abilities.AvatarState.PotionEffects.Regeneration.Power", 3); - config.addDefault("Abilities.AvatarState.PotionEffects.Speed.Enabled", true); - config.addDefault("Abilities.AvatarState.PotionEffects.Speed.Power", 3); - config.addDefault("Abilities.AvatarState.PotionEffects.DamageResistance.Enabled", true); - config.addDefault("Abilities.AvatarState.PotionEffects.FireResistance.Enabled", true); - config.addDefault("Abilities.AvatarState.PotionEffects.FireResistance.Power", 3); - - config.addDefault("Abilities.Air.Passive.Factor", 0.3); - config.addDefault("Abilities.Air.Passive.Speed", 2); - config.addDefault("Abilities.Air.Passive.Jump", 3); - - config.addDefault("Abilities.Air.AirBlast.Enabled", true); - config.addDefault("Abilities.Air.AirBlast.Description", "AirBlast is the most fundamental bending technique of an airbender." - + " To use, simply left-click in a direction. A gust of wind will be" - + " created at your fingertips, launching anything in its path harmlessly back." - + " A gust of air can extinguish fires on the ground or on a player, can cool lava, and " - + "can flip levers and activate buttons. Additionally, tapping sneak will change the " - + "origin of your next AirBlast to your targeted location."); - config.addDefault("Abilities.Air.AirBlast.Speed", 25); - config.addDefault("Abilities.Air.AirBlast.Range", 20); - config.addDefault("Abilities.Air.AirBlast.Radius", 2); - config.addDefault("Abilities.Air.AirBlast.Push", 3.5); - - config.addDefault("Abilities.Air.AirBubble.Enabled", true); - config.addDefault("Abilities.Air.AirBubble.Description", "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."); - config.addDefault("Abilities.Air.AirBubble.Radius", 7); - - config.addDefault("Abilities.Air.AirBurst.Enabled", true); - config.addDefault("Abilities.Air.AirBurst.Description", "AirBurst is one of the most powerful abilities in the airbender's arsenal. " - + "To use, press and hold sneak to charge your burst. " - + "Once charged, you can either release sneak to launch a cone-shaped burst " - + "of air in front of you, or click to release the burst in a sphere around you. " - + "Additionally, having this ability selected when you land on the ground from a " - + "large enough fall will create a burst of air around you."); - config.addDefault("Abilities.Air.AirBurst.FallThreshold", 10); - config.addDefault("Abilities.Air.AirBurst.PushFactor", 1.5); - config.addDefault("Abilities.Air.AirBurst.ChargeTime", 1750); - config.addDefault("Abilities.Air.AirBurst.Damage", 0); - - config.addDefault("Abilities.Air.AirScooter.Enabled", true); - config.addDefault("Abilities.Air.AirScooter.Description", "AirScooter is a fast means of transportation. To use, sprint, jump then click with " - + "this ability selected. You will hop on a scooter of air and be propelled forward " - + "in the direction you're looking (you don't need to press anything). " - + "This ability can be used to levitate above liquids, but it cannot go up steep slopes. " - + "Any other actions will deactivate this ability."); - config.addDefault("Abilities.Air.AirScooter.Speed", .675); - - config.addDefault("Abilities.Air.Tornado.Enabled", true); - config.addDefault("Abilities.Air.Tornado.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 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's looking. Skilled airbenders can scale anything " - + "with this ability."); - - config.addDefault("Abilities.Air.AirShield.Enabled", true); - config.addDefault("Abilities.Air.AirShield.Description", "Air Shield is one of the most powerful defensive techniques in existence. " - + "To use, simply sneak (default: shift). " - + "This will create a whirlwind of air around the user, " - + "with a small pocket of safe space in the center. " - + "This wind will deflect all projectiles and will prevent any creature from " - + "entering it for as long as its maintained."); - config.addDefault("Abilities.Air.AirShield.Radius", 7); - config.addDefault("Abilities.Air.AirShield.IsAvatarStateToggle", true); - - config.addDefault("Abilities.Air.AirSpout.Enabled", true); - config.addDefault("Abilities.Air.AirSpout.Description", "This ability gives the airbender limited sustained levitation. It is a " - + "toggle - click to activate and form a whirling spout of air " - + "beneath you, lifting you up. You can bend other abilities while using AirSpout. " - + "Click again to deactivate this ability."); - config.addDefault("Abilities.Air.AirSpout.Height", 20); - - config.addDefault("Abilities.Air.AirSuction.Enabled", true); - config.addDefault("Abilities.Air.AirSuction.Description", "To use, simply left-click in a direction. A gust of wind will originate as far as it can in that direction and flow towards you, sucking anything in its path harmlessly with it. Skilled benders can use this technique to pull items from precarious locations. Additionally, tapping sneak will change the origin of your next AirSuction to your targeted location."); - config.addDefault("Abilities.Air.AirSuction.Speed", 25); - config.addDefault("Abilities.Air.AirSuction.Range", 20); - config.addDefault("Abilities.Air.AirSuction.Radius", 2); - config.addDefault("Abilities.Air.AirSuction.Push", 3.5); - - config.addDefault("Abilities.Air.AirSwipe.Enabled", true); - config.addDefault("Abilities.Air.AirSwipe.Description", "To use, simply left-click in a direction. An arc of air will flow from you towards that direction, cutting and pushing back anything in its path. Its damage is minimal, but it still sends the message. This ability will extinguish fires, cool lava, and cut things like grass, mushrooms, and flowers. Additionally, you can charge it by holding sneak. Charging before attacking will increase damage and knockback, up to a maximum."); - config.addDefault("Abilities.Air.AirSwipe.Damage", 2); - config.addDefault("Abilities.Air.AirSwipe.Range", 16); - config.addDefault("Abilities.Air.AirSwipe.Radius", 2); - config.addDefault("Abilities.Air.AirSwipe.Push", 1); - config.addDefault("Abilities.Air.AirSwipe.Arc", 20); - config.addDefault("Abilities.Air.AirSwipe.Speed", 25); - config.addDefault("Abilities.Air.AirSwipe.Cooldown", 1500); - config.addDefault("Abilities.Air.AirSwipe.ChargeFactor", 3); - config.addDefault("Abilities.Air.AirSwipe.MaxChargeTime", 3000); - - config.addDefault("Abilities.Air.Flight.Enabled", true); - config.addDefault("Abilities.Air.Flight.Description", "Jump in the air, crouch (default: shift) and hold with this ability bound and you will glide around in the direction you look. While flying, click to Hover. Click again to disable Hovering."); - config.addDefault("Abilities.Air.Flight.HoverEnabled", true); - - config.addDefault("Abilities.Air.Suffocate.Enabled", true); - config.addDefault("Abilities.Air.Suffocate.Description", "This ability is one of the most dangerous abilities an Airbender possesses. To use, simply look at an entity and hold shift. The entity will begin taking damage as you extract the air from their lungs. Any bender caught in this sphere will only be able to use basic moves, such as AirSwipe, WaterManipulation, FireBlast, or EarthBlast. An entity can be knocked out of the sphere by certain bending arts, and your attention will be disrupted if you are hit by bending."); - config.addDefault("Abilities.Air.Suffocate.ChargeTime", 1000); - config.addDefault("Abilities.Air.Suffocate.Cooldown", 0); - config.addDefault("Abilities.Air.Suffocate.Range", 15); - config.addDefault("Abilities.Air.Suffocate.Damage", 2); - config.addDefault("Abilities.Air.Suffocate.DamageInitialDelay", 2); - config.addDefault("Abilities.Air.Suffocate.DamageInterval", 1); - config.addDefault("Abilities.Air.Suffocate.SlowPotency", 1); - config.addDefault("Abilities.Air.Suffocate.SlowDelay", 0.5); - config.addDefault("Abilities.Air.Suffocate.SlowInterval", 1.25); - config.addDefault("Abilities.Air.Suffocate.BlindPotentcy", 30); - config.addDefault("Abilities.Air.Suffocate.BlindDelay", 2); - config.addDefault("Abilities.Air.Suffocate.BlindInterval", 1.5); - config.addDefault("Abilities.Air.Suffocate.CanBeUsedOnUndeadMobs", true); - config.addDefault("Abilities.Air.Suffocate.RequireConstantAim", true); - config.addDefault("Abilities.Air.Suffocate.RequireConstantAimRadius", 5); - config.addDefault("Abilities.Air.Suffocate.AnimationRadius", 2.0); - config.addDefault("Abilities.Air.Suffocate.AnimationParticleAmount", 2); - config.addDefault("Abilities.Air.Suffocate.AnimationSpeed", 1.0); - - config.addDefault("Abilities.Air.Tornado.Radius", 10); - config.addDefault("Abilities.Air.Tornado.Height", 25); - config.addDefault("Abilities.Air.Tornado.Range", 25); - config.addDefault("Abilities.Air.Tornado.MobPushFactor", 1); - config.addDefault("Abilities.Air.Tornado.PlayerPushFactor", 1); - - config.addDefault("Abilities.Air.AirCombo.Enabled", true); - config.addDefault("Abilities.Air.AirCombo.Twister.Speed", 0.35); - config.addDefault("Abilities.Air.AirCombo.Twister.Range", 16); - config.addDefault("Abilities.Air.AirCombo.Twister.Height", 8); - config.addDefault("Abilities.Air.AirCombo.Twister.Radius", 3.5); - config.addDefault("Abilities.Air.AirCombo.Twister.RemoveDelay", 1500); - config.addDefault("Abilities.Air.AirCombo.Twister.Cooldown", 10000); - config.addDefault("Abilities.Air.AirCombo.Twister.DegreesPerParticle", 7); - config.addDefault("Abilities.Air.AirCombo.Twister.HeightPerParticle", 1.25); - config.addDefault("Abilities.Air.AirCombo.AirStream.Speed", 0.5); - config.addDefault("Abilities.Air.AirCombo.AirStream.Range", 40); - config.addDefault("Abilities.Air.AirCombo.AirStream.EntityDuration", 4000); - config.addDefault("Abilities.Air.AirCombo.AirStream.EntityHeight", 14); - config.addDefault("Abilities.Air.AirCombo.AirStream.Cooldown", 6000); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Speed", 1.4); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Range", 14); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Damage", 4); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Knockback", 3.5); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Cooldown", 5000); - - config.addDefault("Abilities.Water.Passive.SwimSpeedFactor", 0.7); - - config.addDefault("Abilities.Water.Bloodbending.Enabled", true); - config.addDefault("Abilities.Water.Bloodbending.Description", "This ability was made illegal for a reason. With this ability selected, sneak while " - + "targetting something and you will bloodbend that target. Bloodbent targets cannot move, " - + "bend or attack. You are free to control their actions by looking elsewhere - they will " - + "be forced to move in that direction. Additionally, clicking while bloodbending will " - + "launch that target off in the direction you're looking. " - + "People who are capable of bloodbending are immune to your technique, and you are immune to theirs."); - config.addDefault("Abilities.Water.Bloodbending.CanOnlyBeUsedAtNight", false); - config.addDefault("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs", true); - config.addDefault("Abilities.Water.Bloodbending.ThrowFactor", 2); - config.addDefault("Abilities.Water.Bloodbending.Range", 10); - config.addDefault("Abilities.Water.Bloodbending.HoldTime", 0); - config.addDefault("Abilities.Water.Bloodbending.Cooldown", 0); - config.addDefault("Abilities.Water.Bloodbending.CanOnlyBeUsedDuringFullMoon", false); - - config.addDefault("Abilities.Water.HealingWaters.Enabled", true); - config.addDefault("Abilities.Water.HealingWaters.Description", "To use, the bender must be at least partially submerged in water. " - + "If the user is not sneaking, this ability will automatically begin " - + "working provided the user has it selected. If the user is sneaking, " - + "he/she is channeling the healing to their target in front of them. " - + "In order for this channel to be successful, the user and the target must " - + "be at least partially submerged in water."); - config.addDefault("Abilities.Water.HealingWaters.Radius", 5); - config.addDefault("Abilities.Water.HealingWaters.Interval", 750); - config.addDefault("Abilities.Water.HealingWaters.Power", 1); - - config.addDefault("Abilities.Water.IceBlast.Enabled", true); - config.addDefault("Abilities.Water.IceBlast.Damage", 3); - config.addDefault("Abilities.Water.IceBlast.Range", 20); - config.addDefault("Abilities.Water.IceBlast.Description", "This ability offers a powerful ice utility for Waterbenders. It can be used to fire an explosive burst of ice at an opponent, spraying ice and snow around it. To use, simply tap sneak (Default: Shift) while targeting a block of ice to select it as a source. From there, you can just left click to send the blast off at your opponent."); - - config.addDefault("Abilities.Water.IceSpike.Enabled", true); - config.addDefault("Abilities.Water.IceSpike.Description", "This ability has many functions. Clicking while targetting ice, or an entity over some ice, " - + "will raise a spike of ice up, damaging and slowing the target. Tapping sneak (shift) while" - + " selecting a water source will select that source that can then be fired with a click. Firing" - + " this will launch a spike of ice at your target, dealing a bit of damage and slowing the target. " - + "If you sneak (shift) while not selecting a source, many ice spikes will erupt from around you, " - + "damaging and slowing those targets."); - config.addDefault("Abilities.Water.IceSpike.Cooldown", 2000); - config.addDefault("Abilities.Water.IceSpike.Damage", 2); - config.addDefault("Abilities.Water.IceSpike.Range", 20); - config.addDefault("Abilities.Water.IceSpike.ThrowingMult", 0.7); - config.addDefault("Abilities.Water.IceSpike.Height", 6); - config.addDefault("Abilities.Water.IceSpike.Projectile.Range", 20); - config.addDefault("Abilities.Water.IceSpike.Projectile.Damage", 1); - - config.addDefault("Abilities.Water.OctopusForm.Enabled", true); - config.addDefault("Abilities.Water.OctopusForm.Description", "This ability allows the waterbender to manipulate a large quantity of water into a form resembling that of an octopus. " - + "To use, click to select a water source. Then, hold sneak to channel this ability. " - + "While channeling, the water will form itself around you and has a chance to block incoming attacks. " - + "Additionally, you can click while channeling to attack things near you, dealing damage and knocking them back. " - + "Releasing shift at any time will dissipate the form."); - config.addDefault("Abilities.Water.OctopusForm.Range", 10); - config.addDefault("Abilities.Water.OctopusForm.AttackRange", 2.5); - config.addDefault("Abilities.Water.OctopusForm.Radius", 3); - config.addDefault("Abilities.Water.OctopusForm.Damage", 3); - config.addDefault("Abilities.Water.OctopusForm.Knockback", 1.75); - config.addDefault("Abilities.Water.OctopusForm.FormDelay", 50); - - config.addDefault("Abilities.Water.PhaseChange.Enabled", true); - config.addDefault("Abilities.Water.PhaseChange.Description", "To use, simply left-click. " - + "Any water you are looking at within range will instantly freeze over into solid ice. " - + "Provided you stay within range of the ice and do not unbind FreezeMelt, " - + "that ice will not thaw. If, however, you do either of those the ice will instantly thaw. " - + "If you sneak (default: shift), anything around where you are looking at will instantly melt. " - + "Since this is a more favorable state for these things, they will never re-freeze unless they " - + "would otherwise by nature or some other bending ability. Additionally, if you tap sneak while " - + "targetting water with FreezeMelt, it will evaporate water around that block that is above " - + "sea level. "); - config.addDefault("Abilities.Water.PhaseChange.Range", 20); - config.addDefault("Abilities.Water.PhaseChange.Radius", 5); - - config.addDefault("Abilities.Water.Surge.Enabled", true); - config.addDefault("Abilities.Water.Surge.Description", "This ability has two distinct features. If you sneak to select a source block, you can then click in a direction and a large wave will be launched in that direction. If you sneak again while the wave is en route, the wave will freeze the next target it hits. If, instead, you click to select a source block, you can hold sneak to form a wall of water at your cursor location. Click to shift between a water wall and an ice wall. Release sneak to dissipate it."); - config.addDefault("Abilities.Water.Surge.Wave.Radius", 3); - config.addDefault("Abilities.Water.Surge.Wave.Range", 20); - config.addDefault("Abilities.Water.Surge.Wave.HorizontalPush", 1); - config.addDefault("Abilities.Water.Surge.VerticalPush", 0.2); - config.addDefault("Abilities.Water.Surge.Wall.Range", 5); - config.addDefault("Abilities.Water.Surge.Wall.Radius", 2); - - config.addDefault("Abilities.Water.Torrent.Enabled", true); - config.addDefault("Abilities.Water.Torrent.Description", "Torrent is one of the strongest moves in a waterbender's arsenal. To use, first click a source block to select it; then hold shift to begin streaming the water around you. Water flowing around you this way will damage and knock back nearby enemies and projectiles. If you release shift during this, you will create a large wave that expands outwards from you, launching anything in its path back. Instead, if you click you release the water and channel it to flow towards your cursor. Anything caught in the blast will be tossed about violently and take damage. Finally, if you click again when the water is torrenting, it will freeze the area around it when it is obstructed."); - config.addDefault("Abilities.Water.Torrent.Range", 25); - config.addDefault("Abilities.Water.Torrent.DeflectDamage", 1); - config.addDefault("Abilities.Water.Torrent.Damage", 2); - config.addDefault("Abilities.Water.Torrent.Wave.Radius", 15); - config.addDefault("Abilities.Water.Torrent.Wave.Knockback", 1.5); - config.addDefault("Abilities.Water.Torrent.Wave.Height", 1); - - config.addDefault("Abilities.Water.Plantbending.RegrowTime", 180000); - - config.addDefault("Abilities.Water.WaterBubble.Enabled", true); - config.addDefault("Abilities.Water.WaterBubble.Description","To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."); - config.addDefault("Abilities.Water.WaterBubble.Radius", 7); - - config.addDefault("Abilities.Water.WaterManipulation.Enabled", true); - config.addDefault("Abilities.Water.WaterManipulation.Description", "To use, place your cursor over a waterbendable object and tap sneak (default: shift). Smoke will appear where you've selected, indicating the origin of your ability. After you have selected an origin, simply left-click in any direction and you will see your water spout off in that direction, slicing any creature in its path. If you look towards a creature when you use this ability, it will target that creature. A collision from Water Manipulation both knocks the target back and deals some damage. Alternatively, if you have the source selected and tap shift again, you will be able to control the water more directly."); - config.addDefault("Abilities.Water.WaterManipulation.Damage", 3.0); - config.addDefault("Abilities.Water.WaterManipulation.Range", 20); - config.addDefault("Abilities.Water.WaterManipulation.Speed", 35); - config.addDefault("Abilities.Water.WaterManipulation.Push", 0.3); - config.addDefault("Abilities.Water.WaterManipulation.Cooldown", 1000); - - config.addDefault("Abilities.Water.WaterSpout.Enabled", true); - config.addDefault("Abilities.Water.WaterSpout.Description", "This ability provides a Waterbender with a means of transportation. To use, simply left click while in or over water to spout water up beneath you, experiencing controlled levitation. Left clicking again while the spout is active will cause it to disappear. Alternatively, tapping a Waterbendable block while not in Water will select a water block as a source, from there, you can tap sneak (Default:Shift) to channel the Water around you. Releasing the sneak will create a wave allowing you a quick burst of controlled transportation. While riding the wave you may press sneak to cause the wave to disappear."); - config.addDefault("Abilities.Water.WaterSpout.Height", 20); - config.addDefault("Abilities.Water.WaterSpout.Wave.Particles", false); - config.addDefault("Abilities.Water.WaterSpout.Wave.Enabled", true); - config.addDefault("Abilities.Water.WaterSpout.Wave.Range", 6); - config.addDefault("Abilities.Water.WaterSpout.Wave.ChargeTime", 1000); - config.addDefault("Abilities.Water.WaterSpout.Wave.FlightTime", 2000); - config.addDefault("Abilities.Water.WaterSpout.Wave.Speed", 1.2); - - config.addDefault("Abilities.Water.WaterCombo.Enabled", true); - config.addDefault("Abilities.Water.WaterCombo.IceWave.Damage", 3); - config.addDefault("Abilities.Water.WaterCombo.IceWave.Cooldown", 6000); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.Damage", 1.5); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.Radius", 2.5); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.Range", 12); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.MaxShots", 30); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.AnimationSpeed", 1); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.ShootTime", 5000); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.Cooldown", 10000); - - config.addDefault("Abilities.Earth.Passive.Duration", 2500); - - config.addDefault("Abilities.Earth.Catapult.Enabled", true); - config.addDefault("Abilities.Earth.Catapult.Description", "To use, left-click while looking in the direction you want to be launched. " - + "A pillar of earth will jut up from under you and launch you in that direction - " - + "if and only if there is enough earth behind where you're looking to launch you. " - + "Skillful use of this ability takes much time and work, and it does result in the " - + "death of certain gung-ho earthbenders. If you plan to use this ability, be sure " - + "you've read about your passive ability you innately have as an earthbender."); - config.addDefault("Abilities.Earth.Catapult.Length", 7); - config.addDefault("Abilities.Earth.Catapult.Speed", 12); - config.addDefault("Abilities.Earth.Catapult.Push", 5); - - config.addDefault("Abilities.Earth.Collapse.Enabled", true); - config.addDefault("Abilities.Earth.Collapse.Description", " To use, simply left-click on an earthbendable block. " - + "That block and the earthbendable blocks above it will be shoved " - + "back into the earth below them, if they can. " - + "This ability does have the capacity to trap something inside of it, " - + "although it is incredibly difficult to do so. " - + "Additionally, press sneak with this ability to affect an area around your targetted location - " - + "all earth that can be moved downwards will be moved downwards. " - + "This ability is especially risky or deadly in caves, depending on the " - + "earthbender's goal and technique."); - config.addDefault("Abilities.Earth.Collapse.Range", 20); - config.addDefault("Abilities.Earth.Collapse.Radius", 7); - config.addDefault("Abilities.Earth.Collapse.Speed", 8); - - config.addDefault("Abilities.Earth.EarthArmor.Enabled", true); - config.addDefault("Abilities.Earth.EarthArmor.Description", "This ability encases the earthbender in temporary armor. To use, click on a block that is earthbendable. If there is another block under it that is earthbendable, the block will fly to you and grant you temporary armor and damage reduction. This ability has a long cooldown."); - config.addDefault("Abilities.Earth.EarthArmor.Duration", 10000); - config.addDefault("Abilities.Earth.EarthArmor.Strength", 2); - config.addDefault("Abilities.Earth.EarthArmor.Duration", 17500); - - config.addDefault("Abilities.Earth.EarthBlast.Enabled", true); - config.addDefault("Abilities.Earth.EarthBlast.Description", "To use, place your cursor over an earthbendable object (dirt, rock, ores, etc) " - + "and tap sneak (default: shift). The object will temporarily turn to stone, " - + "indicating that you have it focused as the source for your ability. " - + "After you have selected an origin (you no longer need to be sneaking), " - + "simply left-click in any direction and you will see your object launch " - + "off in that direction, smashing into any creature in its path. If you look " - + "towards a creature when you use this ability, it will target that creature. " - + "A collision from Earth Blast both knocks the target back and deals some damage. " - + "You cannot have multiple of these abilities flying at the same time."); - config.addDefault("Abilities.Earth.EarthBlast.CanHitSelf", false); - config.addDefault("Abilities.Earth.EarthBlast.PrepareRange", 7); - config.addDefault("Abilities.Earth.EarthBlast.Range", 20); - config.addDefault("Abilities.Earth.EarthBlast.Speed", 35); - config.addDefault("Abilities.Earth.EarthBlast.Revert", true); - config.addDefault("Abilities.Earth.Earthblast.Damage", 4); - config.addDefault("Abilities.Earth.EarthBlast.Push", 0.3); - - config.addDefault("Abilities.Earth.EarthGrab.Enabled", true); - config.addDefault("Abilities.Earth.EarthGrab.Description", "To use, simply left-click while targeting a creature within range. " - + "This ability will erect a circle of earth to trap the creature in."); - config.addDefault("Abilities.Earth.EarthGrab.Range", 15); - - config.addDefault("Abilities.Earth.EarthTunnel.Enabled", true); - config.addDefault("Abilities.Earth.EarthTunnel.Description", "Earth Tunnel is a completely utility ability for earthbenders. To use, simply sneak (default: shift) in the direction you want to tunnel. You will slowly begin tunneling in the direction you're facing for as long as you sneak or if the tunnel has been dug long enough. This ability will be interrupted if it hits a block that cannot be earthbent."); - config.addDefault("Abilities.Earth.EarthTunnel.MaxRadius", 1); - config.addDefault("Abilities.Earth.EarthTunnel.Range", 10); - config.addDefault("Abilities.Earth.EarthTunnel.Radius", 0.25); - config.addDefault("Abilities.Earth.EarthTunnel.Revert", true); - config.addDefault("Abilities.Earth.EarthTunnel.Interval", 30); - - config.addDefault("Abilities.Earth.Extraction.Enabled", true); - config.addDefault("Abilities.Earth.Extraction.Description", "This ability allows metalbenders to extract the minerals from ore blocks. To use, simply tap sneak while looking at an ore block with metal in it (iron, gold, quartz) and the ore will be extracted and drop in front of you. This ability has a small chance of doubling or tripling the loot. This ability has a short cooldown."); - config.addDefault("Abilities.Earth.Extraction.Cooldown", 10000); - config.addDefault("Abilities.Earth.Extraction.TripleLootChance", 15); - config.addDefault("Abilities.Earth.Extraction.DoubleLootChance", 40); - - config.addDefault("Abilities.Earth.LavaFlow.Enabled", true); - config.addDefault("Abilities.Earth.LavaFlow.Description", "This ability allows an Earthbender to create lava using the Earth around them. To use, simply hold sneak (Default: Shift) to create a lava moat that surrounds you, press sneak again to remove the moat. Left click an Earthbendable block to create a pool of lava after a small delay. Additionally, you can left click at any time to turn lava back into its original state -- Earth."); - config.addDefault("Abilities.Earth.LavaFlow.ShiftCooldown", 16000); - config.addDefault("Abilities.Earth.LavaFlow.ClickLavaCooldown", 10000); - config.addDefault("Abilities.Earth.LavaFlow.ClickLandCooldown", 500); - config.addDefault("Abilities.Earth.LavaFlow.ShiftCleanupDelay", 10000); - config.addDefault("Abilities.Earth.LavaFlow.ClickLavaCleanupDelay", 7000); - config.addDefault("Abilities.Earth.LavaFlow.ClickLandCleanupDelay", 20000); - config.addDefault("Abilities.Earth.LavaFlow.ClickRange", 10.0); - config.addDefault("Abilities.Earth.LavaFlow.ShiftRadius", 8.0); - config.addDefault("Abilities.Earth.LavaFlow.ShiftPlatformRadius", 1.5); - config.addDefault("Abilities.Earth.LavaFlow.ClickRadius", 5.0); - config.addDefault("Abilities.Earth.LavaFlow.ClickLavaCreateSpeed", 0.05); - config.addDefault("Abilities.Earth.LavaFlow.ClickLandCreateSpeed", 0.10); - config.addDefault("Abilities.Earth.LavaFlow.ShiftFlowSpeed", 0.1); - config.addDefault("Abilities.Earth.LavaFlow.ShiftRemoveSpeed", 3.0); - config.addDefault("Abilities.Earth.LavaFlow.ClickLavaStartDelay", 1500); - config.addDefault("Abilities.Earth.LavaFlow.ClickLandStartDelay", 0); - config.addDefault("Abilities.Earth.LavaFlow.UpwardFlow", 2); - config.addDefault("Abilities.Earth.LavaFlow.DownwardFlow", 4); - config.addDefault("Abilities.Earth.LavaFlow.AllowNaturalFlow", false); - config.addDefault("Abilities.Earth.LavaFlow.ParticleDensity", 0.33); - - config.addDefault("Abilities.Earth.EarthSmash.Enabled", true); - config.addDefault("Abilities.Earth.EarthSmash.Description", "To raise an EarthSmash hold sneak (default: shift) for approximately 1.5 seconds, " + - "then release while aiming at dirt. To grab the EarthSmash aim at the center and hold sneak, " + - "the EarthSmash will follow your mouse. You can shoot the EarthSmash by grabbing onto it and left clicking. " + - "To ride the EarthSmash simply hop ontop of it and hold sneak while aiming in the direction that you wish to go. " + - "Another way to ride an EarthSmash is to grab it with sneak and then right click it. " + - "Use EarthSmash as a defensive shield, a powerful attack, or an advanced means of transportation."); - config.addDefault("Abilities.Earth.EarthSmash.AllowGrab", true); - config.addDefault("Abilities.Earth.EarthSmash.AllowShooting", true); - config.addDefault("Abilities.Earth.EarthSmash.AllowFlight", true); - config.addDefault("Abilities.Earth.EarthSmash.GrabRange", 10); - config.addDefault("Abilities.Earth.EarthSmash.ChargeTime", 1200); - config.addDefault("Abilities.Earth.EarthSmash.Cooldown", 0); - config.addDefault("Abilities.Earth.EarthSmash.ShotRange", 30); - config.addDefault("Abilities.Earth.EarthSmash.Damage", 6); - config.addDefault("Abilities.Earth.EarthSmash.Knockback", 3.5); - config.addDefault("Abilities.Earth.EarthSmash.Knockup", 0.15); - config.addDefault("Abilities.Earth.EarthSmash.FlightSpeed", 0.72); - config.addDefault("Abilities.Earth.EarthSmash.FlightTimer", 3000); - config.addDefault("Abilities.Earth.EarthSmash.RemoveTimer", 30000); - -// config.addDefault("Abilities.Earth.LavaSurge.Enabled", true); -// config.addDefault("Abilities.Earth.LavaSurge.Description", "LavaSurge is a fundamental move for any Lavabender out there. To use, simply sneak (Default: Shift) while looking at a source of Earth or Lava, then click in a direction. A surge of lava will swiftly travel towards the target you were pointing at, dealing moderate damage, a large knockback, and setting them on fire."); -// config.addDefault("Abilities.Earth.LavaSurge.Damage", 4); -// config.addDefault("Abilities.Earth.LavaSurge.Cooldown", 1000); -// config.addDefault("Abilities.Earth.LavaSurge.FractureRadius", 1); -// config.addDefault("Abilities.Earth.LavaSurge.PrepareRange", 7); -// config.addDefault("Abilities.Earth.LavaSurge.TravelRange", 15); -// config.addDefault("Abilities.Earth.LavaSurge.MaxLavaWaves", 10); -// config.addDefault("Abilities.Earth.LavaSurge.SourceCanBeEarth", true); - - config.addDefault("Abilities.Earth.MetalClips.Enabled", true); - config.addDefault("Abilities.Earth.MetalClips.Description", "MetalClips has the potential to be both an offensive and a utility ability. To start, you must carry smelted Iron Ingots in your inventory. To apply the clips onto an entity, simply click at them. If the entity is a Zombie, a Skeleton, or a Player, the clips will form armor around the entity, giving you some control over them. Each additional clip will give you more control. If you have permission to do so, you may crush the entity against a wall with a 4th clip, hurting them. Without explicit permissions, you will only be able to strap three clips on your target. If the entity is not one of the above, the clip will simply do damage and fall to the ground, to be collected."); - config.addDefault("Abilities.Earth.MetalClips.Damage", 2); - config.addDefault("Abilities.Earth.MetalClips.DamageInterval", 500); - config.addDefault("Abilities.Earth.MetalClips.MagnetRange", 20); - config.addDefault("Abilities.Earth.MetalClips.MagnetPower", 0.6); - config.addDefault("Abilities.Earth.MetalClips.Cooldown", 1000); - config.addDefault("Abilities.Earth.MetalClips.Duration", 10000); - - - config.addDefault("Abilities.Earth.RaiseEarth.Enabled", true); - config.addDefault("Abilities.Earth.RaiseEarth.Description", "To use, simply left-click on an earthbendable block. " - + "A column of earth will shoot upwards from that location. " - + "Anything in the way of the column will be brought up with it, " - + "leaving talented benders the ability to trap brainless entities up there. " - + "Additionally, simply sneak (default shift) looking at an earthbendable block. " - + "A wall of earth will shoot upwards from that location. " - + "Anything in the way of the wall will be brought up with it. "); - config.addDefault("Abilities.Earth.RaiseEarth.Column.Height", 6); - config.addDefault("Abilities.Earth.RaiseEarth.Wall.Range", 15); - config.addDefault("Abilities.Earth.RaiseEarth.Wall.Height", 6); - config.addDefault("Abilities.Earth.RaiseEarth.Wall.Width", 6); - - config.addDefault("Abilities.Earth.Shockwave.Enabled", true); - config.addDefault("Abilities.Earth.Shockwave.Description", "This is one of the most powerful moves in the earthbender's arsenal. " - + "To use, you must first charge it by holding sneak (default: shift). " - + "Once charged, you can release sneak to create an enormous shockwave of earth, " - + "disturbing all earth around you and expanding radially outwards. " - + "Anything caught in the shockwave will be blasted back and dealt damage. " - + "If you instead click while charged, the disruption is focused in a cone in front of you. " - + "Lastly, if you fall from a great enough height with this ability selected, you will automatically create a shockwave."); - config.addDefault("Abilities.Earth.Shockwave.FallThreshold", 10); - config.addDefault("Abilities.Earth.Shockwave.ChargeTime", 2500); - config.addDefault("Abilities.Earth.Shockwave.Damage", 5); - config.addDefault("Abilities.Earth.Shockwave.Knockback", 1.1); - config.addDefault("Abilities.Earth.Shockwave.Range", 15); - - config.addDefault("Abilities.Earth.Tremorsense.Enabled", true); - config.addDefault("Abilities.Earth.Tremorsense.Description", "This is a pure utility ability for earthbenders. If you are in an area of low-light and are standing on top of an earthbendable block, this ability will automatically turn that block into glowstone, visible *only by you*. If you lose contact with a bendable block, the light will go out as you have lost contact with the earth and cannot 'see' until you can touch earth again. Additionally, if you click with this ability selected, smoke will appear above nearby earth with pockets of air beneath them."); - config.addDefault("Abilities.Earth.Tremorsense.MaxDepth", 10); - config.addDefault("Abilities.Earth.Tremorsense.Radius", 5); - config.addDefault("Abilities.Earth.Tremorsense.LightThreshold", 7); - config.addDefault("Abilities.Earth.Tremorsense.Cooldown", 1000); - - config.addDefault("Abilities.Fire.Blaze.Enabled", true); - config.addDefault("Abilities.Fire.Blaze.Description", "To use, simply left-click in any direction. An arc of fire will flow from your location, igniting anything in its path. Additionally, tap sneak to engulf the area around you in roaring flames."); - config.addDefault("Abilities.Fire.Blaze.ArcOfFire.Arc", 20); - config.addDefault("Abilities.Fire.Blaze.ArcOfFire.Range", 9); - config.addDefault("Abilities.Fire.Blaze.RingOfFire.Range", 7); - - config.addDefault("Abilities.Fire.Combustion.Enabled", true); - config.addDefault("Abilities.Fire.Combustion.Description", "Combustion is a powerful ability only known by a few skilled Firebenders. It allows the bender to Firebend with their mind, concentrating energy to create a powerful blast. To use, simply tap sneak (Default: Shift) to launch the blast. This technique is highly destructive and very effective, it also comes with a long cooldown."); - config.addDefault("Abilities.Fire.Combustion.Cooldown", 15000); - // config.addDefault("Abilities.Fire.Combustion.ChargeTime", 5000); - config.addDefault("Abilities.Fire.Combustion.BreakBlocks", false); - config.addDefault("Abilities.Fire.Combustion.Power", 1.0); - config.addDefault("Abilities.Fire.Combustion.Damage", 5); - config.addDefault("Abilities.Fire.Combustion.Radius", 4); - config.addDefault("Abilities.Fire.Combustion.Range", 20); - config.addDefault("Abilities.Fire.Combustion.Speed", 25); - - config.addDefault("Abilities.Fire.FireBlast.Enabled", true); - config.addDefault("Abilities.Fire.FireBlast.Description","FireBlast is the most fundamental bending technique of a firebender. " - + "To use, simply left-click in a direction. A blast of fire will be created at your fingertips. " - + "If this blast contacts an enemy, it will dissipate and engulf them in flames, " - + "doing additional damage and knocking them back slightly. " - + "If the blast hits terrain, it will ignite the nearby area. " - + "Additionally, if you hold sneak, you will charge up the fireblast. " - + "If you release it when it's charged, it will instead launch a powerful " - + "fireball that explodes on contact."); - config.addDefault("Abilities.Fire.FireBlast.Speed", 15); - config.addDefault("Abilities.Fire.FireBlast.Range", 15); - config.addDefault("Abilities.Fire.FireBlast.Radius", 2); - config.addDefault("Abilities.Fire.FireBlast.Push", 0.3); - config.addDefault("Abilities.Fire.FireBlast.Damage", 2); - config.addDefault("Abilities.Fire.FireBlast.Cooldown", 1500); - config.addDefault("Abilities.Fire.FireBlast.Dissipate", false); - config.addDefault("Abilities.Fire.FireBlast.Charged.ChargeTime", 2000); - config.addDefault("Abilities.Fire.FireBlast.Charged.Damage", 4); - config.addDefault("Abilities.Fire.FireBlast.Charged.DamageRadius", 6); - config.addDefault("Abilities.Fire.FireBlast.Charged.Power", 1); - config.addDefault("Abilities.Fire.FireBlast.Charged.Range", 20); - - config.addDefault("Abilities.Fire.FireBurst.Enabled", true); - config.addDefault("Abilities.Fire.FireBurst.Description", "FireBurst is a very powerful firebending ability. " - + "To use, press and hold sneak to charge your burst. " - + "Once charged, you can either release sneak to launch a cone-shaped burst " - + "of flames in front of you, or click to release the burst in a sphere around you. "); - config.addDefault("Abilities.Fire.FireBurst.Damage", 3); - config.addDefault("Abilities.Fire.FireBurst.ChargeTime", 2500); - config.addDefault("Abilities.Fire.FireBurst.Range", 15); - - config.addDefault("Abilities.Fire.FireJet.Enabled", true); - config.addDefault("Abilities.Fire.FireJet.Description", "This ability is used for a limited burst of flight for firebenders. Clicking with this " - + "ability selected will launch you in the direction you're looking, granting you " - + "controlled flight for a short time. This ability can be used mid-air to prevent falling " - + "to your death, but on the ground it can only be used if standing on a block that's " - + "ignitable (e.g. not snow or water)."); - config.addDefault("Abilities.Fire.FireJet.Speed", 0.7); - config.addDefault("Abilities.Fire.FireJet.Duration", 1500); - config.addDefault("Abilities.Fire.FireJet.Cooldown", 6000); - config.addDefault("Abilities.Fire.FireJet.IsAvatarStateToggle", true); - - config.addDefault("Abilities.Fire.FireShield.Enabled", true); - config.addDefault("Abilities.Fire.FireShield.Description", "FireShield is a basic defensive ability. " - + "Clicking with this ability selected will create a " - + "small disc of fire in front of you, which will block most " - + "attacks and bending. Alternatively, pressing and holding " - + "sneak creates a very small shield of fire, blocking most attacks. " - + "Creatures that contact this fire are ignited."); - config.addDefault("Abilities.Fire.FireShield.Radius", 3); - config.addDefault("Abilities.Fire.FireShield.DiscRadius", 1.5); - config.addDefault("Abilities.Fire.FireShield.Duration", 1000); - - config.addDefault("Abilities.Fire.HeatControl.Enabled", true); - config.addDefault("Abilities.Fire.HeatControl.Description", "While this ability is selected, the firebender becomes impervious " - + "to fire damage and cannot be ignited. " - + "If the user left-clicks with this ability, the targeted area will be " - + "extinguished, although it will leave any creature burning engulfed in flames. " - + "This ability can also cool lava. If this ability is used while targetting ice or snow, it" - + " will instead melt blocks in that area. Finally, sneaking with this ability will cook any food in your hand."); - config.addDefault("Abilities.Fire.HeatControl.Extinguish.Range", 20); - config.addDefault("Abilities.Fire.HeatControl.Extinguish.Radius", 7); - config.addDefault("Abilities.Fire.HeatControl.Solidify.Range", 10); - config.addDefault("Abilities.Fire.HeatControl.Solidify.Radius", 5); - config.addDefault("Abilities.Fire.HeatControl.Solidify.RevertTime", 20000); - config.addDefault("Abilities.Fire.HeatControl.Melt.Range", 15); - config.addDefault("Abilities.Fire.HeatControl.Melt.Radius", 5); - - config.addDefault("Abilities.Fire.Illumination.Enabled", true); - config.addDefault("Abilities.Fire.Illumination.Description", "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking " - + "will create a torch that follows you around. The torch will only appear on objects that are " - + "ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, " - + "it will disappear, but will reappear when you get on another ignitable block. Clicking again " - + "dismisses this torch."); - config.addDefault("Abilities.Fire.Illumination.Range", 5); - - config.addDefault("Abilities.Fire.Lightning.Enabled", true); - config.addDefault("Abilities.Fire.Lightning.Description", "Hold sneak while selecting this ability to charge up a lightning strike. Once charged, release sneak to discharge the lightning to the targeted location."); - config.addDefault("Abilities.Fire.Lightning.Damage", 6.0); - config.addDefault("Abilities.Fire.Lightning.Range", 13.0); - config.addDefault("Abilities.Fire.Lightning.ChargeTime", 3500); - config.addDefault("Abilities.Fire.Lightning.Cooldown", 0); - config.addDefault("Abilities.Fire.Lightning.StunChance", 0.20); - config.addDefault("Abilities.Fire.Lightning.StunDuration", 30.0); - config.addDefault("Abilities.Fire.Lightning.MaxArcAngle", 30); - config.addDefault("Abilities.Fire.Lightning.SubArcChance", 0.025); - config.addDefault("Abilities.Fire.Lightning.ChainArcRange", 6.0); - config.addDefault("Abilities.Fire.Lightning.ChainArcChance", 0.50); - config.addDefault("Abilities.Fire.Lightning.MaxChainArcs", 2); - config.addDefault("Abilities.Fire.Lightning.WaterArcs", 4); - config.addDefault("Abilities.Fire.Lightning.WaterArcRange", 12.0); - config.addDefault("Abilities.Fire.Lightning.SelfHitWater", true); - config.addDefault("Abilities.Fire.Lightning.SelfHitClose", true); - config.addDefault("Abilities.Fire.Lightning.ArcOnIce", false); - - - config.addDefault("Abilities.Fire.WallOfFire.Enabled", true); - config.addDefault("Abilities.Fire.WallOfFire.Description", "To use this ability, click at a location. A wall of fire will appear at this location, igniting enemies caught in it and blocking projectiles."); - config.addDefault("Abilities.Fire.WallOfFire.Range", 4); - config.addDefault("Abilities.Fire.WallOfFire.Height", 4); - config.addDefault("Abilities.Fire.WallOfFire.Width", 4); - config.addDefault("Abilities.Fire.WallOfFire.Duration", 5000); - config.addDefault("Abilities.Fire.WallOfFire.Damage", 2); - config.addDefault("Abilities.Fire.WallOfFire.Cooldown", 7500); - config.addDefault("Abilities.Fire.WallOfFire.Interval", 500); - - config.addDefault("Abilities.Fire.FireCombo.Enabled", true); - config.addDefault("Abilities.Fire.FireCombo.FireKick.Range", 7.0); - config.addDefault("Abilities.Fire.FireCombo.FireKick.Damage", 3.0); - config.addDefault("Abilities.Fire.FireCombo.FireKick.Cooldown", 2000); - config.addDefault("Abilities.Fire.FireCombo.FireSpin.Range", 7); - config.addDefault("Abilities.Fire.FireCombo.FireSpin.Damage", 3.0); - config.addDefault("Abilities.Fire.FireCombo.FireSpin.Knockback", 3.2); - config.addDefault("Abilities.Fire.FireCombo.FireSpin.Cooldown", 2000); - config.addDefault("Abilities.Fire.FireCombo.FireWheel.Range", 20.0); - config.addDefault("Abilities.Fire.FireCombo.FireWheel.Damage", 4.0); - config.addDefault("Abilities.Fire.FireCombo.FireWheel.Speed", 0.55); - config.addDefault("Abilities.Fire.FireCombo.FireWheel.Cooldown", 200); - config.addDefault("Abilities.Fire.FireCombo.JetBlast.Speed", 1.2); - config.addDefault("Abilities.Fire.FireCombo.JetBlast.Cooldown", 6000); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Speed", 1.1); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Damage", 3); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Cooldown", 6000); - - config.addDefault("Abilities.Chi.Passive.FallReductionFactor", 0.5); - config.addDefault("Abilities.Chi.Passive.Speed", 1); - config.addDefault("Abilities.Chi.Passive.Jump", 2); - config.addDefault("Abilities.Chi.Passive.BlockChi.Duration", 2500); - config.addDefault("Abilities.Chi.Passive.DodgeChange", 25); - - config.addDefault("Abilities.Chi.AcrobatStance.Enabled", true); - config.addDefault("Abilities.Chi.AcrobatStance.Description", "AcrobatStance gives a Chiblocker a higher probability of blocking a Bender's Chi while granting them a Speed and Jump Boost. It also increases the rate at which the hunger bar depletes. To use, simply left click. Left clicking again will de-activate the stance."); - config.addDefault("Abilities.Chi.ChiBlockBoost", 0.1); - - config.addDefault("Abilities.Chi.HighJump.Enabled", true); - config.addDefault("Abilities.Chi.HighJump.Description", "To use this ability, simply click. You will jump quite high. This ability has a short cooldown."); - config.addDefault("Abilities.Chi.HighJump.Height", 1); - config.addDefault("Abilities.Chi.HighJump.Cooldown", 10000); - - 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); - - config.addDefault("Abilities.Chi.RapidPunch.Enabled", true); - config.addDefault("Abilities.Chi.RapidPunch.Description", "This ability allows the chiblocker to punch rapidly in a short period. To use, simply punch. This has a short cooldown."); - config.addDefault("Abilities.Chi.RapidPunch.Damage", 1); - config.addDefault("Abilities.Chi.RapidPunch.Distance", 4); - config.addDefault("Abilities.Chi.RapidPunch.Cooldown", 15000); - config.addDefault("Abilities.Chi.RapidPunch.Punches", 4); - - config.addDefault("Abilities.Chi.Smokescreen.Enabled", true); - config.addDefault("Abilities.Chi.Smokescreen.Description", "Smokescren, if used correctly, can serve as a defensive and offensive ability for Chiblockers. To use, simply left click and you will toss out a Smoke Bomb. When the bomb hits the ground, it will explode and give all players within a small radius of the explosion temporary blindness, allowing you to either get away, or move in for the kill. This ability has a long cooldown."); - config.addDefault("Abilities.Chi.Smokescreen.Cooldown", 50000); - config.addDefault("Abilities.Chi.Smokescreen.Radius", 4); - config.addDefault("Abilities.Chi.Smokescreen.Duration", 15); - - config.addDefault("Abilities.Chi.WarriorStance.Enabled", true); - config.addDefault("Abilities.Chi.WarriorStance.Description", "WarriorStance gives a Chiblocker increased damage but makes them a tad more vulnerable. To activate, simply left click."); - config.addDefault("Abilities.Chi.WarriorStance.Strength", 1); - config.addDefault("Abilities.Chi.WarriorStance.Resistance", -1); - - config.addDefault("Abilities.Chi.QuickStrike.Enabled", true); - config.addDefault("Abilities.Chi.QuickStrike.Description", "QuickStrike enables a chiblocker to quickly strike an enemy, potentially blocking their chi."); - config.addDefault("Abilities.Chi.QuickStrike.Damage", 2); - config.addDefault("Abilities.Chi.QuickStrike.ChiBlockChance", 20); - - config.addDefault("Abilities.Chi.SwiftKick.Enabled", true); - config.addDefault("Abilities.Chi.SwiftKick.Description", "SwiftKick allows a chiblocker to swiftly kick an enemy, potentially blocking their chi. The chiblocker must be in the air to use this ability."); - config.addDefault("Abilities.Chi.SwiftKick.Damage", 4); - config.addDefault("Abilities.Chi.SwiftKick.ChiBlockChance", 30); - - config.addDefault("Abilities.Chi.ChiCombo.ParalyzeDuration", 10000); - - config.addDefault("Storage.engine", "sqlite"); - - config.addDefault("Storage.MySQL.host", "localhost"); - config.addDefault("Storage.MySQL.port", 3306); - config.addDefault("Storage.MySQL.pass", ""); - config.addDefault("Storage.MySQL.db", "minecraft"); - config.addDefault("Storage.MySQL.user", "root"); - - config.addDefault("debug", false); - config.options().copyDefaults(true); - plugin.saveConfig(); - } -} +package com.projectkorra.ProjectKorra; + +import java.util.ArrayList; + +import org.bukkit.configuration.file.FileConfiguration; + +public class ConfigManager { + + static ProjectKorra plugin; + + public ConfigManager(ProjectKorra plugin) { + ConfigManager.plugin = plugin; + configCheck(); + } + + public static void configCheck() { + + FileConfiguration config = ProjectKorra.plugin.getConfig(); + + ArrayList earthbendable = new ArrayList(); + earthbendable.add("STONE"); + earthbendable.add("CLAY"); + earthbendable.add("COAL_ORE"); + earthbendable.add("DIAMOND_ORE"); + earthbendable.add("DIRT"); + earthbendable.add("GOLD_ORE"); + earthbendable.add("GRASS"); + earthbendable.add("GRAVEL"); + earthbendable.add("IRON_ORE"); + earthbendable.add("LAPIS_ORE"); + earthbendable.add("NETHERRACK"); + earthbendable.add("REDSTONE_ORE"); + earthbendable.add("SAND"); + earthbendable.add("SANDSTONE"); + earthbendable.add("MYCEL"); + + ArrayList metals = new ArrayList(); + metals.add("IRON_BLOCK"); + metals.add("GOLD_BLOCK"); + metals.add("QUARTZ_BLOCK"); + + config.addDefault("Properties.Chat.Enable", true); + config.addDefault("Properties.Chat.Format", ": "); + config.addDefault("Properties.Chat.Prefixes.Air", "[Airbender]"); + config.addDefault("Properties.Chat.Prefixes.Water", "[Waterbender]"); + config.addDefault("Properties.Chat.Prefixes.Earth", "[Earthbender]"); + config.addDefault("Properties.Chat.Prefixes.Fire", "[Firebender]"); + config.addDefault("Properties.Chat.Prefixes.Chi", "[Chiblocker]"); + config.addDefault("Properties.Chat.Prefixes.Avatar", "[Avatar]"); + config.addDefault("Properties.Chat.Colors.Avatar", "DARK_PURPLE"); + config.addDefault("Properties.Chat.Colors.Air", "GRAY"); + config.addDefault("Properties.Chat.Colors.AirSub", "DARK_GRAY"); + config.addDefault("Properties.Chat.Colors.Water", "AQUA"); + config.addDefault("Properties.Chat.Colors.WaterSub", "DARK_AQUA"); + config.addDefault("Properties.Chat.Colors.Earth", "GREEN"); + config.addDefault("Properties.Chat.Colors.EarthSub", "DARK_GREEN"); + config.addDefault("Properties.Chat.Colors.Fire", "RED"); + config.addDefault("Properties.Chat.Colors.FireSub", "DARK_RED"); + config.addDefault("Properties.Chat.Colors.Chi", "GOLD"); + + config.addDefault("Properties.ImportEnabled", true); + config.addDefault("Properties.BendingAffectFallingSand.Normal", true); + config.addDefault("Properties.BendingAffectFallingSand.NormalStrengthMultiplier", 1.0); + config.addDefault("Properties.BendingAffectFallingSand.TNT", true); + config.addDefault("Properties.BendingAffectFallingSand.TNTStrengthMultiplier", 1.0); + config.addDefault("Properties.GlobalCooldown", 500); + config.addDefault("Properties.SeaLevel", 62); + + config.addDefault("Properties.HorizontalCollisionPhysics.Enabled", true); + config.addDefault("Properties.HorizontalCollisionPhysics.WallDamageMinimumDistance", 5.0); + + config.addDefault("Properties.CustomItems.GrapplingHook.Enable", true); + config.addDefault("Properties.CustomItems.GrapplingHook.IronUses", 25); + config.addDefault("Properties.CustomItems.GrapplingHook.GoldUses", 50); + + config.addDefault("Properties.RegionProtection.AllowHarmlessAbilities", true); + config.addDefault("Properties.RegionProtection.RespectWorldGuard", true); + config.addDefault("Properties.RegionProtection.RespectGriefPrevention", true); + config.addDefault("Properties.RegionProtection.RespectFactions", true); + config.addDefault("Properties.RegionProtection.RespectTowny", true); + config.addDefault("Properties.RegionProtection.RespectPreciousStones", true); + config.addDefault("Properties.RegionProtection.RespectLWC", true); + config.addDefault("Properties.RegionProtection.CacheBlockTime", 5000); + + config.addDefault("Properties.TagAPI.Enabled", true); + + config.addDefault("Properties.Air.CanBendWithWeapons", false); + config.addDefault("Properties.Air.Particles", "smoke"); + config.addDefault("Properties.Air.PlaySound", true); + + config.addDefault("Properties.Water.CanBendWithWeapons", true); + config.addDefault("Properties.Water.NightFactor", 1.5); + config.addDefault("Properties.Water.FullMoonFactor", 3.0); + config.addDefault("Properties.Water.CanBendPackedIce", true); + config.addDefault("Properties.Water.PlaySound", true); + + config.addDefault("Properties.Earth.RevertEarthbending", true); + config.addDefault("Properties.Earth.SafeRevert", true); + config.addDefault("Properties.Earth.RevertCheckTime", 300000); + config.addDefault("Properties.Earth.CanBendWithWeapons", true); + config.addDefault("Properties.Earth.EarthbendableBlocks", earthbendable); + config.addDefault("Properties.Earth.MetalBlocks", metals); + config.addDefault("Properties.Earth.MetalPowerFactor", 1.5); + config.addDefault("Properties.Earth.PlaySound", true); + + config.addDefault("Properties.Fire.CanBendWithWeapons", true); + config.addDefault("Properties.Fire.DayFactor", 1.5); + config.addDefault("Properties.Fire.PlaySound", true); + + config.addDefault("Properties.Chi.CanBendWithWeapons", true); + + ArrayList disabledWorlds = new ArrayList(); + disabledWorlds.add("TestWorld"); + disabledWorlds.add("TestWorld2"); + config.addDefault("Properties.DisabledWorlds", disabledWorlds); + + config.addDefault("Abilities.AvatarState.Enabled", true); + config.addDefault("Abilities.AvatarState.Description", "The signature ability of the Avatar, this is a toggle. Click to activate to become " + + "nearly unstoppable. While in the Avatar State, the user takes severely reduced damage from " + + "all sources, regenerates health rapidly, and is granted extreme speed. Nearly all abilities " + + "are incredibly amplified in this state. Additionally, AirShield and FireJet become toggle-able " + + "abilities and last until you deactivate them or the Avatar State. Click again with the Avatar " + + "State selected to deactivate it."); + config.addDefault("Abilities.AvatarState.Cooldown", 7200000); + config.addDefault("Abilities.AvatarState.Duration", 480000); + config.addDefault("Abilities.AvatarState.PowerMultiplier", 5); + config.addDefault("Abilities.AvatarState.PotionEffects.Regeneration.Enabled", true); + config.addDefault("Abilities.AvatarState.PotionEffects.Regeneration.Power", 3); + config.addDefault("Abilities.AvatarState.PotionEffects.Speed.Enabled", true); + config.addDefault("Abilities.AvatarState.PotionEffects.Speed.Power", 3); + config.addDefault("Abilities.AvatarState.PotionEffects.DamageResistance.Enabled", true); + config.addDefault("Abilities.AvatarState.PotionEffects.FireResistance.Enabled", true); + config.addDefault("Abilities.AvatarState.PotionEffects.FireResistance.Power", 3); + + config.addDefault("Abilities.Air.Passive.Factor", 0.3); + config.addDefault("Abilities.Air.Passive.Speed", 2); + config.addDefault("Abilities.Air.Passive.Jump", 3); + + config.addDefault("Abilities.Air.AirBlast.Enabled", true); + config.addDefault("Abilities.Air.AirBlast.Description", "AirBlast is the most fundamental bending technique of an airbender." + + " To use, simply left-click in a direction. A gust of wind will be" + + " created at your fingertips, launching anything in its path harmlessly back." + + " A gust of air can extinguish fires on the ground or on a player, can cool lava, and " + + "can flip levers and activate buttons. Additionally, tapping sneak will change the " + + "origin of your next AirBlast to your targeted location."); + config.addDefault("Abilities.Air.AirBlast.Speed", 25); + config.addDefault("Abilities.Air.AirBlast.Range", 20); + config.addDefault("Abilities.Air.AirBlast.Radius", 2); + config.addDefault("Abilities.Air.AirBlast.Push", 3.5); + + config.addDefault("Abilities.Air.AirBubble.Enabled", true); + config.addDefault("Abilities.Air.AirBubble.Description", "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."); + config.addDefault("Abilities.Air.AirBubble.Radius", 7); + + config.addDefault("Abilities.Air.AirBurst.Enabled", true); + config.addDefault("Abilities.Air.AirBurst.Description", "AirBurst is one of the most powerful abilities in the airbender's arsenal. " + + "To use, press and hold sneak to charge your burst. " + + "Once charged, you can either release sneak to launch a cone-shaped burst " + + "of air in front of you, or click to release the burst in a sphere around you. " + + "Additionally, having this ability selected when you land on the ground from a " + + "large enough fall will create a burst of air around you."); + config.addDefault("Abilities.Air.AirBurst.FallThreshold", 10); + config.addDefault("Abilities.Air.AirBurst.PushFactor", 1.5); + config.addDefault("Abilities.Air.AirBurst.ChargeTime", 1750); + config.addDefault("Abilities.Air.AirBurst.Damage", 0); + + config.addDefault("Abilities.Air.AirScooter.Enabled", true); + config.addDefault("Abilities.Air.AirScooter.Description", "AirScooter is a fast means of transportation. To use, sprint, jump then click with " + + "this ability selected. You will hop on a scooter of air and be propelled forward " + + "in the direction you're looking (you don't need to press anything). " + + "This ability can be used to levitate above liquids, but it cannot go up steep slopes. " + + "Any other actions will deactivate this ability."); + config.addDefault("Abilities.Air.AirScooter.Speed", .675); + + config.addDefault("Abilities.Air.Tornado.Enabled", true); + config.addDefault("Abilities.Air.Tornado.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 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's looking. Skilled airbenders can scale anything " + + "with this ability."); + + config.addDefault("Abilities.Air.AirShield.Enabled", true); + config.addDefault("Abilities.Air.AirShield.Description", "Air Shield is one of the most powerful defensive techniques in existence. " + + "To use, simply sneak (default: shift). " + + "This will create a whirlwind of air around the user, " + + "with a small pocket of safe space in the center. " + + "This wind will deflect all projectiles and will prevent any creature from " + + "entering it for as long as its maintained."); + config.addDefault("Abilities.Air.AirShield.Radius", 7); + config.addDefault("Abilities.Air.AirShield.IsAvatarStateToggle", true); + + config.addDefault("Abilities.Air.AirSpout.Enabled", true); + config.addDefault("Abilities.Air.AirSpout.Description", "This ability gives the airbender limited sustained levitation. It is a " + + "toggle - click to activate and form a whirling spout of air " + + "beneath you, lifting you up. You can bend other abilities while using AirSpout. " + + "Click again to deactivate this ability."); + config.addDefault("Abilities.Air.AirSpout.Height", 20); + + config.addDefault("Abilities.Air.AirSuction.Enabled", true); + config.addDefault("Abilities.Air.AirSuction.Description", "To use, simply left-click in a direction. A gust of wind will originate as far as it can in that direction and flow towards you, sucking anything in its path harmlessly with it. Skilled benders can use this technique to pull items from precarious locations. Additionally, tapping sneak will change the origin of your next AirSuction to your targeted location."); + config.addDefault("Abilities.Air.AirSuction.Speed", 25); + config.addDefault("Abilities.Air.AirSuction.Range", 20); + config.addDefault("Abilities.Air.AirSuction.Radius", 2); + config.addDefault("Abilities.Air.AirSuction.Push", 3.5); + + config.addDefault("Abilities.Air.AirSwipe.Enabled", true); + config.addDefault("Abilities.Air.AirSwipe.Description", "To use, simply left-click in a direction. An arc of air will flow from you towards that direction, cutting and pushing back anything in its path. Its damage is minimal, but it still sends the message. This ability will extinguish fires, cool lava, and cut things like grass, mushrooms, and flowers. Additionally, you can charge it by holding sneak. Charging before attacking will increase damage and knockback, up to a maximum."); + config.addDefault("Abilities.Air.AirSwipe.Damage", 2); + config.addDefault("Abilities.Air.AirSwipe.Range", 16); + config.addDefault("Abilities.Air.AirSwipe.Radius", 2); + config.addDefault("Abilities.Air.AirSwipe.Push", 1); + config.addDefault("Abilities.Air.AirSwipe.Arc", 20); + config.addDefault("Abilities.Air.AirSwipe.Speed", 25); + config.addDefault("Abilities.Air.AirSwipe.Cooldown", 1500); + config.addDefault("Abilities.Air.AirSwipe.ChargeFactor", 3); + config.addDefault("Abilities.Air.AirSwipe.MaxChargeTime", 3000); + + config.addDefault("Abilities.Air.Flight.Enabled", true); + config.addDefault("Abilities.Air.Flight.Description", "Jump in the air, crouch (default: shift) and hold with this ability bound and you will glide around in the direction you look. While flying, click to Hover. Click again to disable Hovering."); + config.addDefault("Abilities.Air.Flight.HoverEnabled", true); + + config.addDefault("Abilities.Air.Suffocate.Enabled", true); + config.addDefault("Abilities.Air.Suffocate.Description", "This ability is one of the most dangerous abilities an Airbender possesses. To use, simply look at an entity and hold shift. The entity will begin taking damage as you extract the air from their lungs. Any bender caught in this sphere will only be able to use basic moves, such as AirSwipe, WaterManipulation, FireBlast, or EarthBlast. An entity can be knocked out of the sphere by certain bending arts, and your attention will be disrupted if you are hit by bending."); + config.addDefault("Abilities.Air.Suffocate.ChargeTime", 1000); + config.addDefault("Abilities.Air.Suffocate.Cooldown", 0); + config.addDefault("Abilities.Air.Suffocate.Range", 15); + config.addDefault("Abilities.Air.Suffocate.Damage", 2); + config.addDefault("Abilities.Air.Suffocate.DamageInitialDelay", 2); + config.addDefault("Abilities.Air.Suffocate.DamageInterval", 1); + config.addDefault("Abilities.Air.Suffocate.SlowPotency", 1); + config.addDefault("Abilities.Air.Suffocate.SlowDelay", 0.5); + config.addDefault("Abilities.Air.Suffocate.SlowInterval", 1.25); + config.addDefault("Abilities.Air.Suffocate.BlindPotentcy", 30); + config.addDefault("Abilities.Air.Suffocate.BlindDelay", 2); + config.addDefault("Abilities.Air.Suffocate.BlindInterval", 1.5); + config.addDefault("Abilities.Air.Suffocate.CanBeUsedOnUndeadMobs", true); + config.addDefault("Abilities.Air.Suffocate.RequireConstantAim", true); + config.addDefault("Abilities.Air.Suffocate.RequireConstantAimRadius", 5); + config.addDefault("Abilities.Air.Suffocate.AnimationRadius", 2.0); + config.addDefault("Abilities.Air.Suffocate.AnimationParticleAmount", 2); + config.addDefault("Abilities.Air.Suffocate.AnimationSpeed", 1.0); + + config.addDefault("Abilities.Air.Tornado.Radius", 10); + config.addDefault("Abilities.Air.Tornado.Height", 25); + config.addDefault("Abilities.Air.Tornado.Range", 25); + config.addDefault("Abilities.Air.Tornado.MobPushFactor", 1); + config.addDefault("Abilities.Air.Tornado.PlayerPushFactor", 1); + + config.addDefault("Abilities.Air.AirCombo.Enabled", true); + config.addDefault("Abilities.Air.AirCombo.Twister.Speed", 0.35); + config.addDefault("Abilities.Air.AirCombo.Twister.Range", 16); + config.addDefault("Abilities.Air.AirCombo.Twister.Height", 8); + config.addDefault("Abilities.Air.AirCombo.Twister.Radius", 3.5); + config.addDefault("Abilities.Air.AirCombo.Twister.RemoveDelay", 1500); + config.addDefault("Abilities.Air.AirCombo.Twister.Cooldown", 10000); + config.addDefault("Abilities.Air.AirCombo.Twister.DegreesPerParticle", 7); + config.addDefault("Abilities.Air.AirCombo.Twister.HeightPerParticle", 1.25); + config.addDefault("Abilities.Air.AirCombo.AirStream.Speed", 0.5); + config.addDefault("Abilities.Air.AirCombo.AirStream.Range", 40); + config.addDefault("Abilities.Air.AirCombo.AirStream.EntityDuration", 4000); + config.addDefault("Abilities.Air.AirCombo.AirStream.EntityHeight", 14); + config.addDefault("Abilities.Air.AirCombo.AirStream.Cooldown", 6000); + config.addDefault("Abilities.Air.AirCombo.AirSweep.Speed", 1.4); + config.addDefault("Abilities.Air.AirCombo.AirSweep.Range", 14); + config.addDefault("Abilities.Air.AirCombo.AirSweep.Damage", 4); + config.addDefault("Abilities.Air.AirCombo.AirSweep.Knockback", 3.5); + config.addDefault("Abilities.Air.AirCombo.AirSweep.Cooldown", 5000); + + config.addDefault("Abilities.Water.Passive.SwimSpeedFactor", 0.7); + + config.addDefault("Abilities.Water.Bloodbending.Enabled", true); + config.addDefault("Abilities.Water.Bloodbending.Description", "This ability was made illegal for a reason. With this ability selected, sneak while " + + "targetting something and you will bloodbend that target. Bloodbent targets cannot move, " + + "bend or attack. You are free to control their actions by looking elsewhere - they will " + + "be forced to move in that direction. Additionally, clicking while bloodbending will " + + "launch that target off in the direction you're looking. " + + "People who are capable of bloodbending are immune to your technique, and you are immune to theirs."); + config.addDefault("Abilities.Water.Bloodbending.CanOnlyBeUsedAtNight", false); + config.addDefault("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs", true); + config.addDefault("Abilities.Water.Bloodbending.ThrowFactor", 2); + config.addDefault("Abilities.Water.Bloodbending.Range", 10); + config.addDefault("Abilities.Water.Bloodbending.HoldTime", 0); + config.addDefault("Abilities.Water.Bloodbending.Cooldown", 0); + config.addDefault("Abilities.Water.Bloodbending.CanOnlyBeUsedDuringFullMoon", false); + + config.addDefault("Abilities.Water.HealingWaters.Enabled", true); + config.addDefault("Abilities.Water.HealingWaters.Description", "To use, the bender must be at least partially submerged in water. " + + "If the user is not sneaking, this ability will automatically begin " + + "working provided the user has it selected. If the user is sneaking, " + + "he/she is channeling the healing to their target in front of them. " + + "In order for this channel to be successful, the user and the target must " + + "be at least partially submerged in water."); + config.addDefault("Abilities.Water.HealingWaters.Radius", 5); + config.addDefault("Abilities.Water.HealingWaters.Interval", 750); + config.addDefault("Abilities.Water.HealingWaters.Power", 1); + + config.addDefault("Abilities.Water.IceBlast.Enabled", true); + config.addDefault("Abilities.Water.IceBlast.Damage", 3); + config.addDefault("Abilities.Water.IceBlast.Range", 20); + config.addDefault("Abilities.Water.IceBlast.Description", "This ability offers a powerful ice utility for Waterbenders. It can be used to fire an explosive burst of ice at an opponent, spraying ice and snow around it. To use, simply tap sneak (Default: Shift) while targeting a block of ice to select it as a source. From there, you can just left click to send the blast off at your opponent."); + + config.addDefault("Abilities.Water.IceSpike.Enabled", true); + config.addDefault("Abilities.Water.IceSpike.Description", "This ability has many functions. Clicking while targetting ice, or an entity over some ice, " + + "will raise a spike of ice up, damaging and slowing the target. Tapping sneak (shift) while" + + " selecting a water source will select that source that can then be fired with a click. Firing" + + " this will launch a spike of ice at your target, dealing a bit of damage and slowing the target. " + + "If you sneak (shift) while not selecting a source, many ice spikes will erupt from around you, " + + "damaging and slowing those targets."); + config.addDefault("Abilities.Water.IceSpike.Cooldown", 2000); + config.addDefault("Abilities.Water.IceSpike.Damage", 2); + config.addDefault("Abilities.Water.IceSpike.Range", 20); + config.addDefault("Abilities.Water.IceSpike.ThrowingMult", 0.7); + config.addDefault("Abilities.Water.IceSpike.Height", 6); + config.addDefault("Abilities.Water.IceSpike.Projectile.Range", 20); + config.addDefault("Abilities.Water.IceSpike.Projectile.Damage", 1); + + config.addDefault("Abilities.Water.OctopusForm.Enabled", true); + config.addDefault("Abilities.Water.OctopusForm.Description", "This ability allows the waterbender to manipulate a large quantity of water into a form resembling that of an octopus. " + + "To use, click to select a water source. Then, hold sneak to channel this ability. " + + "While channeling, the water will form itself around you and has a chance to block incoming attacks. " + + "Additionally, you can click while channeling to attack things near you, dealing damage and knocking them back. " + + "Releasing shift at any time will dissipate the form."); + config.addDefault("Abilities.Water.OctopusForm.Range", 10); + config.addDefault("Abilities.Water.OctopusForm.AttackRange", 2.5); + config.addDefault("Abilities.Water.OctopusForm.Radius", 3); + config.addDefault("Abilities.Water.OctopusForm.Damage", 3); + config.addDefault("Abilities.Water.OctopusForm.Knockback", 1.75); + config.addDefault("Abilities.Water.OctopusForm.FormDelay", 50); + + config.addDefault("Abilities.Water.PhaseChange.Enabled", true); + config.addDefault("Abilities.Water.PhaseChange.Description", "To use, simply left-click. " + + "Any water you are looking at within range will instantly freeze over into solid ice. " + + "Provided you stay within range of the ice and do not unbind FreezeMelt, " + + "that ice will not thaw. If, however, you do either of those the ice will instantly thaw. " + + "If you sneak (default: shift), anything around where you are looking at will instantly melt. " + + "Since this is a more favorable state for these things, they will never re-freeze unless they " + + "would otherwise by nature or some other bending ability. Additionally, if you tap sneak while " + + "targetting water with FreezeMelt, it will evaporate water around that block that is above " + + "sea level. "); + config.addDefault("Abilities.Water.PhaseChange.Range", 20); + config.addDefault("Abilities.Water.PhaseChange.Radius", 5); + + config.addDefault("Abilities.Water.Surge.Enabled", true); + config.addDefault("Abilities.Water.Surge.Description", "This ability has two distinct features. If you sneak to select a source block, you can then click in a direction and a large wave will be launched in that direction. If you sneak again while the wave is en route, the wave will freeze the next target it hits. If, instead, you click to select a source block, you can hold sneak to form a wall of water at your cursor location. Click to shift between a water wall and an ice wall. Release sneak to dissipate it."); + config.addDefault("Abilities.Water.Surge.Wave.Radius", 3); + config.addDefault("Abilities.Water.Surge.Wave.Range", 20); + config.addDefault("Abilities.Water.Surge.Wave.HorizontalPush", 1); + config.addDefault("Abilities.Water.Surge.VerticalPush", 0.2); + config.addDefault("Abilities.Water.Surge.Wall.Range", 5); + config.addDefault("Abilities.Water.Surge.Wall.Radius", 2); + + config.addDefault("Abilities.Water.Torrent.Enabled", true); + config.addDefault("Abilities.Water.Torrent.Description", "Torrent is one of the strongest moves in a waterbender's arsenal. To use, first click a source block to select it; then hold shift to begin streaming the water around you. Water flowing around you this way will damage and knock back nearby enemies and projectiles. If you release shift during this, you will create a large wave that expands outwards from you, launching anything in its path back. Instead, if you click you release the water and channel it to flow towards your cursor. Anything caught in the blast will be tossed about violently and take damage. Finally, if you click again when the water is torrenting, it will freeze the area around it when it is obstructed."); + config.addDefault("Abilities.Water.Torrent.Range", 25); + config.addDefault("Abilities.Water.Torrent.DeflectDamage", 1); + config.addDefault("Abilities.Water.Torrent.Damage", 2); + config.addDefault("Abilities.Water.Torrent.Wave.Radius", 15); + config.addDefault("Abilities.Water.Torrent.Wave.Knockback", 1.5); + config.addDefault("Abilities.Water.Torrent.Wave.Height", 1); + + config.addDefault("Abilities.Water.Plantbending.RegrowTime", 180000); + + config.addDefault("Abilities.Water.WaterArms.Enabled", true); + config.addDefault("Abilities.Water.WaterArms.Description", "One of the most diverse moves in a waterbenders arsenal, this move creates tendrils " + + "of water from the players arms to emulate their actual arms. Each water arms mode will be binded to a slot, switch slots to change mode. " + + "To deactive the arms, hold Sneak and Double Left-Click. Tapping Sneak will tell you what mode you currently have active! " + + "Pull: Pulls entities and blocks towards the player! " + + "Punch: Damages entities and knocks them back! " + + "Grapple: Pull yourself towards blocks like a grappling hook! " + + "Freeze: Shoot blocks from your arms like mini ice blasts! " + + "Spear: Shoot your arms to create spears through the air, and capturing anything it hits!"); + + config.addDefault("Abilities.Water.WaterArms.Arms.InitialLength", 4); + config.addDefault("Abilities.Water.WaterArms.Arms.SourceGrabRange", 4); + config.addDefault("Abilities.Water.WaterArms.Arms.MaxAttacks", 10); + config.addDefault("Abilities.Water.WaterArms.Arms.MaxAlternateUsage", 50); + config.addDefault("Abilities.Water.WaterArms.Arms.MaxIceShots", 5); + config.addDefault("Abilities.Water.WaterArms.Arms.Cooldown", 20000); + config.addDefault("Abilities.Water.WaterArms.Arms.AllowSpectatorUse", false); + config.addDefault("Abilities.Water.WaterArms.Arms.AllowPlantSource", true); + + config.addDefault("Abilities.Water.WaterArms.Arms.Lightning.Enabled", true); + config.addDefault("Abilities.Water.WaterArms.Arms.Lightning.Damage", Double.valueOf(10.0)); + config.addDefault("Abilities.Water.WaterArms.Arms.Lightning.KillUser", false); + + config.addDefault("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldownEnabled", false); + config.addDefault("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown", 200); + + config.addDefault("Abilities.Water.WaterArms.WhipMode.MaxLength", 20); + config.addDefault("Abilities.Water.WaterArms.WhipMode.MaxLengthWeak", 12); + + config.addDefault("Abilities.Water.WaterArms.WhipMode.NightAugments.MaxLength.Normal", 24); + config.addDefault("Abilities.Water.WaterArms.WhipMode.NightAugments.MaxLength.FullMoon", 30); + + config.addDefault("Abilities.Water.WaterArms.WhipMode.Pull.PullBlocks", true); + config.addDefault("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamage", Double.valueOf(2.0)); + config.addDefault("Abilities.Water.WaterArms.WhipMode.Pull.BlockRevertDelay", 20000); + config.addDefault("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamageUser", false); + + config.addDefault("Abilities.Water.WaterArms.WhipMode.Punch.PunchDamage", Double.valueOf(3.0)); + + config.addDefault("Abilities.Water.WaterArms.WhipMode.Grapple.GrappleBarriers", false); + config.addDefault("Abilities.Water.WaterArms.WhipMode.Grapple.RespectRegions", false); + + config.addDefault("Abilities.Water.WaterArms.IceMode.Range", 20); + config.addDefault("Abilities.Water.WaterArms.IceMode.Damage", Double.valueOf(2.0)); + + config.addDefault("Abilities.Water.WaterArms.SpearMode.Range", 40); + config.addDefault("Abilities.Water.WaterArms.SpearMode.Damage", Double.valueOf(4.0)); + config.addDefault("Abilities.Water.WaterArms.SpearMode.DamageEnabled", true); + config.addDefault("Abilities.Water.WaterArms.SpearMode.Sphere", 2); + config.addDefault("Abilities.Water.WaterArms.SpearMode.Duration", 6000); + config.addDefault("Abilities.Water.WaterArms.SpearMode.Length", 18); + + config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Range.Normal", 45); + config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Range.FullMoon", 60); + config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Sphere.Normal", 3); + config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Sphere.FullMoon", 6); + config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Duration.Normal", 7000); + config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Duration.FullMoon", 12000); + + config.addDefault("Abilities.Water.WaterBubble.Enabled", true); + config.addDefault("Abilities.Water.WaterBubble.Description","To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."); + config.addDefault("Abilities.Water.WaterBubble.Radius", 7); + + config.addDefault("Abilities.Water.WaterManipulation.Enabled", true); + config.addDefault("Abilities.Water.WaterManipulation.Description", "To use, place your cursor over a waterbendable object and tap sneak (default: shift). Smoke will appear where you've selected, indicating the origin of your ability. After you have selected an origin, simply left-click in any direction and you will see your water spout off in that direction, slicing any creature in its path. If you look towards a creature when you use this ability, it will target that creature. A collision from Water Manipulation both knocks the target back and deals some damage. Alternatively, if you have the source selected and tap shift again, you will be able to control the water more directly."); + config.addDefault("Abilities.Water.WaterManipulation.Damage", 3.0); + config.addDefault("Abilities.Water.WaterManipulation.Range", 20); + config.addDefault("Abilities.Water.WaterManipulation.Speed", 35); + config.addDefault("Abilities.Water.WaterManipulation.Push", 0.3); + config.addDefault("Abilities.Water.WaterManipulation.Cooldown", 1000); + + config.addDefault("Abilities.Water.WaterSpout.Enabled", true); + config.addDefault("Abilities.Water.WaterSpout.Description", "This ability provides a Waterbender with a means of transportation. To use, simply left click while in or over water to spout water up beneath you, experiencing controlled levitation. Left clicking again while the spout is active will cause it to disappear. Alternatively, tapping a Waterbendable block while not in Water will select a water block as a source, from there, you can tap sneak (Default:Shift) to channel the Water around you. Releasing the sneak will create a wave allowing you a quick burst of controlled transportation. While riding the wave you may press sneak to cause the wave to disappear."); + config.addDefault("Abilities.Water.WaterSpout.Height", 20); + config.addDefault("Abilities.Water.WaterSpout.Wave.Particles", false); + config.addDefault("Abilities.Water.WaterSpout.Wave.Enabled", true); + config.addDefault("Abilities.Water.WaterSpout.Wave.Range", 6); + config.addDefault("Abilities.Water.WaterSpout.Wave.ChargeTime", 1000); + config.addDefault("Abilities.Water.WaterSpout.Wave.FlightTime", 2000); + config.addDefault("Abilities.Water.WaterSpout.Wave.Speed", 1.2); + + config.addDefault("Abilities.Water.WaterCombo.Enabled", true); + config.addDefault("Abilities.Water.WaterCombo.IceWave.Damage", 3); + config.addDefault("Abilities.Water.WaterCombo.IceWave.Cooldown", 6000); + config.addDefault("Abilities.Water.WaterCombo.IceBullet.Damage", 1.5); + config.addDefault("Abilities.Water.WaterCombo.IceBullet.Radius", 2.5); + config.addDefault("Abilities.Water.WaterCombo.IceBullet.Range", 12); + config.addDefault("Abilities.Water.WaterCombo.IceBullet.MaxShots", 30); + config.addDefault("Abilities.Water.WaterCombo.IceBullet.AnimationSpeed", 1); + config.addDefault("Abilities.Water.WaterCombo.IceBullet.ShootTime", 5000); + config.addDefault("Abilities.Water.WaterCombo.IceBullet.Cooldown", 10000); + + config.addDefault("Abilities.Earth.Passive.Duration", 2500); + + config.addDefault("Abilities.Earth.Catapult.Enabled", true); + config.addDefault("Abilities.Earth.Catapult.Description", "To use, left-click while looking in the direction you want to be launched. " + + "A pillar of earth will jut up from under you and launch you in that direction - " + + "if and only if there is enough earth behind where you're looking to launch you. " + + "Skillful use of this ability takes much time and work, and it does result in the " + + "death of certain gung-ho earthbenders. If you plan to use this ability, be sure " + + "you've read about your passive ability you innately have as an earthbender."); + config.addDefault("Abilities.Earth.Catapult.Length", 7); + config.addDefault("Abilities.Earth.Catapult.Speed", 12); + config.addDefault("Abilities.Earth.Catapult.Push", 5); + + config.addDefault("Abilities.Earth.Collapse.Enabled", true); + config.addDefault("Abilities.Earth.Collapse.Description", " To use, simply left-click on an earthbendable block. " + + "That block and the earthbendable blocks above it will be shoved " + + "back into the earth below them, if they can. " + + "This ability does have the capacity to trap something inside of it, " + + "although it is incredibly difficult to do so. " + + "Additionally, press sneak with this ability to affect an area around your targetted location - " + + "all earth that can be moved downwards will be moved downwards. " + + "This ability is especially risky or deadly in caves, depending on the " + + "earthbender's goal and technique."); + config.addDefault("Abilities.Earth.Collapse.Range", 20); + config.addDefault("Abilities.Earth.Collapse.Radius", 7); + config.addDefault("Abilities.Earth.Collapse.Speed", 8); + + config.addDefault("Abilities.Earth.EarthArmor.Enabled", true); + config.addDefault("Abilities.Earth.EarthArmor.Description", "This ability encases the earthbender in temporary armor. To use, click on a block that is earthbendable. If there is another block under it that is earthbendable, the block will fly to you and grant you temporary armor and damage reduction. This ability has a long cooldown."); + config.addDefault("Abilities.Earth.EarthArmor.Duration", 10000); + config.addDefault("Abilities.Earth.EarthArmor.Strength", 2); + config.addDefault("Abilities.Earth.EarthArmor.Duration", 17500); + + config.addDefault("Abilities.Earth.EarthBlast.Enabled", true); + config.addDefault("Abilities.Earth.EarthBlast.Description", "To use, place your cursor over an earthbendable object (dirt, rock, ores, etc) " + + "and tap sneak (default: shift). The object will temporarily turn to stone, " + + "indicating that you have it focused as the source for your ability. " + + "After you have selected an origin (you no longer need to be sneaking), " + + "simply left-click in any direction and you will see your object launch " + + "off in that direction, smashing into any creature in its path. If you look " + + "towards a creature when you use this ability, it will target that creature. " + + "A collision from Earth Blast both knocks the target back and deals some damage. " + + "You cannot have multiple of these abilities flying at the same time."); + config.addDefault("Abilities.Earth.EarthBlast.CanHitSelf", false); + config.addDefault("Abilities.Earth.EarthBlast.PrepareRange", 7); + config.addDefault("Abilities.Earth.EarthBlast.Range", 20); + config.addDefault("Abilities.Earth.EarthBlast.Speed", 35); + config.addDefault("Abilities.Earth.EarthBlast.Revert", true); + config.addDefault("Abilities.Earth.Earthblast.Damage", 4); + config.addDefault("Abilities.Earth.EarthBlast.Push", 0.3); + + config.addDefault("Abilities.Earth.EarthGrab.Enabled", true); + config.addDefault("Abilities.Earth.EarthGrab.Description", "To use, simply left-click while targeting a creature within range. " + + "This ability will erect a circle of earth to trap the creature in."); + config.addDefault("Abilities.Earth.EarthGrab.Range", 15); + + config.addDefault("Abilities.Earth.EarthTunnel.Enabled", true); + config.addDefault("Abilities.Earth.EarthTunnel.Description", "Earth Tunnel is a completely utility ability for earthbenders. To use, simply sneak (default: shift) in the direction you want to tunnel. You will slowly begin tunneling in the direction you're facing for as long as you sneak or if the tunnel has been dug long enough. This ability will be interrupted if it hits a block that cannot be earthbent."); + config.addDefault("Abilities.Earth.EarthTunnel.MaxRadius", 1); + config.addDefault("Abilities.Earth.EarthTunnel.Range", 10); + config.addDefault("Abilities.Earth.EarthTunnel.Radius", 0.25); + config.addDefault("Abilities.Earth.EarthTunnel.Revert", true); + config.addDefault("Abilities.Earth.EarthTunnel.Interval", 30); + + config.addDefault("Abilities.Earth.Extraction.Enabled", true); + config.addDefault("Abilities.Earth.Extraction.Description", "This ability allows metalbenders to extract the minerals from ore blocks. To use, simply tap sneak while looking at an ore block with metal in it (iron, gold, quartz) and the ore will be extracted and drop in front of you. This ability has a small chance of doubling or tripling the loot. This ability has a short cooldown."); + config.addDefault("Abilities.Earth.Extraction.Cooldown", 10000); + config.addDefault("Abilities.Earth.Extraction.TripleLootChance", 15); + config.addDefault("Abilities.Earth.Extraction.DoubleLootChance", 40); + + config.addDefault("Abilities.Earth.LavaFlow.Enabled", true); + config.addDefault("Abilities.Earth.LavaFlow.Description", "This ability allows an Earthbender to create lava using the Earth around them. To use, simply hold sneak (Default: Shift) to create a lava moat that surrounds you, press sneak again to remove the moat. Left click an Earthbendable block to create a pool of lava after a small delay. Additionally, you can left click at any time to turn lava back into its original state -- Earth."); + config.addDefault("Abilities.Earth.LavaFlow.ShiftCooldown", 16000); + config.addDefault("Abilities.Earth.LavaFlow.ClickLavaCooldown", 10000); + config.addDefault("Abilities.Earth.LavaFlow.ClickLandCooldown", 500); + config.addDefault("Abilities.Earth.LavaFlow.ShiftCleanupDelay", 10000); + config.addDefault("Abilities.Earth.LavaFlow.ClickLavaCleanupDelay", 7000); + config.addDefault("Abilities.Earth.LavaFlow.ClickLandCleanupDelay", 20000); + config.addDefault("Abilities.Earth.LavaFlow.ClickRange", 10.0); + config.addDefault("Abilities.Earth.LavaFlow.ShiftRadius", 8.0); + config.addDefault("Abilities.Earth.LavaFlow.ShiftPlatformRadius", 1.5); + config.addDefault("Abilities.Earth.LavaFlow.ClickRadius", 5.0); + config.addDefault("Abilities.Earth.LavaFlow.ClickLavaCreateSpeed", 0.05); + config.addDefault("Abilities.Earth.LavaFlow.ClickLandCreateSpeed", 0.10); + config.addDefault("Abilities.Earth.LavaFlow.ShiftFlowSpeed", 0.1); + config.addDefault("Abilities.Earth.LavaFlow.ShiftRemoveSpeed", 3.0); + config.addDefault("Abilities.Earth.LavaFlow.ClickLavaStartDelay", 1500); + config.addDefault("Abilities.Earth.LavaFlow.ClickLandStartDelay", 0); + config.addDefault("Abilities.Earth.LavaFlow.UpwardFlow", 2); + config.addDefault("Abilities.Earth.LavaFlow.DownwardFlow", 4); + config.addDefault("Abilities.Earth.LavaFlow.AllowNaturalFlow", false); + config.addDefault("Abilities.Earth.LavaFlow.ParticleDensity", 0.33); + + config.addDefault("Abilities.Earth.EarthSmash.Enabled", true); + config.addDefault("Abilities.Earth.EarthSmash.Description", "To raise an EarthSmash hold sneak (default: shift) for approximately 1.5 seconds, " + + "then release while aiming at dirt. To grab the EarthSmash aim at the center and hold sneak, " + + "the EarthSmash will follow your mouse. You can shoot the EarthSmash by grabbing onto it and left clicking. " + + "To ride the EarthSmash simply hop ontop of it and hold sneak while aiming in the direction that you wish to go. " + + "Another way to ride an EarthSmash is to grab it with sneak and then right click it. " + + "Use EarthSmash as a defensive shield, a powerful attack, or an advanced means of transportation."); + config.addDefault("Abilities.Earth.EarthSmash.AllowGrab", true); + config.addDefault("Abilities.Earth.EarthSmash.AllowShooting", true); + config.addDefault("Abilities.Earth.EarthSmash.AllowFlight", true); + config.addDefault("Abilities.Earth.EarthSmash.GrabRange", 10); + config.addDefault("Abilities.Earth.EarthSmash.ChargeTime", 1200); + config.addDefault("Abilities.Earth.EarthSmash.Cooldown", 0); + config.addDefault("Abilities.Earth.EarthSmash.ShotRange", 30); + config.addDefault("Abilities.Earth.EarthSmash.Damage", 6); + config.addDefault("Abilities.Earth.EarthSmash.Knockback", 3.5); + config.addDefault("Abilities.Earth.EarthSmash.Knockup", 0.15); + config.addDefault("Abilities.Earth.EarthSmash.FlightSpeed", 0.72); + config.addDefault("Abilities.Earth.EarthSmash.FlightTimer", 3000); + config.addDefault("Abilities.Earth.EarthSmash.RemoveTimer", 30000); + +// config.addDefault("Abilities.Earth.LavaSurge.Enabled", true); +// config.addDefault("Abilities.Earth.LavaSurge.Description", "LavaSurge is a fundamental move for any Lavabender out there. To use, simply sneak (Default: Shift) while looking at a source of Earth or Lava, then click in a direction. A surge of lava will swiftly travel towards the target you were pointing at, dealing moderate damage, a large knockback, and setting them on fire."); +// config.addDefault("Abilities.Earth.LavaSurge.Damage", 4); +// config.addDefault("Abilities.Earth.LavaSurge.Cooldown", 1000); +// config.addDefault("Abilities.Earth.LavaSurge.FractureRadius", 1); +// config.addDefault("Abilities.Earth.LavaSurge.PrepareRange", 7); +// config.addDefault("Abilities.Earth.LavaSurge.TravelRange", 15); +// config.addDefault("Abilities.Earth.LavaSurge.MaxLavaWaves", 10); +// config.addDefault("Abilities.Earth.LavaSurge.SourceCanBeEarth", true); + + config.addDefault("Abilities.Earth.MetalClips.Enabled", true); + config.addDefault("Abilities.Earth.MetalClips.Description", "MetalClips has the potential to be both an offensive and a utility ability. To start, you must carry smelted Iron Ingots in your inventory. To apply the clips onto an entity, simply click at them. If the entity is a Zombie, a Skeleton, or a Player, the clips will form armor around the entity, giving you some control over them. Each additional clip will give you more control. If you have permission to do so, you may crush the entity against a wall with a 4th clip, hurting them. Without explicit permissions, you will only be able to strap three clips on your target. If the entity is not one of the above, the clip will simply do damage and fall to the ground, to be collected."); + config.addDefault("Abilities.Earth.MetalClips.Damage", 2); + config.addDefault("Abilities.Earth.MetalClips.DamageInterval", 500); + config.addDefault("Abilities.Earth.MetalClips.MagnetRange", 20); + config.addDefault("Abilities.Earth.MetalClips.MagnetPower", 0.6); + config.addDefault("Abilities.Earth.MetalClips.Cooldown", 1000); + config.addDefault("Abilities.Earth.MetalClips.Duration", 10000); + + + config.addDefault("Abilities.Earth.RaiseEarth.Enabled", true); + config.addDefault("Abilities.Earth.RaiseEarth.Description", "To use, simply left-click on an earthbendable block. " + + "A column of earth will shoot upwards from that location. " + + "Anything in the way of the column will be brought up with it, " + + "leaving talented benders the ability to trap brainless entities up there. " + + "Additionally, simply sneak (default shift) looking at an earthbendable block. " + + "A wall of earth will shoot upwards from that location. " + + "Anything in the way of the wall will be brought up with it. "); + config.addDefault("Abilities.Earth.RaiseEarth.Column.Height", 6); + config.addDefault("Abilities.Earth.RaiseEarth.Wall.Range", 15); + config.addDefault("Abilities.Earth.RaiseEarth.Wall.Height", 6); + config.addDefault("Abilities.Earth.RaiseEarth.Wall.Width", 6); + + config.addDefault("Abilities.Earth.Shockwave.Enabled", true); + config.addDefault("Abilities.Earth.Shockwave.Description", "This is one of the most powerful moves in the earthbender's arsenal. " + + "To use, you must first charge it by holding sneak (default: shift). " + + "Once charged, you can release sneak to create an enormous shockwave of earth, " + + "disturbing all earth around you and expanding radially outwards. " + + "Anything caught in the shockwave will be blasted back and dealt damage. " + + "If you instead click while charged, the disruption is focused in a cone in front of you. " + + "Lastly, if you fall from a great enough height with this ability selected, you will automatically create a shockwave."); + config.addDefault("Abilities.Earth.Shockwave.FallThreshold", 10); + config.addDefault("Abilities.Earth.Shockwave.ChargeTime", 2500); + config.addDefault("Abilities.Earth.Shockwave.Damage", 5); + config.addDefault("Abilities.Earth.Shockwave.Knockback", 1.1); + config.addDefault("Abilities.Earth.Shockwave.Range", 15); + + config.addDefault("Abilities.Earth.Tremorsense.Enabled", true); + config.addDefault("Abilities.Earth.Tremorsense.Description", "This is a pure utility ability for earthbenders. If you are in an area of low-light and are standing on top of an earthbendable block, this ability will automatically turn that block into glowstone, visible *only by you*. If you lose contact with a bendable block, the light will go out as you have lost contact with the earth and cannot 'see' until you can touch earth again. Additionally, if you click with this ability selected, smoke will appear above nearby earth with pockets of air beneath them."); + config.addDefault("Abilities.Earth.Tremorsense.MaxDepth", 10); + config.addDefault("Abilities.Earth.Tremorsense.Radius", 5); + config.addDefault("Abilities.Earth.Tremorsense.LightThreshold", 7); + config.addDefault("Abilities.Earth.Tremorsense.Cooldown", 1000); + + config.addDefault("Abilities.Fire.Blaze.Enabled", true); + config.addDefault("Abilities.Fire.Blaze.Description", "To use, simply left-click in any direction. An arc of fire will flow from your location, igniting anything in its path. Additionally, tap sneak to engulf the area around you in roaring flames."); + config.addDefault("Abilities.Fire.Blaze.ArcOfFire.Arc", 20); + config.addDefault("Abilities.Fire.Blaze.ArcOfFire.Range", 9); + config.addDefault("Abilities.Fire.Blaze.RingOfFire.Range", 7); + + config.addDefault("Abilities.Fire.Combustion.Enabled", true); + config.addDefault("Abilities.Fire.Combustion.Description", "Combustion is a powerful ability only known by a few skilled Firebenders. It allows the bender to Firebend with their mind, concentrating energy to create a powerful blast. To use, simply tap sneak (Default: Shift) to launch the blast. This technique is highly destructive and very effective, it also comes with a long cooldown."); + config.addDefault("Abilities.Fire.Combustion.Cooldown", 15000); + // config.addDefault("Abilities.Fire.Combustion.ChargeTime", 5000); + config.addDefault("Abilities.Fire.Combustion.BreakBlocks", false); + config.addDefault("Abilities.Fire.Combustion.Power", 1.0); + config.addDefault("Abilities.Fire.Combustion.Damage", 5); + config.addDefault("Abilities.Fire.Combustion.Radius", 4); + config.addDefault("Abilities.Fire.Combustion.Range", 20); + config.addDefault("Abilities.Fire.Combustion.Speed", 25); + + config.addDefault("Abilities.Fire.FireBlast.Enabled", true); + config.addDefault("Abilities.Fire.FireBlast.Description","FireBlast is the most fundamental bending technique of a firebender. " + + "To use, simply left-click in a direction. A blast of fire will be created at your fingertips. " + + "If this blast contacts an enemy, it will dissipate and engulf them in flames, " + + "doing additional damage and knocking them back slightly. " + + "If the blast hits terrain, it will ignite the nearby area. " + + "Additionally, if you hold sneak, you will charge up the fireblast. " + + "If you release it when it's charged, it will instead launch a powerful " + + "fireball that explodes on contact."); + config.addDefault("Abilities.Fire.FireBlast.Speed", 15); + config.addDefault("Abilities.Fire.FireBlast.Range", 15); + config.addDefault("Abilities.Fire.FireBlast.Radius", 2); + config.addDefault("Abilities.Fire.FireBlast.Push", 0.3); + config.addDefault("Abilities.Fire.FireBlast.Damage", 2); + config.addDefault("Abilities.Fire.FireBlast.Cooldown", 1500); + config.addDefault("Abilities.Fire.FireBlast.Dissipate", false); + config.addDefault("Abilities.Fire.FireBlast.Charged.ChargeTime", 2000); + config.addDefault("Abilities.Fire.FireBlast.Charged.Damage", 4); + config.addDefault("Abilities.Fire.FireBlast.Charged.DamageRadius", 6); + config.addDefault("Abilities.Fire.FireBlast.Charged.Power", 1); + config.addDefault("Abilities.Fire.FireBlast.Charged.Range", 20); + + config.addDefault("Abilities.Fire.FireBurst.Enabled", true); + config.addDefault("Abilities.Fire.FireBurst.Description", "FireBurst is a very powerful firebending ability. " + + "To use, press and hold sneak to charge your burst. " + + "Once charged, you can either release sneak to launch a cone-shaped burst " + + "of flames in front of you, or click to release the burst in a sphere around you. "); + config.addDefault("Abilities.Fire.FireBurst.Damage", 3); + config.addDefault("Abilities.Fire.FireBurst.ChargeTime", 2500); + config.addDefault("Abilities.Fire.FireBurst.Range", 15); + + config.addDefault("Abilities.Fire.FireJet.Enabled", true); + config.addDefault("Abilities.Fire.FireJet.Description", "This ability is used for a limited burst of flight for firebenders. Clicking with this " + + "ability selected will launch you in the direction you're looking, granting you " + + "controlled flight for a short time. This ability can be used mid-air to prevent falling " + + "to your death, but on the ground it can only be used if standing on a block that's " + + "ignitable (e.g. not snow or water)."); + config.addDefault("Abilities.Fire.FireJet.Speed", 0.7); + config.addDefault("Abilities.Fire.FireJet.Duration", 1500); + config.addDefault("Abilities.Fire.FireJet.Cooldown", 6000); + config.addDefault("Abilities.Fire.FireJet.IsAvatarStateToggle", true); + + config.addDefault("Abilities.Fire.FireShield.Enabled", true); + config.addDefault("Abilities.Fire.FireShield.Description", "FireShield is a basic defensive ability. " + + "Clicking with this ability selected will create a " + + "small disc of fire in front of you, which will block most " + + "attacks and bending. Alternatively, pressing and holding " + + "sneak creates a very small shield of fire, blocking most attacks. " + + "Creatures that contact this fire are ignited."); + config.addDefault("Abilities.Fire.FireShield.Radius", 3); + config.addDefault("Abilities.Fire.FireShield.DiscRadius", 1.5); + config.addDefault("Abilities.Fire.FireShield.Duration", 1000); + + config.addDefault("Abilities.Fire.HeatControl.Enabled", true); + config.addDefault("Abilities.Fire.HeatControl.Description", "While this ability is selected, the firebender becomes impervious " + + "to fire damage and cannot be ignited. " + + "If the user left-clicks with this ability, the targeted area will be " + + "extinguished, although it will leave any creature burning engulfed in flames. " + + "This ability can also cool lava. If this ability is used while targetting ice or snow, it" + + " will instead melt blocks in that area. Finally, sneaking with this ability will cook any food in your hand."); + config.addDefault("Abilities.Fire.HeatControl.Extinguish.Range", 20); + config.addDefault("Abilities.Fire.HeatControl.Extinguish.Radius", 7); + config.addDefault("Abilities.Fire.HeatControl.Solidify.Range", 10); + config.addDefault("Abilities.Fire.HeatControl.Solidify.Radius", 5); + config.addDefault("Abilities.Fire.HeatControl.Solidify.RevertTime", 20000); + config.addDefault("Abilities.Fire.HeatControl.Melt.Range", 15); + config.addDefault("Abilities.Fire.HeatControl.Melt.Radius", 5); + + config.addDefault("Abilities.Fire.Illumination.Enabled", true); + config.addDefault("Abilities.Fire.Illumination.Description", "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking " + + "will create a torch that follows you around. The torch will only appear on objects that are " + + "ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, " + + "it will disappear, but will reappear when you get on another ignitable block. Clicking again " + + "dismisses this torch."); + config.addDefault("Abilities.Fire.Illumination.Range", 5); + + config.addDefault("Abilities.Fire.Lightning.Enabled", true); + config.addDefault("Abilities.Fire.Lightning.Description", "Hold sneak while selecting this ability to charge up a lightning strike. Once charged, release sneak to discharge the lightning to the targeted location."); + config.addDefault("Abilities.Fire.Lightning.Damage", 6.0); + config.addDefault("Abilities.Fire.Lightning.Range", 13.0); + config.addDefault("Abilities.Fire.Lightning.ChargeTime", 3500); + config.addDefault("Abilities.Fire.Lightning.Cooldown", 0); + config.addDefault("Abilities.Fire.Lightning.StunChance", 0.20); + config.addDefault("Abilities.Fire.Lightning.StunDuration", 30.0); + config.addDefault("Abilities.Fire.Lightning.MaxArcAngle", 30); + config.addDefault("Abilities.Fire.Lightning.SubArcChance", 0.025); + config.addDefault("Abilities.Fire.Lightning.ChainArcRange", 6.0); + config.addDefault("Abilities.Fire.Lightning.ChainArcChance", 0.50); + config.addDefault("Abilities.Fire.Lightning.MaxChainArcs", 2); + config.addDefault("Abilities.Fire.Lightning.WaterArcs", 4); + config.addDefault("Abilities.Fire.Lightning.WaterArcRange", 12.0); + config.addDefault("Abilities.Fire.Lightning.SelfHitWater", true); + config.addDefault("Abilities.Fire.Lightning.SelfHitClose", true); + config.addDefault("Abilities.Fire.Lightning.ArcOnIce", false); + + + config.addDefault("Abilities.Fire.WallOfFire.Enabled", true); + config.addDefault("Abilities.Fire.WallOfFire.Description", "To use this ability, click at a location. A wall of fire will appear at this location, igniting enemies caught in it and blocking projectiles."); + config.addDefault("Abilities.Fire.WallOfFire.Range", 4); + config.addDefault("Abilities.Fire.WallOfFire.Height", 4); + config.addDefault("Abilities.Fire.WallOfFire.Width", 4); + config.addDefault("Abilities.Fire.WallOfFire.Duration", 5000); + config.addDefault("Abilities.Fire.WallOfFire.Damage", 2); + config.addDefault("Abilities.Fire.WallOfFire.Cooldown", 7500); + config.addDefault("Abilities.Fire.WallOfFire.Interval", 500); + + config.addDefault("Abilities.Fire.FireCombo.Enabled", true); + config.addDefault("Abilities.Fire.FireCombo.FireKick.Range", 7.0); + config.addDefault("Abilities.Fire.FireCombo.FireKick.Damage", 3.0); + config.addDefault("Abilities.Fire.FireCombo.FireKick.Cooldown", 2000); + config.addDefault("Abilities.Fire.FireCombo.FireSpin.Range", 7); + config.addDefault("Abilities.Fire.FireCombo.FireSpin.Damage", 3.0); + config.addDefault("Abilities.Fire.FireCombo.FireSpin.Knockback", 3.2); + config.addDefault("Abilities.Fire.FireCombo.FireSpin.Cooldown", 2000); + config.addDefault("Abilities.Fire.FireCombo.FireWheel.Range", 20.0); + config.addDefault("Abilities.Fire.FireCombo.FireWheel.Damage", 4.0); + config.addDefault("Abilities.Fire.FireCombo.FireWheel.Speed", 0.55); + config.addDefault("Abilities.Fire.FireCombo.FireWheel.Cooldown", 200); + config.addDefault("Abilities.Fire.FireCombo.JetBlast.Speed", 1.2); + config.addDefault("Abilities.Fire.FireCombo.JetBlast.Cooldown", 6000); + config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Speed", 1.1); + config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Damage", 3); + config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Cooldown", 6000); + + config.addDefault("Abilities.Chi.Passive.FallReductionFactor", 0.5); + config.addDefault("Abilities.Chi.Passive.Speed", 1); + config.addDefault("Abilities.Chi.Passive.Jump", 2); + config.addDefault("Abilities.Chi.Passive.BlockChi.Duration", 2500); + config.addDefault("Abilities.Chi.Passive.DodgeChange", 25); + + config.addDefault("Abilities.Chi.AcrobatStance.Enabled", true); + config.addDefault("Abilities.Chi.AcrobatStance.Description", "AcrobatStance gives a Chiblocker a higher probability of blocking a Bender's Chi while granting them a Speed and Jump Boost. It also increases the rate at which the hunger bar depletes. To use, simply left click. Left clicking again will de-activate the stance."); + config.addDefault("Abilities.Chi.ChiBlockBoost", 0.1); + + config.addDefault("Abilities.Chi.HighJump.Enabled", true); + config.addDefault("Abilities.Chi.HighJump.Description", "To use this ability, simply click. You will jump quite high. This ability has a short cooldown."); + config.addDefault("Abilities.Chi.HighJump.Height", 1); + config.addDefault("Abilities.Chi.HighJump.Cooldown", 10000); + + 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); + + config.addDefault("Abilities.Chi.RapidPunch.Enabled", true); + config.addDefault("Abilities.Chi.RapidPunch.Description", "This ability allows the chiblocker to punch rapidly in a short period. To use, simply punch. This has a short cooldown."); + config.addDefault("Abilities.Chi.RapidPunch.Damage", 1); + config.addDefault("Abilities.Chi.RapidPunch.Distance", 4); + config.addDefault("Abilities.Chi.RapidPunch.Cooldown", 15000); + config.addDefault("Abilities.Chi.RapidPunch.Punches", 4); + + config.addDefault("Abilities.Chi.Smokescreen.Enabled", true); + config.addDefault("Abilities.Chi.Smokescreen.Description", "Smokescren, if used correctly, can serve as a defensive and offensive ability for Chiblockers. To use, simply left click and you will toss out a Smoke Bomb. When the bomb hits the ground, it will explode and give all players within a small radius of the explosion temporary blindness, allowing you to either get away, or move in for the kill. This ability has a long cooldown."); + config.addDefault("Abilities.Chi.Smokescreen.Cooldown", 50000); + config.addDefault("Abilities.Chi.Smokescreen.Radius", 4); + config.addDefault("Abilities.Chi.Smokescreen.Duration", 15); + + config.addDefault("Abilities.Chi.WarriorStance.Enabled", true); + config.addDefault("Abilities.Chi.WarriorStance.Description", "WarriorStance gives a Chiblocker increased damage but makes them a tad more vulnerable. To activate, simply left click."); + config.addDefault("Abilities.Chi.WarriorStance.Strength", 1); + config.addDefault("Abilities.Chi.WarriorStance.Resistance", -1); + + config.addDefault("Abilities.Chi.QuickStrike.Enabled", true); + config.addDefault("Abilities.Chi.QuickStrike.Description", "QuickStrike enables a chiblocker to quickly strike an enemy, potentially blocking their chi."); + config.addDefault("Abilities.Chi.QuickStrike.Damage", 2); + config.addDefault("Abilities.Chi.QuickStrike.ChiBlockChance", 20); + + config.addDefault("Abilities.Chi.SwiftKick.Enabled", true); + config.addDefault("Abilities.Chi.SwiftKick.Description", "SwiftKick allows a chiblocker to swiftly kick an enemy, potentially blocking their chi. The chiblocker must be in the air to use this ability."); + config.addDefault("Abilities.Chi.SwiftKick.Damage", 4); + config.addDefault("Abilities.Chi.SwiftKick.ChiBlockChance", 30); + + config.addDefault("Abilities.Chi.ChiCombo.ParalyzeDuration", 10000); + + config.addDefault("Storage.engine", "sqlite"); + + config.addDefault("Storage.MySQL.host", "localhost"); + config.addDefault("Storage.MySQL.port", 3306); + config.addDefault("Storage.MySQL.pass", ""); + config.addDefault("Storage.MySQL.db", "minecraft"); + config.addDefault("Storage.MySQL.user", "root"); + + config.addDefault("debug", false); + config.options().copyDefaults(true); + plugin.saveConfig(); + } +} From 45b7ee8b7a904d6d927cc5ecc3d781366449b723 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 30 May 2015 14:49:23 +0100 Subject: [PATCH 07/25] Added WaterArms to the stock abilities list --- .../ProjectKorra/Ability/StockAbilities.java | 450 +++++++++--------- 1 file changed, 225 insertions(+), 225 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java b/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java index 5d26f7d3..0cb47530 100644 --- a/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java +++ b/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java @@ -1,225 +1,225 @@ -package com.projectkorra.ProjectKorra.Ability; - -import java.util.Arrays; - -public enum StockAbilities { - - // Old Bending - AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, - - Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, - - HeatControl, Blaze, FireJet, Illumination, WallOfFire, FireBlast, Lightning, FireBurst, FireShield, - - WaterBubble, PhaseChange, HealingWaters, WaterManipulation, Surge, Bloodbending, WaterSpout, IceSpike, OctopusForm, Torrent, - - HighJump, RapidPunch, Paralyze, - - AvatarState, - - // Project Korra - Extraction, MetalClips, Smokescreen, Combustion, LavaFlow, Suffocate, IceBlast, WarriorStance, AcrobatStance, QuickStrike, SwiftKick, EarthSmash, Flight; - - private enum AirbendingAbilities { - AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, Suffocate, Flight; - } - - private enum WaterbendingAbilities { - WaterBubble, PhaseChange, HealingWaters, WaterManipulation, Surge, Bloodbending, WaterSpout, IceSpike, IceBlast, OctopusForm, Torrent; - - } - - private enum EarthbendingAbilities { - Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, Extraction, MetalClips, LavaFlow, EarthSmash; - } - - private enum FirebendingAbilities { - HeatControl, Blaze, FireJet, Illumination, WallOfFire, FireBlast, Lightning, FireBurst, FireShield, Combustion; - } - - private enum ChiblockingAbilities { - HighJump, RapidPunch, Paralyze, Smokescreen, WarriorStance, AcrobatStance, QuickStrike, SwiftKick; - } - - private enum FlightAbilities - { - Flight; - } - - private enum SpiritualProjectionAbilities - { - ; - } - - private enum CombustionbendingAbilities - { - Combustion; - } - - private enum LightningbendingAbilities - { - Lightning; - } - - private enum LavabendingAbilities - { - LavaFlow; - } - - private enum MetalbendingAbilities - { - Extraction, MetalClips; - } - - private enum SandbendingAbilities - { - ; - } - - private enum HealingAbilities - { - HealingWaters; - } - - private enum IcebendingAbilities - { - PhaseChange, IceBlast, IceSpike; - } - - private enum BloodbendingAbilities - { - Bloodbending; - } - - private enum PlantbendingAbilities - { - ; - } - - public static boolean isFlightAbility(String ability) - { - for(FlightAbilities a : FlightAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isSpiritualProjectionAbility(String ability) - { - for(SpiritualProjectionAbilities a : SpiritualProjectionAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isCombustionbendingAbility(String ability) - { - for(CombustionbendingAbilities a : CombustionbendingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isLightningbendingAbility(String ability) - { - for(LightningbendingAbilities a : LightningbendingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isLavabendingAbility(String ability) - { - for(LavabendingAbilities a : LavabendingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isMetalbendingAbility(String ability) - { - for(MetalbendingAbilities a : MetalbendingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isSandbendingAbility(String ability) - { - for(SandbendingAbilities a : SandbendingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isHealingAbility(String ability) - { - for(HealingAbilities a : HealingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isIcebendingAbility(String ability) - { - for(IcebendingAbilities a : IcebendingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isBloodbendingAbility(String ability) - { - for(BloodbendingAbilities a : BloodbendingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isPlantbendingAbility(String ability) - { - for(PlantbendingAbilities a : PlantbendingAbilities.values()) - if(a.name().equalsIgnoreCase(ability)) return true; - return false; - } - - public static boolean isStockAbility(String ability) { - for (StockAbilities a: StockAbilities.values()) { - if (a.name().equalsIgnoreCase(ability)) return true; - } - return false; - } - - public static boolean isAirbending(StockAbilities ability) { - for (AirbendingAbilities a: AirbendingAbilities.values()) { - if (a.name().equalsIgnoreCase(ability.name())) return true; - } - return false; - } - - public static boolean isWaterbending(StockAbilities ability) { - for (WaterbendingAbilities a: WaterbendingAbilities.values()) { - if (a.name().equalsIgnoreCase(ability.name())) return true; - } - return false; - } - - public static boolean isEarthbending(StockAbilities ability) { - for (EarthbendingAbilities a: EarthbendingAbilities.values()) { - if (a.name().equalsIgnoreCase(ability.name())) return true; - } - return false; - } - - public static boolean isFirebending(StockAbilities ability) { - for (FirebendingAbilities a: FirebendingAbilities.values()) { - if (a.name().equalsIgnoreCase(ability.name())) return true; - } - return false; - } - - public static boolean isChiBlocking(StockAbilities ability) { - for (ChiblockingAbilities a: ChiblockingAbilities.values()) { - if (a.name().equalsIgnoreCase(ability.name())) return true; - } - - return false; - } - - public static StockAbilities getAbility(int index) { - if (index == -1) - return null; - if (index > 41) return null; - return Arrays.asList(StockAbilities.values()).get(index); - } -} +package com.projectkorra.ProjectKorra.Ability; + +import java.util.Arrays; + +public enum StockAbilities { + + // Old Bending + AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, + + Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, + + HeatControl, Blaze, FireJet, Illumination, WallOfFire, FireBlast, Lightning, FireBurst, FireShield, + + WaterBubble, PhaseChange, HealingWaters, WaterManipulation, Surge, Bloodbending, WaterSpout, IceSpike, OctopusForm, Torrent, + + HighJump, RapidPunch, Paralyze, + + AvatarState, + + // Project Korra + Extraction, MetalClips, Smokescreen, Combustion, LavaFlow, Suffocate, IceBlast, WarriorStance, AcrobatStance, QuickStrike, SwiftKick, EarthSmash, Flight, WaterArms; + + private enum AirbendingAbilities { + AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, Suffocate, Flight; + } + + private enum WaterbendingAbilities { + WaterBubble, PhaseChange, HealingWaters, WaterManipulation, Surge, Bloodbending, WaterSpout, IceSpike, IceBlast, OctopusForm, Torrent, WaterArms; + + } + + private enum EarthbendingAbilities { + Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, Extraction, MetalClips, LavaFlow, EarthSmash; + } + + private enum FirebendingAbilities { + HeatControl, Blaze, FireJet, Illumination, WallOfFire, FireBlast, Lightning, FireBurst, FireShield, Combustion; + } + + private enum ChiblockingAbilities { + HighJump, RapidPunch, Paralyze, Smokescreen, WarriorStance, AcrobatStance, QuickStrike, SwiftKick; + } + + private enum FlightAbilities + { + Flight; + } + + private enum SpiritualProjectionAbilities + { + ; + } + + private enum CombustionbendingAbilities + { + Combustion; + } + + private enum LightningbendingAbilities + { + Lightning; + } + + private enum LavabendingAbilities + { + LavaFlow; + } + + private enum MetalbendingAbilities + { + Extraction, MetalClips; + } + + private enum SandbendingAbilities + { + ; + } + + private enum HealingAbilities + { + HealingWaters; + } + + private enum IcebendingAbilities + { + PhaseChange, IceBlast, IceSpike; + } + + private enum BloodbendingAbilities + { + Bloodbending; + } + + private enum PlantbendingAbilities + { + ; + } + + public static boolean isFlightAbility(String ability) + { + for(FlightAbilities a : FlightAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isSpiritualProjectionAbility(String ability) + { + for(SpiritualProjectionAbilities a : SpiritualProjectionAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isCombustionbendingAbility(String ability) + { + for(CombustionbendingAbilities a : CombustionbendingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isLightningbendingAbility(String ability) + { + for(LightningbendingAbilities a : LightningbendingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isLavabendingAbility(String ability) + { + for(LavabendingAbilities a : LavabendingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isMetalbendingAbility(String ability) + { + for(MetalbendingAbilities a : MetalbendingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isSandbendingAbility(String ability) + { + for(SandbendingAbilities a : SandbendingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isHealingAbility(String ability) + { + for(HealingAbilities a : HealingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isIcebendingAbility(String ability) + { + for(IcebendingAbilities a : IcebendingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isBloodbendingAbility(String ability) + { + for(BloodbendingAbilities a : BloodbendingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isPlantbendingAbility(String ability) + { + for(PlantbendingAbilities a : PlantbendingAbilities.values()) + if(a.name().equalsIgnoreCase(ability)) return true; + return false; + } + + public static boolean isStockAbility(String ability) { + for (StockAbilities a: StockAbilities.values()) { + if (a.name().equalsIgnoreCase(ability)) return true; + } + return false; + } + + public static boolean isAirbending(StockAbilities ability) { + for (AirbendingAbilities a: AirbendingAbilities.values()) { + if (a.name().equalsIgnoreCase(ability.name())) return true; + } + return false; + } + + public static boolean isWaterbending(StockAbilities ability) { + for (WaterbendingAbilities a: WaterbendingAbilities.values()) { + if (a.name().equalsIgnoreCase(ability.name())) return true; + } + return false; + } + + public static boolean isEarthbending(StockAbilities ability) { + for (EarthbendingAbilities a: EarthbendingAbilities.values()) { + if (a.name().equalsIgnoreCase(ability.name())) return true; + } + return false; + } + + public static boolean isFirebending(StockAbilities ability) { + for (FirebendingAbilities a: FirebendingAbilities.values()) { + if (a.name().equalsIgnoreCase(ability.name())) return true; + } + return false; + } + + public static boolean isChiBlocking(StockAbilities ability) { + for (ChiblockingAbilities a: ChiblockingAbilities.values()) { + if (a.name().equalsIgnoreCase(ability.name())) return true; + } + + return false; + } + + public static StockAbilities getAbility(int index) { + if (index == -1) + return null; + if (index > 41) return null; + return Arrays.asList(StockAbilities.values()).get(index); + } +} From 66374480cfa738c1b50fb6719724beaff07efbd9 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 15:16:36 +0100 Subject: [PATCH 08/25] Updated/Fixed MultiAbilityAPI. --- .../Ability/AbilityModuleManager.java | 605 +++++++++--------- .../MultiAbility/MultiAbilityModule.java | 6 +- .../MultiAbilityModuleManager.java | 8 +- .../ProjectKorra/MultiAbilityManager.java | 180 +++++- 4 files changed, 480 insertions(+), 319 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/Ability/AbilityModuleManager.java b/src/com/projectkorra/ProjectKorra/Ability/AbilityModuleManager.java index e2e9f7d4..7b2c8d35 100644 --- a/src/com/projectkorra/ProjectKorra/Ability/AbilityModuleManager.java +++ b/src/com/projectkorra/ProjectKorra/Ability/AbilityModuleManager.java @@ -1,302 +1,303 @@ -package com.projectkorra.ProjectKorra.Ability; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -import com.projectkorra.ProjectKorra.Element; -import com.projectkorra.ProjectKorra.ProjectKorra; -import com.projectkorra.ProjectKorra.Utilities.AbilityLoader; - - -public class AbilityModuleManager { - - static ProjectKorra plugin; - public static List ability; - private final AbilityLoader loader; - - public static HashSet abilities; - public static HashSet disabledStockAbilities; - public static List waterbendingabilities; - public static List airbendingabilities; - public static List earthbendingabilities; - public static List firebendingabilities; - public static List chiabilities; - public static HashSet shiftabilities; - public static HashMap authors; - public static HashSet harmlessabilities; - public static HashSet igniteabilities; - public static HashSet explodeabilities; - public static HashSet metalbendingabilities; - public static HashSet earthsubabilities; - public static HashSet subabilities; - public static HashSet lightningabilities; - public static HashSet combustionabilities; - public static HashSet lavaabilities; - public static HashSet sandabilities; - public static HashSet metalabilities; - public static HashSet flightabilities; - public static HashSet spiritualprojectionabilities; - public static HashSet iceabilities; - public static HashSet healingabilities; - public static HashSet plantabilities; - public static HashSet bloodabilities; - - public static HashMap descriptions; - - public AbilityModuleManager(final ProjectKorra plugin) { - AbilityModuleManager.plugin = plugin; - final File path = new File(plugin.getDataFolder().toString() + "/Abilities/"); - if (!path.exists()) { - path.mkdir(); - } - loader = new AbilityLoader(plugin, path, new Object[] {}); - abilities = new HashSet(); - waterbendingabilities = new ArrayList(); - airbendingabilities = new ArrayList(); - earthbendingabilities = new ArrayList(); - firebendingabilities = new ArrayList(); - chiabilities = new ArrayList(); - shiftabilities = new HashSet(); - descriptions = new HashMap(); - authors = new HashMap(); - harmlessabilities = new HashSet(); - explodeabilities = new HashSet(); - igniteabilities = new HashSet(); - metalbendingabilities = new HashSet(); - earthsubabilities = new HashSet(); - subabilities = new HashSet(); - ability = loader.load(AbilityModule.class); - disabledStockAbilities = new HashSet(); - lightningabilities = new HashSet(); - combustionabilities = new HashSet(); - flightabilities = new HashSet(); - spiritualprojectionabilities = new HashSet(); - metalabilities = new HashSet(); - sandabilities = new HashSet(); - lavaabilities = new HashSet(); - healingabilities = new HashSet(); - plantabilities = new HashSet(); - iceabilities = new HashSet(); - bloodabilities = new HashSet(); - fill(); - } - - private void fill() { - - for (StockAbilities a: StockAbilities.values()) { - if (StockAbilities.isAirbending(a)) { - if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Air." + a.name() + ".Enabled")) { - abilities.add(a.name()); - airbendingabilities.add(a.name()); - descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Air." + a.name() + ".Description")); - if (a == StockAbilities.AirScooter) harmlessabilities.add(a.name()); - if (a == StockAbilities.AirSpout) harmlessabilities.add(a.name()); - if (a == StockAbilities.Tornado) shiftabilities.add(a.name()); - if (a == StockAbilities.AirSuction) shiftabilities.add(a.name()); - if (a == StockAbilities.AirSwipe) shiftabilities.add(a.name()); - if (a == StockAbilities.AirBlast) shiftabilities.add(a.name()); - if (a == StockAbilities.AirBurst) shiftabilities.add(a.name()); - if (a == StockAbilities.AirShield) shiftabilities.add(a.name()); - if (a == StockAbilities.Flight) shiftabilities.add(a.name()); - - // Air Sub Abilities - if (a == StockAbilities.Flight) subabilities.add(a.name()); - if (a == StockAbilities.Flight) flightabilities.add(a.name()); - } - } - else if (StockAbilities.isWaterbending(a)) { - if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water." + a.name() + ".Enabled")) { - abilities.add(a.name()); - waterbendingabilities.add(a.name()); - descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Water." + a.name() + ".Description")); - if (a == StockAbilities.WaterSpout) harmlessabilities.add(a.name()); - if (a == StockAbilities.HealingWaters) harmlessabilities.add(a.name()); - if (a == StockAbilities.Surge) shiftabilities.add(a.name()); - if (a == StockAbilities.Bloodbending) shiftabilities.add(a.name()); - if (a == StockAbilities.PhaseChange) shiftabilities.add(a.name()); - if (a == StockAbilities.HealingWaters) shiftabilities.add(a.name()); - if (a == StockAbilities.OctopusForm) shiftabilities.add(a.name()); - if (a == StockAbilities.Torrent) shiftabilities.add(a.name()); - if (a == StockAbilities.WaterManipulation) shiftabilities.add(a.name()); - if (a == StockAbilities.IceSpike) shiftabilities.add(a.name()); - if (a == StockAbilities.IceBlast) shiftabilities.add(a.name()); - - // Water Sub Abilities - if (a == StockAbilities.HealingWaters) subabilities.add(a.name()); - if (a == StockAbilities.Bloodbending) subabilities.add(a.name()); - if (a == StockAbilities.PhaseChange) subabilities.add(a.name()); - if (a == StockAbilities.IceSpike) subabilities.add(a.name()); - if (a == StockAbilities.IceBlast) subabilities.add(a.name()); - - if (a == StockAbilities.HealingWaters) healingabilities.add(a.name()); - if (a == StockAbilities.Bloodbending) bloodabilities.add(a.name()); - if (a == StockAbilities.PhaseChange) iceabilities.add(a.name()); - if (a == StockAbilities.IceSpike) iceabilities.add(a.name()); - if (a == StockAbilities.IceBlast) iceabilities.add(a.name()); - } - } - else if (StockAbilities.isEarthbending(a)) { - if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth." + a.name() + ".Enabled")) { - abilities.add(a.name()); - earthbendingabilities.add(a.name()); - descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Earth." + a.name() + ".Description")); - if (a == StockAbilities.Tremorsense) harmlessabilities.add(a.name()); - if (a == StockAbilities.RaiseEarth) shiftabilities.add(a.name()); - if (a == StockAbilities.Collapse) shiftabilities.add(a.name()); - if (a == StockAbilities.EarthBlast) shiftabilities.add(a.name()); - if (a == StockAbilities.Shockwave) shiftabilities.add(a.name()); - if (a == StockAbilities.EarthTunnel) shiftabilities.add(a.name()); - if (a == StockAbilities.EarthGrab) shiftabilities.add(a.name()); - if (a == StockAbilities.LavaFlow) shiftabilities.add(a.name()); - if (a == StockAbilities.MetalClips) shiftabilities.add(a.name()); - if (a == StockAbilities.EarthSmash) shiftabilities.add(a.name()); - - // Earth Sub Abilities - if (a == StockAbilities.MetalClips) subabilities.add(a.name()); - if (a == StockAbilities.Extraction) subabilities.add(a.name()); - if (a == StockAbilities.LavaFlow) subabilities.add(a.name()); - - if (a == StockAbilities.MetalClips) metalabilities.add(a.name()); - if (a == StockAbilities.Extraction) metalabilities.add(a.name()); - if (a == StockAbilities.LavaFlow) lavaabilities.add(a.name()); -// if (a == StockAbilities.LavaSurge) earthsubabilities.add(a.name()); - - } - } - else if (StockAbilities.isFirebending(a)) { - if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire." + a.name() + ".Enabled")) { - abilities.add(a.name()); - firebendingabilities.add(a.name()); - descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Fire." + a.name() + ".Description")); - if (a == StockAbilities.Illumination) harmlessabilities.add(a.name()); - if (a == StockAbilities.Blaze) igniteabilities.add(a.name()); - if (a == StockAbilities.FireBlast) explodeabilities.add(a.name()); - if (a == StockAbilities.Lightning) explodeabilities.add(a.name()); - if (a == StockAbilities.Combustion) explodeabilities.add(a.name()); - if (a == StockAbilities.HeatControl) shiftabilities.add(a.name()); - if (a == StockAbilities.Lightning) shiftabilities.add(a.name()); - if (a == StockAbilities.FireBlast) shiftabilities.add(a.name()); - if (a == StockAbilities.Blaze) shiftabilities.add(a.name()); - if (a == StockAbilities.FireBurst) shiftabilities.add(a.name()); - - // Fire Sub Abilities - if (a == StockAbilities.Lightning) subabilities.add(a.name()); - if (a == StockAbilities.Combustion) subabilities.add(a.name()); - - if (a == StockAbilities.Lightning) lightningabilities.add(a.name()); - if (a == StockAbilities.Combustion) combustionabilities.add(a.name()); - } - } - else if (StockAbilities.isChiBlocking(a)) { - if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Chi." + a.name() + ".Enabled")) { - abilities.add(a.name()); - chiabilities.add(a.name()); - descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Chi." + a.name() + ".Description")); - if (a == StockAbilities.HighJump) harmlessabilities.add(a.name()); - } - } - else { - if (ProjectKorra.plugin.getConfig().getBoolean("Abilities." + a.name() + ".Enabled")) { - abilities.add(a.name()); // AvatarState, etc. - descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities." + a.name() + ".Description")); - } - } - } - for (AbilityModule ab: ability) { - try { - //To check if EarthBlast == Earthblast or for example, EarthBlast == EARTHBLAST - boolean succes = true; - for(String enabledAbility : abilities){ - if(enabledAbility.equalsIgnoreCase(ab.getName())){ - succes = false; - } - } - if (!succes) - continue; - ab.onThisLoad(); - abilities.add(ab.getName()); - for (StockAbilities a: StockAbilities.values()) { - if (a.name().equalsIgnoreCase(ab.getName())){ - disabledStockAbilities.add(a.name()); - } - } - if (ab.getElement() == Element.Air.toString()) airbendingabilities.add(ab.getName()); - if (ab.getElement() == Element.Water.toString()) waterbendingabilities.add(ab.getName()); - if (ab.getElement() == Element.Earth.toString()) earthbendingabilities.add(ab.getName()); - if (ab.getElement() == Element.Fire.toString()) firebendingabilities.add(ab.getName()); - if (ab.getElement() == Element.Chi.toString()) chiabilities.add(ab.getName()); - if (ab.isShiftAbility()) shiftabilities.add(ab.getName()); - if (ab.isHarmlessAbility()) harmlessabilities.add(ab.getName()); - - if (ab.getSubElement() != null) - { - subabilities.add(ab.getName()); - switch(ab.getSubElement()) - { - case Bloodbending: - bloodabilities.add(ab.getName()); - break; - case Combustion: - combustionabilities.add(ab.getName()); - break; - case Flight: - flightabilities.add(ab.getName()); - break; - case Healing: - healingabilities.add(ab.getName()); - break; - case Icebending: - iceabilities.add(ab.getName()); - break; - case Lavabending: - lavaabilities.add(ab.getName()); - break; - case Lightning: - lightningabilities.add(ab.getName()); - break; - case Metalbending: - metalabilities.add(ab.getName()); - break; - case Plantbending: - plantabilities.add(ab.getName()); - break; - case Sandbending: - sandabilities.add(ab.getName()); - break; - case SpiritualProjection: - spiritualprojectionabilities.add(ab.getName()); - break; - } - } - - // if (ab.isMetalbendingAbility()) metalbendingabilities.add(ab.getName()); - descriptions.put(ab.getName(), ab.getDescription()); - authors.put(ab.getName(), ab.getAuthor()); - } catch (AbstractMethodError e) { //If triggered means ability was made pre 1.6 BETA 8 - ProjectKorra.log.warning("The ability " + ab.getName() + " is either broken or outdated. Please remove it!"); - //e.printStackTrace(); - ab.stop(); - abilities.remove(ab.getName()); - final AbilityModule skill = ab; - //Bellow to avoid ConcurrentModificationException - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - public void run() { - ability.remove(skill); - } - }, 10); - continue; - } - } - - Collections.sort(airbendingabilities); - Collections.sort(waterbendingabilities); - Collections.sort(earthbendingabilities); - Collections.sort(firebendingabilities); - Collections.sort(chiabilities); - } - -} +package com.projectkorra.ProjectKorra.Ability; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + +import com.projectkorra.ProjectKorra.Element; +import com.projectkorra.ProjectKorra.ProjectKorra; +import com.projectkorra.ProjectKorra.Utilities.AbilityLoader; + + +public class AbilityModuleManager { + + static ProjectKorra plugin; + public static List ability; + private final AbilityLoader loader; + + public static HashSet abilities; + public static HashSet disabledStockAbilities; + public static List waterbendingabilities; + public static List airbendingabilities; + public static List earthbendingabilities; + public static List firebendingabilities; + public static List chiabilities; + public static HashSet shiftabilities; + public static HashMap authors; + public static HashSet harmlessabilities; + public static HashSet igniteabilities; + public static HashSet explodeabilities; + public static HashSet metalbendingabilities; + public static HashSet earthsubabilities; + public static HashSet subabilities; + public static HashSet lightningabilities; + public static HashSet combustionabilities; + public static HashSet lavaabilities; + public static HashSet sandabilities; + public static HashSet metalabilities; + public static HashSet flightabilities; + public static HashSet spiritualprojectionabilities; + public static HashSet iceabilities; + public static HashSet healingabilities; + public static HashSet plantabilities; + public static HashSet bloodabilities; + + public static HashMap descriptions; + + public AbilityModuleManager(final ProjectKorra plugin) { + AbilityModuleManager.plugin = plugin; + final File path = new File(plugin.getDataFolder().toString() + "/Abilities/"); + if (!path.exists()) { + path.mkdir(); + } + loader = new AbilityLoader(plugin, path, new Object[] {}); + abilities = new HashSet(); + waterbendingabilities = new ArrayList(); + airbendingabilities = new ArrayList(); + earthbendingabilities = new ArrayList(); + firebendingabilities = new ArrayList(); + chiabilities = new ArrayList(); + shiftabilities = new HashSet(); + descriptions = new HashMap(); + authors = new HashMap(); + harmlessabilities = new HashSet(); + explodeabilities = new HashSet(); + igniteabilities = new HashSet(); + metalbendingabilities = new HashSet(); + earthsubabilities = new HashSet(); + subabilities = new HashSet(); + ability = loader.load(AbilityModule.class); + disabledStockAbilities = new HashSet(); + lightningabilities = new HashSet(); + combustionabilities = new HashSet(); + flightabilities = new HashSet(); + spiritualprojectionabilities = new HashSet(); + metalabilities = new HashSet(); + sandabilities = new HashSet(); + lavaabilities = new HashSet(); + healingabilities = new HashSet(); + plantabilities = new HashSet(); + iceabilities = new HashSet(); + bloodabilities = new HashSet(); + fill(); + } + + private void fill() { + + for (StockAbilities a: StockAbilities.values()) { + if (StockAbilities.isAirbending(a)) { + if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Air." + a.name() + ".Enabled")) { + abilities.add(a.name()); + airbendingabilities.add(a.name()); + descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Air." + a.name() + ".Description")); + if (a == StockAbilities.AirScooter) harmlessabilities.add(a.name()); + if (a == StockAbilities.AirSpout) harmlessabilities.add(a.name()); + if (a == StockAbilities.Tornado) shiftabilities.add(a.name()); + if (a == StockAbilities.AirSuction) shiftabilities.add(a.name()); + if (a == StockAbilities.AirSwipe) shiftabilities.add(a.name()); + if (a == StockAbilities.AirBlast) shiftabilities.add(a.name()); + if (a == StockAbilities.AirBurst) shiftabilities.add(a.name()); + if (a == StockAbilities.AirShield) shiftabilities.add(a.name()); + if (a == StockAbilities.Flight) shiftabilities.add(a.name()); + + // Air Sub Abilities + if (a == StockAbilities.Flight) subabilities.add(a.name()); + if (a == StockAbilities.Flight) flightabilities.add(a.name()); + } + } + else if (StockAbilities.isWaterbending(a)) { + if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water." + a.name() + ".Enabled")) { + abilities.add(a.name()); + waterbendingabilities.add(a.name()); + descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Water." + a.name() + ".Description")); + if (a == StockAbilities.WaterSpout) harmlessabilities.add(a.name()); + if (a == StockAbilities.HealingWaters) harmlessabilities.add(a.name()); + if (a == StockAbilities.Surge) shiftabilities.add(a.name()); + if (a == StockAbilities.Bloodbending) shiftabilities.add(a.name()); + if (a == StockAbilities.PhaseChange) shiftabilities.add(a.name()); + if (a == StockAbilities.HealingWaters) shiftabilities.add(a.name()); + if (a == StockAbilities.OctopusForm) shiftabilities.add(a.name()); + if (a == StockAbilities.Torrent) shiftabilities.add(a.name()); + if (a == StockAbilities.WaterManipulation) shiftabilities.add(a.name()); + if (a == StockAbilities.WaterArms) shiftabilities.add(a.name()); + if (a == StockAbilities.IceSpike) shiftabilities.add(a.name()); + if (a == StockAbilities.IceBlast) shiftabilities.add(a.name()); + + // Water Sub Abilities + if (a == StockAbilities.HealingWaters) subabilities.add(a.name()); + if (a == StockAbilities.Bloodbending) subabilities.add(a.name()); + if (a == StockAbilities.PhaseChange) subabilities.add(a.name()); + if (a == StockAbilities.IceSpike) subabilities.add(a.name()); + if (a == StockAbilities.IceBlast) subabilities.add(a.name()); + + if (a == StockAbilities.HealingWaters) healingabilities.add(a.name()); + if (a == StockAbilities.Bloodbending) bloodabilities.add(a.name()); + if (a == StockAbilities.PhaseChange) iceabilities.add(a.name()); + if (a == StockAbilities.IceSpike) iceabilities.add(a.name()); + if (a == StockAbilities.IceBlast) iceabilities.add(a.name()); + } + } + else if (StockAbilities.isEarthbending(a)) { + if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth." + a.name() + ".Enabled")) { + abilities.add(a.name()); + earthbendingabilities.add(a.name()); + descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Earth." + a.name() + ".Description")); + if (a == StockAbilities.Tremorsense) harmlessabilities.add(a.name()); + if (a == StockAbilities.RaiseEarth) shiftabilities.add(a.name()); + if (a == StockAbilities.Collapse) shiftabilities.add(a.name()); + if (a == StockAbilities.EarthBlast) shiftabilities.add(a.name()); + if (a == StockAbilities.Shockwave) shiftabilities.add(a.name()); + if (a == StockAbilities.EarthTunnel) shiftabilities.add(a.name()); + if (a == StockAbilities.EarthGrab) shiftabilities.add(a.name()); + if (a == StockAbilities.LavaFlow) shiftabilities.add(a.name()); + if (a == StockAbilities.MetalClips) shiftabilities.add(a.name()); + if (a == StockAbilities.EarthSmash) shiftabilities.add(a.name()); + + // Earth Sub Abilities + if (a == StockAbilities.MetalClips) subabilities.add(a.name()); + if (a == StockAbilities.Extraction) subabilities.add(a.name()); + if (a == StockAbilities.LavaFlow) subabilities.add(a.name()); + + if (a == StockAbilities.MetalClips) metalabilities.add(a.name()); + if (a == StockAbilities.Extraction) metalabilities.add(a.name()); + if (a == StockAbilities.LavaFlow) lavaabilities.add(a.name()); +// if (a == StockAbilities.LavaSurge) earthsubabilities.add(a.name()); + + } + } + else if (StockAbilities.isFirebending(a)) { + if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Fire." + a.name() + ".Enabled")) { + abilities.add(a.name()); + firebendingabilities.add(a.name()); + descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Fire." + a.name() + ".Description")); + if (a == StockAbilities.Illumination) harmlessabilities.add(a.name()); + if (a == StockAbilities.Blaze) igniteabilities.add(a.name()); + if (a == StockAbilities.FireBlast) explodeabilities.add(a.name()); + if (a == StockAbilities.Lightning) explodeabilities.add(a.name()); + if (a == StockAbilities.Combustion) explodeabilities.add(a.name()); + if (a == StockAbilities.HeatControl) shiftabilities.add(a.name()); + if (a == StockAbilities.Lightning) shiftabilities.add(a.name()); + if (a == StockAbilities.FireBlast) shiftabilities.add(a.name()); + if (a == StockAbilities.Blaze) shiftabilities.add(a.name()); + if (a == StockAbilities.FireBurst) shiftabilities.add(a.name()); + + // Fire Sub Abilities + if (a == StockAbilities.Lightning) subabilities.add(a.name()); + if (a == StockAbilities.Combustion) subabilities.add(a.name()); + + if (a == StockAbilities.Lightning) lightningabilities.add(a.name()); + if (a == StockAbilities.Combustion) combustionabilities.add(a.name()); + } + } + else if (StockAbilities.isChiBlocking(a)) { + if (ProjectKorra.plugin.getConfig().getBoolean("Abilities.Chi." + a.name() + ".Enabled")) { + abilities.add(a.name()); + chiabilities.add(a.name()); + descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities.Chi." + a.name() + ".Description")); + if (a == StockAbilities.HighJump) harmlessabilities.add(a.name()); + } + } + else { + if (ProjectKorra.plugin.getConfig().getBoolean("Abilities." + a.name() + ".Enabled")) { + abilities.add(a.name()); // AvatarState, etc. + descriptions.put(a.name(), ProjectKorra.plugin.getConfig().getString("Abilities." + a.name() + ".Description")); + } + } + } + for (AbilityModule ab: ability) { + try { + //To check if EarthBlast == Earthblast or for example, EarthBlast == EARTHBLAST + boolean succes = true; + for(String enabledAbility : abilities){ + if(enabledAbility.equalsIgnoreCase(ab.getName())){ + succes = false; + } + } + if (!succes) + continue; + ab.onThisLoad(); + abilities.add(ab.getName()); + for (StockAbilities a: StockAbilities.values()) { + if (a.name().equalsIgnoreCase(ab.getName())){ + disabledStockAbilities.add(a.name()); + } + } + if (ab.getElement() == Element.Air.toString()) airbendingabilities.add(ab.getName()); + if (ab.getElement() == Element.Water.toString()) waterbendingabilities.add(ab.getName()); + if (ab.getElement() == Element.Earth.toString()) earthbendingabilities.add(ab.getName()); + if (ab.getElement() == Element.Fire.toString()) firebendingabilities.add(ab.getName()); + if (ab.getElement() == Element.Chi.toString()) chiabilities.add(ab.getName()); + if (ab.isShiftAbility()) shiftabilities.add(ab.getName()); + if (ab.isHarmlessAbility()) harmlessabilities.add(ab.getName()); + + if (ab.getSubElement() != null) + { + subabilities.add(ab.getName()); + switch(ab.getSubElement()) + { + case Bloodbending: + bloodabilities.add(ab.getName()); + break; + case Combustion: + combustionabilities.add(ab.getName()); + break; + case Flight: + flightabilities.add(ab.getName()); + break; + case Healing: + healingabilities.add(ab.getName()); + break; + case Icebending: + iceabilities.add(ab.getName()); + break; + case Lavabending: + lavaabilities.add(ab.getName()); + break; + case Lightning: + lightningabilities.add(ab.getName()); + break; + case Metalbending: + metalabilities.add(ab.getName()); + break; + case Plantbending: + plantabilities.add(ab.getName()); + break; + case Sandbending: + sandabilities.add(ab.getName()); + break; + case SpiritualProjection: + spiritualprojectionabilities.add(ab.getName()); + break; + } + } + + // if (ab.isMetalbendingAbility()) metalbendingabilities.add(ab.getName()); + descriptions.put(ab.getName(), ab.getDescription()); + authors.put(ab.getName(), ab.getAuthor()); + } catch (AbstractMethodError e) { //If triggered means ability was made pre 1.6 BETA 8 + ProjectKorra.log.warning("The ability " + ab.getName() + " is either broken or outdated. Please remove it!"); + //e.printStackTrace(); + ab.stop(); + abilities.remove(ab.getName()); + final AbilityModule skill = ab; + //Bellow to avoid ConcurrentModificationException + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + public void run() { + ability.remove(skill); + } + }, 10); + continue; + } + } + + Collections.sort(airbendingabilities); + Collections.sort(waterbendingabilities); + Collections.sort(earthbendingabilities); + Collections.sort(firebendingabilities); + Collections.sort(chiabilities); + } + +} diff --git a/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModule.java b/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModule.java index d774565d..5e9c97f8 100644 --- a/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModule.java +++ b/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModule.java @@ -2,6 +2,7 @@ package com.projectkorra.ProjectKorra.Ability.MultiAbility; import java.util.ArrayList; +import com.projectkorra.ProjectKorra.MultiAbilityManager.MultiAbilitySub; import com.projectkorra.ProjectKorra.SubElement; import com.projectkorra.ProjectKorra.Utilities.AbilityLoadable; @@ -117,10 +118,11 @@ public abstract class MultiAbilityModule extends AbilityLoadable implements Clon } /** - * Returns what abilities should be bound when ability is used. Colors can be used on these abilities! + * Returns the sub abilities of a MultiAbility. + * e.g. new MultiAbilitySub("SubAbility", Element.Fire, SubElement.Lightning); * @return */ - public abstract ArrayList getAbilities(); + public abstract ArrayList getAbilities(); /** * Void Method called whenever ProjectKorra stops and the ability is unloaded. diff --git a/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModuleManager.java b/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModuleManager.java index c56f36d7..19998d6e 100644 --- a/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModuleManager.java +++ b/src/com/projectkorra/ProjectKorra/Ability/MultiAbility/MultiAbilityModuleManager.java @@ -1,11 +1,11 @@ package com.projectkorra.ProjectKorra.Ability.MultiAbility; import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import com.projectkorra.ProjectKorra.Element; +import com.projectkorra.ProjectKorra.MultiAbilityManager; +import com.projectkorra.ProjectKorra.MultiAbilityManager.MultiAbility; import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; import com.projectkorra.ProjectKorra.Ability.StockAbilities; @@ -15,7 +15,6 @@ public class MultiAbilityModuleManager { private final AbilityLoader loader; public static List multiAbility; - public static HashMap> multiAbilities; public MultiAbilityModuleManager() { @@ -27,7 +26,6 @@ public class MultiAbilityModuleManager loader = new AbilityLoader(ProjectKorra.plugin, path, new Object[] {}); multiAbility = loader.load(MultiAbilityModule.class); - multiAbilities = new HashMap>(); loadMAModules(); } @@ -92,7 +90,7 @@ public class MultiAbilityModuleManager } } - multiAbilities.put(mam.getName(), mam.getAbilities()); + MultiAbilityManager.multiAbilityList.add(new MultiAbility(mam.getName(), mam.getAbilities())); AbilityModuleManager.descriptions.put(mam.getName(), mam.getDescription()); AbilityModuleManager.authors.put(mam.getName(), mam.getAuthor()); } diff --git a/src/com/projectkorra/ProjectKorra/MultiAbilityManager.java b/src/com/projectkorra/ProjectKorra/MultiAbilityManager.java index c41f9128..51102ebd 100644 --- a/src/com/projectkorra/ProjectKorra/MultiAbilityManager.java +++ b/src/com/projectkorra/ProjectKorra/MultiAbilityManager.java @@ -1,27 +1,145 @@ package com.projectkorra.ProjectKorra; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import com.projectkorra.ProjectKorra.Ability.MultiAbility.MultiAbilityModule; import com.projectkorra.ProjectKorra.Ability.MultiAbility.MultiAbilityModuleManager; +import com.projectkorra.ProjectKorra.airbending.AirMethods; +import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; +import com.projectkorra.ProjectKorra.earthbending.EarthMethods; +import com.projectkorra.ProjectKorra.firebending.FireMethods; +import com.projectkorra.ProjectKorra.waterbending.WaterMethods; public class MultiAbilityManager { public static ConcurrentHashMap> playerAbilities = new ConcurrentHashMap>(); public static ConcurrentHashMap playerSlot = new ConcurrentHashMap(); public static ConcurrentHashMap playerBoundAbility = new ConcurrentHashMap(); + public static ArrayList multiAbilityList = new ArrayList(); public MultiAbilityManager() { + ArrayList waterArms = new ArrayList(); + waterArms.add(new MultiAbilitySub("Pull", Element.Water, null)); + waterArms.add(new MultiAbilitySub("Punch", Element.Water, null)); + waterArms.add(new MultiAbilitySub("Grapple", Element.Water, null)); + waterArms.add(new MultiAbilitySub("Grab", Element.Water, null)); + waterArms.add(new MultiAbilitySub("Freeze", Element.Water, SubElement.Icebending)); + waterArms.add(new MultiAbilitySub("Spear", Element.Water, SubElement.Icebending)); + multiAbilityList.add(new MultiAbility("WaterArms", waterArms)); manage(); } /** - * Binds the "Fake" abilities. + * MultiAbility class. + * Manages each MultiAbility's sub abilities. + * + */ + public static class MultiAbility { + private String name; + private ArrayList abilities; + + public MultiAbility(String name, ArrayList abilities){ + this.name = name; + this.abilities = abilities; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ArrayList getAbilities(){ + return abilities; + } + + public void setAbilities(ArrayList abilities){ + this.abilities = abilities; + } + } + + public static class MultiAbilitySub { + private String name; + private Element element; + private SubElement sub; + + public MultiAbilitySub(String name, Element element, SubElement sub){ + this.name = name; + this.element = element; + this.sub = sub; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Element getElement(){ + return element; + } + + public void setElement(Element element){ + this.element = element; + } + + public SubElement getSubElement(){ + return sub; + } + + public void setSubElement(SubElement sub){ + this.sub = sub; + } + + public ChatColor getAbilityColor(){ + if(sub == null){ + switch(element){ + case Air: + return AirMethods.getAirColor(); + case Water: + return WaterMethods.getWaterColor(); + case Fire: + return FireMethods.getFireColor(); + case Earth: + return EarthMethods.getEarthColor(); + case Chi: + return ChiMethods.getChiColor(); + default: + return GeneralMethods.getAvatarColor(); + + } + }else{ + return GeneralMethods.getSubBendingColor(element); + } + } + } + + /** + * Returns a MultiAbility based on name. + * @param multiAbility + * @return + */ + public static MultiAbility getMultiAbility(String multiAbility){ + for(MultiAbility ma: multiAbilityList){ + if(ma.getName().equalsIgnoreCase(multiAbility)) + return ma; + } + return null; + } + + /** + * Sets up a player's binds for a MultiAbility. * @param player * @param multiAbility */ @@ -37,11 +155,15 @@ public class MultiAbilityManager { } playerAbilities.put(player, currAbilities); - List modes = MultiAbilityModuleManager.multiAbilities.get(multiAbility); + List modes = getMultiAbility(multiAbility).getAbilities(); bPlayer.getAbilities().clear(); - for(int i = 0; i < modes.size(); i++) - bPlayer.getAbilities().put(i+1, modes.get(i)); + for(int i = 0; i < modes.size(); i++){ + if(!player.hasPermission("bending.ability." + multiAbility + "." + modes.get(i).getName())) + bPlayer.getAbilities().put(i+1, new StringBuilder().append(modes.get(i).getAbilityColor()).append(ChatColor.STRIKETHROUGH).append(modes.get(i).getName()).toString()); + else + bPlayer.getAbilities().put(i+1, modes.get(i).getAbilityColor() + modes.get(i).getName()); + } if(player.isOnline()){ bPlayer.addCooldown("MAM_Setup", 1L); //Support for bending scoreboards. @@ -50,7 +172,7 @@ public class MultiAbilityManager { } /** - * Unbinds the "Fake" abilities. + * Reverts a player's binds to a previous state before use of a MultiAbility. * @param player */ public static void unbindMultiAbility(Player player){ @@ -85,19 +207,43 @@ public class MultiAbilityManager { } /** - * MultiAbility equivalent of GeneralMethods.getBoundAbility() + * MultiAbility equivalent of GeneralMethods.getBoundAbility(). + * Returns a boolean based on whether a player has a specific MultiAbility active. * @param player * @param multiAbility * @return */ public static boolean hasMultiAbilityBound(Player player, String multiAbility){ if(playerAbilities.containsKey(player)){ - if(!MultiAbilityModuleManager.multiAbilities.get(multiAbility).contains(GeneralMethods.getBoundAbility(player)) && GeneralMethods.getBoundAbility(player) != null) + if(!playerBoundAbility.get(player).equals(multiAbility) && GeneralMethods.getBoundAbility(player) != null) return false; return true; } return false; } + + /** + * Returns a boolean based on whether a player has a MultiAbility active. + * @param player + * @return + */ + public static boolean hasMultiAbilityBound(Player player){ + if(playerAbilities.containsKey(player)) + return true; + return false; + } + + /** + * Returns the MultiAbility the player has bound. + * Returns null if no multiability is bound and active. + * @param player + * @return + */ + public static String getBoundMultiAbility(Player player){ + if(playerBoundAbility.containsKey(player)) + return playerBoundAbility.get(player); + return null; + } public static void manage(){ new BukkitRunnable() { @@ -107,14 +253,17 @@ public class MultiAbilityManager { }.runTaskTimer(ProjectKorra.plugin, 0, 1); } + /** + * Keeps track of the player's selected slot while a MultiAbility is active. + */ public static void scrollHotBarSlots(){ if(!playerAbilities.isEmpty()){ for(Player player : playerAbilities.keySet()){ if(playerBoundAbility.containsKey(player)){ if(GeneralMethods.getBoundAbility(player) == null){ - if(MultiAbilityModuleManager.multiAbilities.containsKey(playerBoundAbility.get(player))){ - if(player.getInventory().getHeldItemSlot() > MultiAbilityModuleManager.multiAbilities.get(playerBoundAbility.get(player)).size()){ - player.getInventory().setHeldItemSlot(MultiAbilityModuleManager.multiAbilities.get(playerBoundAbility.get(player)).size() - 1); + if(multiAbilityList.contains(getMultiAbility(playerBoundAbility.get(player)))){ + if(player.getInventory().getHeldItemSlot() > getMultiAbility(playerBoundAbility.get(player)).getAbilities().size()){ + player.getInventory().setHeldItemSlot(getMultiAbility(playerBoundAbility.get(player)).getAbilities().size() - 1); }else{ player.getInventory().setHeldItemSlot(0); } @@ -125,12 +274,23 @@ public class MultiAbilityManager { } } + /** + * Clears all MultiAbility data for a player. + * Called on player quit event. + * @param player + */ public static void remove(Player player){ + if(hasMultiAbilityBound(player)) + unbindMultiAbility(player); + playerAbilities.remove(player); playerBoundAbility.remove(player); playerSlot.remove(player); } + /** + * Cleans up all MultiAbilities. + */ public static void removeAll(){ List abilities = MultiAbilityModuleManager.multiAbility; for(MultiAbilityModule mam: abilities) From 742df175db65183bf72b182c20282bc3b02d7142 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 15:16:58 +0100 Subject: [PATCH 09/25] Added WaterArms as a stock ability. --- .../ProjectKorra/Ability/StockAbilities.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java b/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java index 0cb47530..12260353 100644 --- a/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java +++ b/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java @@ -96,6 +96,11 @@ public enum StockAbilities { ; } + private enum MultiAbilities + { + WaterArms; + } + public static boolean isFlightAbility(String ability) { for(FlightAbilities a : FlightAbilities.values()) @@ -215,6 +220,13 @@ public enum StockAbilities { return false; } + + public static boolean isMultiAbility(StockAbilities ability) { + for(MultiAbilities a: MultiAbilities.values()) { + if (a.name().equalsIgnoreCase(ability.name())) return true; + } + return false; + } public static StockAbilities getAbility(int index) { if (index == -1) From 25e7eb8b397b2926c39a9529748558dc461168f4 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 15:17:29 +0100 Subject: [PATCH 10/25] Changed config options for WaterArms. --- src/com/projectkorra/ProjectKorra/ConfigManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/ConfigManager.java b/src/com/projectkorra/ProjectKorra/ConfigManager.java index 9802016f..af9f9922 100644 --- a/src/com/projectkorra/ProjectKorra/ConfigManager.java +++ b/src/com/projectkorra/ProjectKorra/ConfigManager.java @@ -368,12 +368,12 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterArms.Enabled", true); config.addDefault("Abilities.Water.WaterArms.Description", "One of the most diverse moves in a waterbenders arsenal, this move creates tendrils " + "of water from the players arms to emulate their actual arms. Each water arms mode will be binded to a slot, switch slots to change mode. " - + "To deactive the arms, hold Sneak and Double Left-Click. Tapping Sneak will tell you what mode you currently have active! " - + "Pull: Pulls entities and blocks towards the player! " - + "Punch: Damages entities and knocks them back! " - + "Grapple: Pull yourself towards blocks like a grappling hook! " - + "Freeze: Shoot blocks from your arms like mini ice blasts! " - + "Spear: Shoot your arms to create spears through the air, and capturing anything it hits!"); + + "To deactive the arms, hold Sneak and Double Left-Click." + + "\nPull - Use your Arms to pull blocks, items, mobs or even players towards you!" + + "\nPunch - An offensive attack, harming players or mobs!" + + "\nGrapple - Scale walls and speed across battlefields, using your Arms as a grappling hook!" + + "\nFreeze - Use your Arms to fire small blasts of ice in any direction!" + + "\nSpear - Throw your Arms in any direction, freezing whatever it hits!"); config.addDefault("Abilities.Water.WaterArms.Arms.InitialLength", 4); config.addDefault("Abilities.Water.WaterArms.Arms.SourceGrabRange", 4); From 9bbd231eef1af43a86c0c4e87b1b94d1fa90ba19 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 15:18:30 +0100 Subject: [PATCH 11/25] Added getLeftSide and getRightSide methods to get the respective side of a location no matter the direction it's facing. --- .../ProjectKorra/GeneralMethods.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/com/projectkorra/ProjectKorra/GeneralMethods.java b/src/com/projectkorra/ProjectKorra/GeneralMethods.java index 5ae6ae04..08a73d92 100644 --- a/src/com/projectkorra/ProjectKorra/GeneralMethods.java +++ b/src/com/projectkorra/ProjectKorra/GeneralMethods.java @@ -1811,4 +1811,28 @@ public class GeneralMethods { return false; } + /** + * Returns a location with a specified distance away from the left side of a location. + * @param location + * @param distance + * @return + */ + public static Location getLeftSide(Location location, double distance){ + float angle = location.getYaw()/60; + return location.clone().add(new Vector(Math.cos(angle), 0, Math.sin(angle)).normalize().multiply(distance)); + } + + /** + * Returns a location with a specified distance away from the right side of a location. + * @param location + * @param distance + * @return + */ + public static Location getRightSide(Location location, double distance){ + float angle = location.getYaw()/60; + return location.clone().subtract(new Vector(Math.cos(angle), 0, Math.sin(angle)).normalize().multiply(distance)); + } + + + } From 6aa5947481ea03da00881bf5450114e7788d5acf Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 15:18:58 +0100 Subject: [PATCH 12/25] Added WaterArms falling block check to entitychangeblockevent. --- .../projectkorra/ProjectKorra/PKListener.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/com/projectkorra/ProjectKorra/PKListener.java b/src/com/projectkorra/ProjectKorra/PKListener.java index e4b7de17..6b4b599c 100644 --- a/src/com/projectkorra/ProjectKorra/PKListener.java +++ b/src/com/projectkorra/ProjectKorra/PKListener.java @@ -131,6 +131,7 @@ import com.projectkorra.ProjectKorra.waterbending.IceSpike2; import com.projectkorra.ProjectKorra.waterbending.Melt; import com.projectkorra.ProjectKorra.waterbending.OctopusForm; import com.projectkorra.ProjectKorra.waterbending.Torrent; +import com.projectkorra.ProjectKorra.waterbending.WaterArms; import com.projectkorra.ProjectKorra.waterbending.WaterManipulation; import com.projectkorra.ProjectKorra.waterbending.WaterMethods; import com.projectkorra.ProjectKorra.waterbending.WaterPassive; @@ -518,6 +519,9 @@ public class PKListener implements Listener { if (abil.equalsIgnoreCase("Torrent")) { Torrent.create(player); } + if (abil.equalsIgnoreCase("WaterArms")) { + new WaterArms(player); + } } if (EarthMethods.isEarthAbility(abil)) { @@ -712,6 +716,10 @@ public class PKListener implements Listener { LavaSurge.falling.remove(entity); event.setCancelled(true); } + if (WaterArms.falling.containsKey(entity)) { + WaterArms.falling.remove(entity); + event.setCancelled(true); + } } } @@ -827,7 +835,7 @@ public class PKListener implements Listener { AirScooter.check(player); String abil = GeneralMethods.getBoundAbility(player); - if (abil == null) return; + if (abil == null && !MultiAbilityManager.hasMultiAbilityBound(player)) return; if (GeneralMethods.canBend(player.getName(), abil)) { if (GeneralMethods.isDisabledStockAbility(abil)) return; @@ -1030,6 +1038,13 @@ public class PKListener implements Listener { if (abil.equalsIgnoreCase("AvatarState")) { new AvatarState(player); } + + if(MultiAbilityManager.hasMultiAbilityBound(player)){ + abil = MultiAbilityManager.getBoundMultiAbility(player); + if (abil.equalsIgnoreCase("WaterArms")) { + new WaterArms(player); + } + } } } From d5c6e10feb13a77e67348b17e8dff753749d216e Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 15:19:32 +0100 Subject: [PATCH 13/25] Added WaterArms managing and stopping. --- .../waterbending/WaterMethods.java | 721 +++++++++--------- .../waterbending/WaterbendingManager.java | 75 +- 2 files changed, 399 insertions(+), 397 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/waterbending/WaterMethods.java b/src/com/projectkorra/ProjectKorra/waterbending/WaterMethods.java index 1e0abb3b..ae8c9ccf 100644 --- a/src/com/projectkorra/ProjectKorra/waterbending/WaterMethods.java +++ b/src/com/projectkorra/ProjectKorra/waterbending/WaterMethods.java @@ -1,361 +1,362 @@ -package com.projectkorra.ProjectKorra.waterbending; - -import java.util.Arrays; - -import org.bukkit.ChatColor; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; - -import com.projectkorra.ProjectKorra.BendingManager; -import com.projectkorra.ProjectKorra.GeneralMethods; -import com.projectkorra.ProjectKorra.ProjectKorra; -import com.projectkorra.ProjectKorra.TempBlock; -import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; -import com.projectkorra.ProjectKorra.Ability.AvatarState; -import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; -import com.projectkorra.rpg.RPGMethods; -import com.projectkorra.rpg.WorldEvents; - -public class WaterMethods { - - static ProjectKorra plugin; - private static FileConfiguration config = ProjectKorra.plugin.getConfig(); - private static Integer[] plantIds = { 6, 18, 31, 32, 37, 38, 39, 40, 59, 81, 83, 86, 99, 100, 103, 104, 105, 106, 111, 161, 175}; - - public WaterMethods(ProjectKorra plugin) { - WaterMethods.plugin = plugin; - } - - /** - * Checks to see if a Player is effected by BloodBending. - * @param player The player to check - *

- * @return true If {@link #isChiBlocked(String)} is true - *
- * false If player is BloodBender and Bending is toggled on, or if player is in AvatarState - *

- */ - public static boolean canBeBloodbent(Player player) { - if (AvatarState.isAvatarState(player)) - if (ChiMethods.isChiBlocked(player.getName())) - return true; - if (GeneralMethods.canBend(player.getName(), "Bloodbending") && !GeneralMethods.getBendingPlayer(player.getName()).isToggled()) - return false; - return true; - } - - /** - * Checks to see if a player can BloodBend. - * @param player The player to check - * @return true If player has permission node "bending.earth.bloodbending" - */ - public static boolean canBloodbend(Player player) { - if (player.hasPermission("bending.water.bloodbending")) return true; - return false; - } - - public static boolean canBloodbendAtAnytime(Player player){ - if(canBloodbend(player) && player.hasPermission("bending.water.bloodbending.anytime")) return true; - return false; - } - - public static boolean canIcebend(Player player) { - if(player.hasPermission("bending.water.icebending")) return true; - return false; - } - - public static boolean canWaterHeal(Player player){ - if(player.hasPermission("bending.water.healing")) return true; - return false; - } - - /** - * Checks to see if a player can PlantBend. - * @param player The player to check - * @return true If player has permission node "bending.ability.plantbending" - */ - public static boolean canPlantbend(Player player) { - return player.hasPermission("bending.water.plantbending"); - } - - public static double getWaterbendingNightAugment(World world) { - if (GeneralMethods.hasRPG()) { - if (isNight(world)) { - if (BendingManager.events.get(world).equalsIgnoreCase(WorldEvents.LunarEclipse.toString())) { - return RPGMethods.getFactor(WorldEvents.LunarEclipse); - } - else if (BendingManager.events.get(world).equalsIgnoreCase("FullMoon")) { - return config.getDouble("Properties.Water.FullMoonFactor"); - } - return config.getDouble("Properties.Water.NightFactor"); - } else { - return 1; - } - } else { - if (isNight(world) && BendingManager.events.get(world).equalsIgnoreCase("FullMoon")) return config.getDouble("Properties.Water.FullMoonFactor"); - if (isNight(world)) return config.getDouble("Properties.Water.NightFactor"); - return 1; - } - } - - /** - * Gets the WaterColor from the config. - * @return Config specified ChatColor - */ - public static ChatColor getWaterColor() { - return ChatColor.valueOf(config.getString("Properties.Chat.Colors.Water")); - } - - @SuppressWarnings("deprecation") - public static Block getWaterSourceBlock(Player player, double range, - boolean plantbending) { - Location location = player.getEyeLocation(); - Vector vector = location.getDirection().clone().normalize(); - for (double i = 0; i <= range; i++) { - Block block = location.clone().add(vector.clone().multiply(i)) - .getBlock(); - if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterManipulation", - location)) - continue; - if (isWaterbendable(block, player) - && (!isPlant(block) || plantbending)) { - if (TempBlock.isTempBlock(block)) { - TempBlock tb = TempBlock.get(block); - byte full = 0x0; - if (tb.getState().getRawData() != full - && (tb.getState().getType() != Material.WATER || tb.getState() - .getType() != Material.STATIONARY_WATER)) { - continue; - } - } - return block; - } - } - return null; - } - - public static Block getIceSourceBlock(Player player, double range) { - Location location = player.getEyeLocation(); - Vector vector = location.getDirection().clone().normalize(); - for (double i = 0; i <= range; i++) { - Block block = location.clone().add(vector.clone().multiply(i)).getBlock(); - if (GeneralMethods.isRegionProtectedFromBuild(player, "IceBlast", location)) - continue; - if (isIcebendable(block)) { - if (TempBlock.isTempBlock(block)) - continue; - return block; - } - } - return null; - } - - public static boolean isAdjacentToFrozenBlock(Block block) { - BlockFace[] faces = { BlockFace.DOWN, BlockFace.UP, BlockFace.NORTH, - BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH }; - boolean adjacent = false; - for (BlockFace face : faces) { - if (FreezeMelt.frozenblocks.containsKey((block.getRelative(face)))) - adjacent = true; - } - - return adjacent; - } - - public static boolean isHealingAbility(String ability){ - return AbilityModuleManager.healingabilities.contains(ability); - } - - public static boolean isIcebendingAbility(String ability){ - return AbilityModuleManager.iceabilities.contains(ability); - } - - public static boolean isPlantbendingAbility(String ability){ - return AbilityModuleManager.plantabilities.contains(ability); - } - - public static boolean isBloodbendingAbility(String ability){ - return AbilityModuleManager.bloodabilities.contains(ability); - } - - public static boolean isFullMoon(World world) { - long days = world.getFullTime() / 24000; - long phase = days%8; - if (phase == 0) { - return true; - } - return false; - } - - public static boolean isMeltable(Block block) { - if (block.getType() == Material.ICE || block.getType() == Material.SNOW) { - return true; - } - return false; - } - - public static boolean isNight(World world) { - if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) { - return false; - } - - long time = world.getTime(); - if (time >= 12950 && time <= 23050) { - return true; - } - return false; - } - - @SuppressWarnings("deprecation") - public static boolean isPlant(Block block) { - if (Arrays.asList(plantIds).contains(block.getTypeId())) return true; - return false; - } - - public static boolean isWater(Block block) { - if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) return true; - return false; - } - - public static boolean isWaterAbility(String ability) { - return AbilityModuleManager.waterbendingabilities.contains(ability); - } - - - @SuppressWarnings("deprecation") - public static boolean isWaterbendable(Block block, Player player) { - byte full = 0x0; - if (TempBlock.isTempBlock(block)) return false; - if ((block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) && block.getData() == full) return true; - if (block.getType() == Material.ICE || block.getType() == Material.SNOW) return true; - if (block.getType() == Material.PACKED_ICE && plugin.getConfig().getBoolean("Properties.Water.CanBendPackedIce")) return true; - if (canPlantbend(player) && isPlant(block)) return true; - return false; - } - - public static boolean isIcebendable(Block block) { - if (block.getType() == Material.ICE) return true; - if (block.getType() == Material.PACKED_ICE && plugin.getConfig().getBoolean("Properties.Water.CanBendPackedIce")) return true; - return false; - } - - public static void playFocusWaterEffect(Block block) { - block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 4, 20); - } - - /** - * Removes all water spouts in a location within a certain radius. - * @param loc The location to use - * @param radius The radius around the location to remove spouts in - * @param source The player causing the removal - */ - public static void removeWaterSpouts(Location loc, double radius, Player source) { - WaterSpout.removeSpouts(loc, radius, source); - } - - /** - * Removes all water spouts in a location with a radius of 1.5. - * @param loc The location to use - * @param source The player causing the removal - */ - public static void removeWaterSpouts(Location loc, Player source) { - removeWaterSpouts(loc, 1.5, source); - } - - public static double waterbendingNightAugment(double value, World world) { - if (isNight(world)) { - if (GeneralMethods.hasRPG()) { - if (BendingManager.events.get(world).equalsIgnoreCase(WorldEvents.LunarEclipse.toString())) { - return RPGMethods.getFactor(WorldEvents.LunarEclipse) * value; - } - else if (BendingManager.events.get(world).equalsIgnoreCase("FullMoon")) { - return plugin.getConfig().getDouble("Properties.Water.FullMoonFactor") * value; - } - else { - return value; - } - } else { - if (isFullMoon(world)) { - return plugin.getConfig().getDouble("Properties.Water.FullMoonFactor") * value; - } else { - return plugin.getConfig().getDouble("Properties.Water.NightFactor") * value; - } - } - } else { - return value; - } - } - - public static boolean isNegativeEffect(PotionEffectType effect) { - if(effect.equals(PotionEffectType.POISON)) return true; - if(effect.equals(PotionEffectType.BLINDNESS)) return true; - if(effect.equals(PotionEffectType.CONFUSION)) return true; - if(effect.equals(PotionEffectType.HARM)) return true; - if(effect.equals(PotionEffectType.HUNGER)) return true; - if(effect.equals(PotionEffectType.SLOW)) return true; - if(effect.equals(PotionEffectType.SLOW_DIGGING)) return true; - if(effect.equals(PotionEffectType.WEAKNESS)) return true; - if(effect.equals(PotionEffectType.WITHER)) return true; - return false; - } - - public static boolean isPositiveEffect(PotionEffectType effect) { - if(effect.equals(PotionEffectType.ABSORPTION)) return true; - if(effect.equals(PotionEffectType.DAMAGE_RESISTANCE)) return true; - if(effect.equals(PotionEffectType.FAST_DIGGING)) return true; - if(effect.equals(PotionEffectType.FIRE_RESISTANCE)) return true; - if(effect.equals(PotionEffectType.HEAL)) return true; - if(effect.equals(PotionEffectType.HEALTH_BOOST)) return true; - if(effect.equals(PotionEffectType.INCREASE_DAMAGE)) return true; - if(effect.equals(PotionEffectType.JUMP)) return true; - if(effect.equals(PotionEffectType.NIGHT_VISION)) return true; - if(effect.equals(PotionEffectType.REGENERATION)) return true; - if(effect.equals(PotionEffectType.SATURATION)) return true; - if(effect.equals(PotionEffectType.SPEED)) return true; - if(effect.equals(PotionEffectType.WATER_BREATHING)) return true; - return false; - } - - public static boolean isNeutralEffect(PotionEffectType effect) { - if(effect.equals(PotionEffectType.INVISIBILITY)) return true; - return false; - } - - public static void playWaterbendingSound(Location loc) { - if (plugin.getConfig().getBoolean("Properties.Water.PlaySound")) { - loc.getWorld().playSound(loc, Sound.WATER, 1, 10); - } - } - - public static void playIcebendingSound(Location loc) { - if (plugin.getConfig().getBoolean("Properties.Water.PlaySound")) { - loc.getWorld().playSound(loc, Sound.FIRE_IGNITE, 10, 4); - } - } - - public static void stopBending() { - FreezeMelt.removeAll(); - IceSpike.removeAll(); - IceSpike2.removeAll(); - WaterManipulation.removeAll(); - WaterSpout.removeAll(); - WaterWall.removeAll(); - Wave.removeAll(); - Plantbending.regrowAll(); - OctopusForm.removeAll(); - Bloodbending.instances.clear(); - WaterWave.removeAll(); - WaterCombo.removeAll(); - WaterReturn.removeAll(); - } +package com.projectkorra.ProjectKorra.waterbending; + +import java.util.Arrays; + +import org.bukkit.ChatColor; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +import com.projectkorra.ProjectKorra.BendingManager; +import com.projectkorra.ProjectKorra.GeneralMethods; +import com.projectkorra.ProjectKorra.ProjectKorra; +import com.projectkorra.ProjectKorra.TempBlock; +import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; +import com.projectkorra.ProjectKorra.Ability.AvatarState; +import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; +import com.projectkorra.rpg.RPGMethods; +import com.projectkorra.rpg.WorldEvents; + +public class WaterMethods { + + static ProjectKorra plugin; + private static FileConfiguration config = ProjectKorra.plugin.getConfig(); + private static Integer[] plantIds = { 6, 18, 31, 32, 37, 38, 39, 40, 59, 81, 83, 86, 99, 100, 103, 104, 105, 106, 111, 161, 175}; + + public WaterMethods(ProjectKorra plugin) { + WaterMethods.plugin = plugin; + } + + /** + * Checks to see if a Player is effected by BloodBending. + * @param player The player to check + *

+ * @return true If {@link #isChiBlocked(String)} is true + *
+ * false If player is BloodBender and Bending is toggled on, or if player is in AvatarState + *

+ */ + public static boolean canBeBloodbent(Player player) { + if (AvatarState.isAvatarState(player)) + if (ChiMethods.isChiBlocked(player.getName())) + return true; + if (GeneralMethods.canBend(player.getName(), "Bloodbending") && !GeneralMethods.getBendingPlayer(player.getName()).isToggled()) + return false; + return true; + } + + /** + * Checks to see if a player can BloodBend. + * @param player The player to check + * @return true If player has permission node "bending.earth.bloodbending" + */ + public static boolean canBloodbend(Player player) { + if (player.hasPermission("bending.water.bloodbending")) return true; + return false; + } + + public static boolean canBloodbendAtAnytime(Player player){ + if(canBloodbend(player) && player.hasPermission("bending.water.bloodbending.anytime")) return true; + return false; + } + + public static boolean canIcebend(Player player) { + if(player.hasPermission("bending.water.icebending")) return true; + return false; + } + + public static boolean canWaterHeal(Player player){ + if(player.hasPermission("bending.water.healing")) return true; + return false; + } + + /** + * Checks to see if a player can PlantBend. + * @param player The player to check + * @return true If player has permission node "bending.ability.plantbending" + */ + public static boolean canPlantbend(Player player) { + return player.hasPermission("bending.water.plantbending"); + } + + public static double getWaterbendingNightAugment(World world) { + if (GeneralMethods.hasRPG()) { + if (isNight(world)) { + if (BendingManager.events.get(world).equalsIgnoreCase(WorldEvents.LunarEclipse.toString())) { + return RPGMethods.getFactor(WorldEvents.LunarEclipse); + } + else if (BendingManager.events.get(world).equalsIgnoreCase("FullMoon")) { + return config.getDouble("Properties.Water.FullMoonFactor"); + } + return config.getDouble("Properties.Water.NightFactor"); + } else { + return 1; + } + } else { + if (isNight(world) && BendingManager.events.get(world).equalsIgnoreCase("FullMoon")) return config.getDouble("Properties.Water.FullMoonFactor"); + if (isNight(world)) return config.getDouble("Properties.Water.NightFactor"); + return 1; + } + } + + /** + * Gets the WaterColor from the config. + * @return Config specified ChatColor + */ + public static ChatColor getWaterColor() { + return ChatColor.valueOf(config.getString("Properties.Chat.Colors.Water")); + } + + @SuppressWarnings("deprecation") + public static Block getWaterSourceBlock(Player player, double range, + boolean plantbending) { + Location location = player.getEyeLocation(); + Vector vector = location.getDirection().clone().normalize(); + for (double i = 0; i <= range; i++) { + Block block = location.clone().add(vector.clone().multiply(i)) + .getBlock(); + if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterManipulation", + location)) + continue; + if (isWaterbendable(block, player) + && (!isPlant(block) || plantbending)) { + if (TempBlock.isTempBlock(block)) { + TempBlock tb = TempBlock.get(block); + byte full = 0x0; + if (tb.getState().getRawData() != full + && (tb.getState().getType() != Material.WATER || tb.getState() + .getType() != Material.STATIONARY_WATER)) { + continue; + } + } + return block; + } + } + return null; + } + + public static Block getIceSourceBlock(Player player, double range) { + Location location = player.getEyeLocation(); + Vector vector = location.getDirection().clone().normalize(); + for (double i = 0; i <= range; i++) { + Block block = location.clone().add(vector.clone().multiply(i)).getBlock(); + if (GeneralMethods.isRegionProtectedFromBuild(player, "IceBlast", location)) + continue; + if (isIcebendable(block)) { + if (TempBlock.isTempBlock(block)) + continue; + return block; + } + } + return null; + } + + public static boolean isAdjacentToFrozenBlock(Block block) { + BlockFace[] faces = { BlockFace.DOWN, BlockFace.UP, BlockFace.NORTH, + BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH }; + boolean adjacent = false; + for (BlockFace face : faces) { + if (FreezeMelt.frozenblocks.containsKey((block.getRelative(face)))) + adjacent = true; + } + + return adjacent; + } + + public static boolean isHealingAbility(String ability){ + return AbilityModuleManager.healingabilities.contains(ability); + } + + public static boolean isIcebendingAbility(String ability){ + return AbilityModuleManager.iceabilities.contains(ability); + } + + public static boolean isPlantbendingAbility(String ability){ + return AbilityModuleManager.plantabilities.contains(ability); + } + + public static boolean isBloodbendingAbility(String ability){ + return AbilityModuleManager.bloodabilities.contains(ability); + } + + public static boolean isFullMoon(World world) { + long days = world.getFullTime() / 24000; + long phase = days%8; + if (phase == 0) { + return true; + } + return false; + } + + public static boolean isMeltable(Block block) { + if (block.getType() == Material.ICE || block.getType() == Material.SNOW) { + return true; + } + return false; + } + + public static boolean isNight(World world) { + if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) { + return false; + } + + long time = world.getTime(); + if (time >= 12950 && time <= 23050) { + return true; + } + return false; + } + + @SuppressWarnings("deprecation") + public static boolean isPlant(Block block) { + if (Arrays.asList(plantIds).contains(block.getTypeId())) return true; + return false; + } + + public static boolean isWater(Block block) { + if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) return true; + return false; + } + + public static boolean isWaterAbility(String ability) { + return AbilityModuleManager.waterbendingabilities.contains(ability); + } + + + @SuppressWarnings("deprecation") + public static boolean isWaterbendable(Block block, Player player) { + byte full = 0x0; + if (TempBlock.isTempBlock(block)) return false; + if ((block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) && block.getData() == full) return true; + if (block.getType() == Material.ICE || block.getType() == Material.SNOW) return true; + if (block.getType() == Material.PACKED_ICE && plugin.getConfig().getBoolean("Properties.Water.CanBendPackedIce")) return true; + if (canPlantbend(player) && isPlant(block)) return true; + return false; + } + + public static boolean isIcebendable(Block block) { + if (block.getType() == Material.ICE) return true; + if (block.getType() == Material.PACKED_ICE && plugin.getConfig().getBoolean("Properties.Water.CanBendPackedIce")) return true; + return false; + } + + public static void playFocusWaterEffect(Block block) { + block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 4, 20); + } + + /** + * Removes all water spouts in a location within a certain radius. + * @param loc The location to use + * @param radius The radius around the location to remove spouts in + * @param source The player causing the removal + */ + public static void removeWaterSpouts(Location loc, double radius, Player source) { + WaterSpout.removeSpouts(loc, radius, source); + } + + /** + * Removes all water spouts in a location with a radius of 1.5. + * @param loc The location to use + * @param source The player causing the removal + */ + public static void removeWaterSpouts(Location loc, Player source) { + removeWaterSpouts(loc, 1.5, source); + } + + public static double waterbendingNightAugment(double value, World world) { + if (isNight(world)) { + if (GeneralMethods.hasRPG()) { + if (BendingManager.events.get(world).equalsIgnoreCase(WorldEvents.LunarEclipse.toString())) { + return RPGMethods.getFactor(WorldEvents.LunarEclipse) * value; + } + else if (BendingManager.events.get(world).equalsIgnoreCase("FullMoon")) { + return plugin.getConfig().getDouble("Properties.Water.FullMoonFactor") * value; + } + else { + return value; + } + } else { + if (isFullMoon(world)) { + return plugin.getConfig().getDouble("Properties.Water.FullMoonFactor") * value; + } else { + return plugin.getConfig().getDouble("Properties.Water.NightFactor") * value; + } + } + } else { + return value; + } + } + + public static boolean isNegativeEffect(PotionEffectType effect) { + if(effect.equals(PotionEffectType.POISON)) return true; + if(effect.equals(PotionEffectType.BLINDNESS)) return true; + if(effect.equals(PotionEffectType.CONFUSION)) return true; + if(effect.equals(PotionEffectType.HARM)) return true; + if(effect.equals(PotionEffectType.HUNGER)) return true; + if(effect.equals(PotionEffectType.SLOW)) return true; + if(effect.equals(PotionEffectType.SLOW_DIGGING)) return true; + if(effect.equals(PotionEffectType.WEAKNESS)) return true; + if(effect.equals(PotionEffectType.WITHER)) return true; + return false; + } + + public static boolean isPositiveEffect(PotionEffectType effect) { + if(effect.equals(PotionEffectType.ABSORPTION)) return true; + if(effect.equals(PotionEffectType.DAMAGE_RESISTANCE)) return true; + if(effect.equals(PotionEffectType.FAST_DIGGING)) return true; + if(effect.equals(PotionEffectType.FIRE_RESISTANCE)) return true; + if(effect.equals(PotionEffectType.HEAL)) return true; + if(effect.equals(PotionEffectType.HEALTH_BOOST)) return true; + if(effect.equals(PotionEffectType.INCREASE_DAMAGE)) return true; + if(effect.equals(PotionEffectType.JUMP)) return true; + if(effect.equals(PotionEffectType.NIGHT_VISION)) return true; + if(effect.equals(PotionEffectType.REGENERATION)) return true; + if(effect.equals(PotionEffectType.SATURATION)) return true; + if(effect.equals(PotionEffectType.SPEED)) return true; + if(effect.equals(PotionEffectType.WATER_BREATHING)) return true; + return false; + } + + public static boolean isNeutralEffect(PotionEffectType effect) { + if(effect.equals(PotionEffectType.INVISIBILITY)) return true; + return false; + } + + public static void playWaterbendingSound(Location loc) { + if (plugin.getConfig().getBoolean("Properties.Water.PlaySound")) { + loc.getWorld().playSound(loc, Sound.WATER, 1, 10); + } + } + + public static void playIcebendingSound(Location loc) { + if (plugin.getConfig().getBoolean("Properties.Water.PlaySound")) { + loc.getWorld().playSound(loc, Sound.FIRE_IGNITE, 10, 4); + } + } + + public static void stopBending() { + FreezeMelt.removeAll(); + IceSpike.removeAll(); + IceSpike2.removeAll(); + WaterManipulation.removeAll(); + WaterSpout.removeAll(); + WaterWall.removeAll(); + Wave.removeAll(); + Plantbending.regrowAll(); + OctopusForm.removeAll(); + Bloodbending.instances.clear(); + WaterWave.removeAll(); + WaterCombo.removeAll(); + WaterReturn.removeAll(); + WaterArms.removeAll(); + } } \ No newline at end of file diff --git a/src/com/projectkorra/ProjectKorra/waterbending/WaterbendingManager.java b/src/com/projectkorra/ProjectKorra/waterbending/WaterbendingManager.java index f430ed51..85e2cc45 100644 --- a/src/com/projectkorra/ProjectKorra/waterbending/WaterbendingManager.java +++ b/src/com/projectkorra/ProjectKorra/waterbending/WaterbendingManager.java @@ -1,37 +1,38 @@ -package com.projectkorra.ProjectKorra.waterbending; - -import org.bukkit.Bukkit; - -import com.projectkorra.ProjectKorra.ProjectKorra; - -public class WaterbendingManager implements Runnable { - - public ProjectKorra plugin; - - public WaterbendingManager(ProjectKorra plugin) { - this.plugin = plugin; - } - - @Override - public void run() { - WaterPassive.handlePassive(); - Plantbending.regrow(); - Bloodbending.progressAll(); - WaterSpout.handleSpouts(Bukkit.getServer()); - FreezeMelt.handleFrozenBlocks(); - OctopusForm.progressAll(); - Torrent.progressAll(); - TorrentBurst.progressAll(); - HealingWaters.heal(Bukkit.getServer()); - WaterReturn.progressAll(); - WaterManipulation.progressAll(); - WaterWall.progressAll(); - Wave.progressAll(); - IceSpike.progressAll(); - IceSpike2.progressAll(); - IceBlast.progressAll(); - WaterWave.progressAll(); - WaterCombo.progressAll(); - } - -} +package com.projectkorra.ProjectKorra.waterbending; + +import org.bukkit.Bukkit; + +import com.projectkorra.ProjectKorra.ProjectKorra; + +public class WaterbendingManager implements Runnable { + + public ProjectKorra plugin; + + public WaterbendingManager(ProjectKorra plugin) { + this.plugin = plugin; + } + + @Override + public void run() { + WaterPassive.handlePassive(); + Plantbending.regrow(); + Bloodbending.progressAll(); + WaterSpout.handleSpouts(Bukkit.getServer()); + FreezeMelt.handleFrozenBlocks(); + OctopusForm.progressAll(); + Torrent.progressAll(); + TorrentBurst.progressAll(); + HealingWaters.heal(Bukkit.getServer()); + WaterReturn.progressAll(); + WaterManipulation.progressAll(); + WaterWall.progressAll(); + Wave.progressAll(); + IceSpike.progressAll(); + IceSpike2.progressAll(); + IceBlast.progressAll(); + WaterWave.progressAll(); + WaterCombo.progressAll(); + WaterArms.progressAll(); + } + +} From 09575f8e9b4eae95dd8ef00337fe39ec2ad1d092 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 15:19:50 +0100 Subject: [PATCH 14/25] Started Recode on WaterArms. --- .../ProjectKorra/waterbending/WaterArms.java | 556 ++++++++++++++++++ .../waterbending/WaterArmsWhip.java | 432 ++++++++++++++ 2 files changed, 988 insertions(+) create mode 100644 src/com/projectkorra/ProjectKorra/waterbending/WaterArms.java create mode 100644 src/com/projectkorra/ProjectKorra/waterbending/WaterArmsWhip.java diff --git a/src/com/projectkorra/ProjectKorra/waterbending/WaterArms.java b/src/com/projectkorra/ProjectKorra/waterbending/WaterArms.java new file mode 100644 index 00000000..f7531abe --- /dev/null +++ b/src/com/projectkorra/ProjectKorra/waterbending/WaterArms.java @@ -0,0 +1,556 @@ +package com.projectkorra.ProjectKorra.waterbending; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import com.projectkorra.ProjectKorra.GeneralMethods; +import com.projectkorra.ProjectKorra.MultiAbilityManager; +import com.projectkorra.ProjectKorra.ProjectKorra; +import com.projectkorra.ProjectKorra.TempBlock; +import com.projectkorra.ProjectKorra.Utilities.ParticleEffect; +import com.projectkorra.ProjectKorra.earthbending.EarthMethods; +import com.projectkorra.ProjectKorra.firebending.FireMethods; +import com.projectkorra.ProjectKorra.firebending.Lightning; +import com.projectkorra.ProjectKorra.waterbending.WaterArmsWhip.Whip; + +public class WaterArms{ + + /** + * Arm Enum value for deciding which arm is being used. + */ + public enum Arm { + Right, Left; + } + + private static FileConfiguration config = ProjectKorra.plugin.getConfig(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap(); + public static ConcurrentHashMap revert = new ConcurrentHashMap(); + public static ConcurrentHashMap falling = new ConcurrentHashMap(); + + private static Integer[] unbreakable = {7, 8, 9, 10, 11, 49, 54, 90, 119, 120, 130, 146}; + + private Player player; + private World world; + + private Arm activeArm = Arm.Right; + + private boolean cooldownLeft; + private boolean cooldownRight; + private boolean fullSource = true; + + private boolean leftArmConsumed = false; + private boolean rightArmConsumed = false; + + private int lengthReduction = 0; + + private int initLength = config.getInt("Abilities.Water.WaterArms.Arms.InitialLength"); + private int sourceGrabRange = config.getInt("Abilities.Water.WaterArms.Arms.SourceGrabRange"); + private int maxPunches = config.getInt("Abilities.Water.WaterArms.Arms.MaxAttacks"); + private int maxIceBlasts = config.getInt("Abilities.Water.WaterArms.Arms.MaxIceShots"); + private int maxUses = config.getInt("Abilities.Water.WaterArms.Arms.MaxAlternateUsage"); + private long cooldown = config.getLong("Abilities.Water.WaterArms.Arms.cooldown"); + private boolean canUsePlantSource = config.getBoolean("Abilities.Water.WaterArms.Arms.AllowPlantSource"); + + private boolean lightningEnabled = config.getBoolean("Abilities.Water.WaterArms.Arms.Lightning.Enabled"); + private double lightningDamage = config.getDouble("Abilities.Water.WaterArms.Arms.Lightning.Damage"); + private boolean lightningKill = config.getBoolean("Abilities.Water.WaterArms.Arms.Lightning.KillUser"); + + private static double blockDamage = config.getDouble("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamage"); + private static boolean pullBlocksDamageUser = config.getBoolean("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamageUser"); + + private int selectedSlot = 0; + private int freezeSlot = 4; + + private long lastClickTime; + + public WaterArms(Player player){ + if(instances.containsKey(player)){ + if(player.isSneaking()){ + instances.get(player).prepareCancel(); + }else{ + switch(player.getInventory().getHeldItemSlot()){ + case 0: + new WaterArmsWhip(player, Whip.Pull); + break; + case 1: + new WaterArmsWhip(player, Whip.Punch); + break; + case 2: + new WaterArmsWhip(player, Whip.Grapple); + break; + case 3: + new WaterArmsWhip(player, Whip.Grab); + break; + case 4: + //new WaterArmsIce(player); + break; + case 5: + //new WaterArmsSpear(player); + break; + default: + break; + } + } + return; + } + this.player = player; + if(canUse(player) && prepare()){ + world = player.getWorld(); + instances.put(player, this); + MultiAbilityManager.bindMultiAbility(player, "WaterArms"); + if(ChatColor.stripColor(GeneralMethods.getBoundAbility(player)) == null){ + remove(); + return; + } + } + } + + private boolean canUse(Player player){ + if(GeneralMethods.getBoundAbility(player) == null) + return false; + if(!GeneralMethods.canBend(player.getName(), "WaterArms")) + return false; + if(GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", player.getLocation())) + return false; + if(GeneralMethods.getBendingPlayer(player.getName()).isOnCooldown("WaterArms")) + return false; + if(GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterArms")) + return true; + return false; + } + + private boolean prepare(){ + Block sourceblock = WaterMethods.getWaterSourceBlock(player, sourceGrabRange, canUsePlantSource); + if(sourceblock != null){ + if(WaterMethods.isPlant(sourceblock)){ + fullSource = false; + } + ParticleEffect.LARGE_SMOKE.display(WaterMethods.getWaterSourceBlock(player, sourceGrabRange, canUsePlantSource).getLocation().clone().add(0.5,0.5,0.5), 0, 0, 0, 0F, 4); + return true; + }else if(WaterReturn.hasWaterBottle(player)){ + WaterReturn.emptyWaterBottle(player); + fullSource = false; + return true; + } + return false; + } + + private void progress(){ + if (!instances.containsKey(player)){ + return; + } + if(player.isDead() || !player.isOnline() || world != player.getWorld()){ + remove(); + return; + } + if(!GeneralMethods.getBendingPlayer(player.getName()).isToggled()){ + remove(); + return; + } + if(!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")){ + remove(); + return; + } + if(maxPunches == 0 || maxUses == 0 || maxIceBlasts == 0 || (leftArmConsumed && rightArmConsumed)){ + remove(); + return; + } + + selectedSlot = player.getInventory().getHeldItemSlot(); + displayRightArm(); + displayLeftArm(); + + if(lightningEnabled) + checkIfZapped(); + } + + private boolean canPlaceBlock(Block block){ + if(!EarthMethods.isTransparentToEarthbending(player, block) && !(WaterMethods.isWater(block) && TempBlock.isTempBlock(block))) + return false; + return true; + } + + /** + * Displays the right arm. + * Returns false if the arm cannot be fully displayed. + * @return + */ + public boolean displayRightArm(){ + if(rightArmConsumed) + return false; + + Location r1 = GeneralMethods.getRightSide(player.getLocation(), 1).add(0, 1.5, 0); + if(!canPlaceBlock(r1.getBlock())) + return false; + + if(!(getRightHandPos().getBlock().getLocation().equals(r1.getBlock().getLocation()))){ + new TempBlock(r1.getBlock(), Material.STATIONARY_WATER, (byte) 5); + revert.put(r1.getBlock(), 0L); + } + + Location r2 = GeneralMethods.getRightSide(player.getLocation(), 2).add(0, 1.5, 0); + if(!canPlaceBlock(r2.getBlock())) + return false; + + new TempBlock(r2.getBlock(), Material.STATIONARY_WATER, (byte) 0); + revert.put(r2.getBlock(), 0L); + + for(int j = 0; j <= initLength; j++){ + Location r3 = r2.clone().toVector().add(player.getLocation().clone().getDirection().multiply(j)).toLocation(player.getWorld()); + if(!canPlaceBlock(r3.getBlock())){ + if(selectedSlot == freezeSlot && r3.getBlock().getType().equals(Material.ICE)) + continue; + return false; + } + + if(j >= 1 && selectedSlot == freezeSlot){ + new TempBlock(r3.getBlock(), Material.ICE, (byte) 0); + revert.put(r3.getBlock(), 0L); + }else{ + new TempBlock(r3.getBlock(), Material.STATIONARY_WATER, (byte) 0); + revert.put(r3.getBlock(), 0L); + } + } + + return true; + } + + /** + * Displays the left arm. + * Returns false if the arm cannot be fully displayed. + * @return + */ + public boolean displayLeftArm(){ + if(leftArmConsumed) + return false; + + Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 1).add(0, 1.5, 0); + if(!canPlaceBlock(l1.getBlock())) + return false; + + if(!(getLeftHandPos().getBlock().getLocation().equals(l1.getBlock().getLocation()))){ + new TempBlock(l1.getBlock(), Material.STATIONARY_WATER, (byte) 5); + revert.put(l1.getBlock(), 0L); + } + + Location l2 = GeneralMethods.getLeftSide(player.getLocation(), 2).add(0, 1.5, 0); + if(!canPlaceBlock(l2.getBlock())) + return false; + + new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, (byte) 0); + revert.put(l2.getBlock(), 0L); + + for(int j = 0; j <= initLength; j++){ + Location l3 = l2.clone().toVector().add(player.getLocation().clone().getDirection().multiply(j)).toLocation(player.getWorld()); + if(!canPlaceBlock(l3.getBlock())){ + if(selectedSlot == freezeSlot && l3.getBlock().getType().equals(Material.ICE)) + continue; + return false; + } + + if(j >= 1 && selectedSlot == freezeSlot){ + new TempBlock(l3.getBlock(), Material.ICE, (byte) 0); + revert.put(l3.getBlock(), 0L); + }else{ + new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, (byte) 0); + revert.put(l3.getBlock(), 0L); + } + } + + return true; + } + + /** + * Calculate roughly where the player's right hand is. + * @return + */ + private Location getRightHandPos(){ + return GeneralMethods.getRightSide(player.getLocation(), .34).add(0, 1.5, 0); + } + + /** + * Calculate roughly where the player's left hand is. + * @return + */ + private Location getLeftHandPos(){ + return GeneralMethods.getLeftSide(player.getLocation(), .34).add(0, 1.5, 0); + } + + /** + * Returns the location of the tip of the right arm, assuming it is fully extended. + * Use the displayRightArm() check to see if it is fully extended. + * @return + */ + public Location getRightArmEnd(){ + Location r1 = GeneralMethods.getRightSide(player.getLocation(), 2).add(0, 1.5, 0); + return r1.clone().add(player.getLocation().getDirection().normalize().multiply(initLength)); + } + + /** + * Returns the location of the tip of the left arm assuming it is fully extended. + * Use the displayLeftArm() check to see if it is fully extended. + * @return + */ + public Location getLeftArmEnd(){ + Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 2).add(0, 1.5, 0); + return l1.clone().add(player.getLocation().getDirection().normalize().multiply(initLength)); + } + + private static void progressRevert(boolean ignoreTime){ + for(Block block : revert.keySet()){ + long time = revert.get(block); + if(System.currentTimeMillis() > time || ignoreTime){ + if(TempBlock.isTempBlock(block)) + TempBlock.revertBlock(block, Material.AIR); + revert.remove(block); + } + } + } + + private static void trackEntities(boolean remove){ + for(FallingBlock fallingBlock : falling.keySet()){ + if(remove){ + fallingBlock.remove(); + falling.remove(fallingBlock); + } + + if(!fallingBlock.isDead()){ + for(Entity entity : GeneralMethods.getEntitiesAroundPoint(fallingBlock.getLocation(), 2.0)){ + if(entity instanceof LivingEntity){ + if(!pullBlocksDamageUser && entity.getEntityId() == falling.get(fallingBlock).getEntityId()) + continue; + GeneralMethods.damageEntity(falling.get(fallingBlock), entity, blockDamage); + fallingBlock.remove(); + falling.remove(fallingBlock); + } + } + } + } + } + + private void checkIfZapped(){ + for (int i = 0; i < Lightning.instances.size(); i++){ + Lightning l = Lightning.instances.get(i); + for(Lightning.Arc arc : l.getArcs()){ + for(Block arm : revert.keySet()){ + for(Location loc : arc.getPoints()){ + if(arm.getLocation().getWorld() == loc.getWorld() && loc.distance(arm.getLocation()) <= 2.5){ + for(Location l1 : getOffsetLocations(4, arm.getLocation(), 1.25)) + FireMethods.playLightningbendingParticle(l1); + if(lightningKill) + GeneralMethods.damageEntity(Lightning.instances.get(i).getPlayer(), player, 60D); + else + GeneralMethods.damageEntity(Lightning.instances.get(i).getPlayer(), player, lightningDamage); + } + } + } + } + } + } + + private static List getOffsetLocations(int amount, Location location, double offset){ + List locations = new ArrayList(); + for(int i = 0; i < amount; i++) + locations.add(location.clone().add((float) (Math.random()*offset), (float) (Math.random()*offset), (float) (Math.random()*offset))); + return locations; + } + + public static void remove(Player player){ + if(instances.containsKey(player)) + instances.get(player).remove(); + } + + public void remove(){ + MultiAbilityManager.unbindMultiAbility(player); + if(player.isOnline()) + GeneralMethods.getBendingPlayer(player.getName()).addCooldown("WaterArms", cooldown); + instances.remove(player); + } + + public void prepareCancel(){ + if(System.currentTimeMillis() < lastClickTime + 500L){ + remove(); + }else{ + lastClickTime = System.currentTimeMillis(); + } + } + + public static void progressAll(){ + progressRevert(false); + trackEntities(false); + for(Player p : instances.keySet()) + instances.get(p).progress(); + WaterArmsWhip.progressAll(); + } + + public static void removeAll(){ + progressRevert(true); + trackEntities(true); + revert.clear(); + falling.clear(); + instances.clear(); + WaterArmsWhip.removeAll(); + } + + + @SuppressWarnings("deprecation") + public static boolean isUnbreakable(Block block) { + if (Arrays.asList(unbreakable).contains(block.getTypeId())) return true; + return false; + } + + /** + * Returns the active arm of the player. + * @return + */ + public Arm getActiveArm(){ + return activeArm; + } + + /** + * Switches the active arm of a player. + */ + public void switchActiveArm(){ + if(activeArm.equals(Arm.Right)) + activeArm = Arm.Left; + else + activeArm = Arm.Right; + } + + /** + * Switches to the most suitable arm for the player. + * @return + */ + public Arm switchPreferredArm(){ + switchActiveArm(); + if(activeArm.equals(Arm.Left)){ + if(!displayLeftArm()){ + switchActiveArm(); + } + } + if(activeArm.equals(Arm.Right)){ + if(!displayRightArm()){ + switchActiveArm(); + } + } + return getActiveArm(); + } + + public boolean canDisplayCurrentArm(){ + switch(activeArm){ + case Left: + return displayLeftArm(); + case Right: + return displayRightArm(); + default: + return false; + } + } + + public Player getPlayer(){ + return player; + } + + public Boolean isFullSource(){ + return fullSource; + } + + public Integer getLengthReduction(){ + return lengthReduction; + } + + public void setLengthReduction(int lengthReduction){ + this.lengthReduction = lengthReduction; + } + + public Integer getMaxPunches(){ + return maxPunches; + } + + public void setMaxPunches(int maxPunches){ + this.maxPunches = maxPunches; + } + + public Integer getMaxUses(){ + return maxUses; + } + + public void setMaxUses(int maxUses){ + this.maxUses = maxUses; + } + + public Integer getMaxIceBlasts(){ + return maxIceBlasts; + } + + public void setMaxIceBlasts(int maxIceBlasts){ + this.maxIceBlasts = maxIceBlasts; + } + + public boolean canLightningDamage(){ + return lightningEnabled; + } + + public void setCanLightningDamage(boolean lightningEnabled){ + this.lightningEnabled = lightningEnabled; + } + + public double getLightningDamage(){ + return lightningDamage; + } + + public void setLightningDamage(double lightningDamage){ + this.lightningDamage = lightningDamage; + } + + public boolean isLeftArmCooldown(){ + return cooldownLeft; + } + + public void setLeftArmCooldown(boolean cooldown){ + this.cooldownLeft = cooldown; + } + + public boolean isRightArmCooldown(){ + return cooldownRight; + } + + public void setRightArmCooldown(boolean cooldown){ + this.cooldownRight = cooldown; + } + + public void setActiveArmCooldown(boolean cooldown){ + switch(activeArm){ + case Left: + setLeftArmCooldown(cooldown); + return; + case Right: + setRightArmCooldown(cooldown); + return; + default: + break; + } + } + + public long getCooldown() { + return cooldown; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } +} \ No newline at end of file diff --git a/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsWhip.java b/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsWhip.java new file mode 100644 index 00000000..6598db3c --- /dev/null +++ b/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsWhip.java @@ -0,0 +1,432 @@ +package com.projectkorra.ProjectKorra.waterbending; + +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import com.projectkorra.ProjectKorra.BendingManager; +import com.projectkorra.ProjectKorra.BendingPlayer; +import com.projectkorra.ProjectKorra.Commands; +import com.projectkorra.ProjectKorra.GeneralMethods; +import com.projectkorra.ProjectKorra.MultiAbilityManager; +import com.projectkorra.ProjectKorra.ProjectKorra; +import com.projectkorra.ProjectKorra.TempBlock; +import com.projectkorra.ProjectKorra.earthbending.EarthMethods; +import com.projectkorra.ProjectKorra.waterbending.WaterArms.Arm; +import com.projectkorra.rpg.WorldEvents; + +public class WaterArmsWhip{ + + /** + * Whip Enum value for deciding what ability should be executed. + */ + public enum Whip { + Pull, Punch, Grapple, Grab; + } + + private static FileConfiguration config = ProjectKorra.plugin.getConfig(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap(); + public static ArrayList grabbedEntities = new ArrayList(); + + private Player player; + private WaterArms waterArms; + + private int whipLength = config.getInt("Abilities.Water.WaterArms.WhipMode.MaxLength"); + private int whipLengthWeak = config.getInt("Abilities.Water.WaterArms.WhipMode.MaxLengthWeak"); + + private int whipLengthNight = config.getInt("Abilities.Water.WaterArms.WhipMode.NightAugments.MaxLength.Normal"); + private int whipLengthFullMoon = config.getInt("Abilities.Water.WaterArms.WhipMode.NightAugments.MaxLength.FullMoon"); + + private int initLength = config.getInt("Abilities.Water.WaterArms.Arms.InitialLength"); + private double damage = config.getDouble("Abilities.Water.WaterArms.WhipMode.Punch.PunchDamage"); + private boolean pullBlocks = config.getBoolean("Abilities.Water.WaterArms.WhipMode.Pull.PullBlocks"); + private long pullBlocksRevertDelay = config.getLong("Abilities.Water.WaterArms.WhipMode.Pull.BlockRevertDelay"); + private boolean grappleRespectRegions = config.getBoolean("Abilities.Water.WaterArms.WhipMode.Grapple.RespectRegions"); + private boolean usageCooldownEnabled = config.getBoolean("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldownEnabled"); + private long usageCooldown = config.getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown"); + + private int activeLength = initLength; + private int whipSpeed = 2; + private boolean reverting = false; + private boolean damaged = false; + private boolean grappled = false; + private boolean grabbed = false; + private LivingEntity grabbedEntity; + private Location end; + private Arm arm; + private Whip ability; + + private int id; + private static int ID = Integer.MIN_VALUE; + + public WaterArmsWhip(Player player, Whip m){ + this.player = player; + ability = m; + getNightAugments(); + createInstance(); + } + + private void getNightAugments(){ + World world = player.getWorld(); + if(WaterMethods.isNight(world)){ + if(GeneralMethods.hasRPG()){ + if(BendingManager.events.get(world).equalsIgnoreCase(WorldEvents.LunarEclipse.toString())){ + whipLength = whipLengthFullMoon; + }else if (BendingManager.events.get(world).equalsIgnoreCase("FullMoon")){ + whipLength = whipLengthFullMoon; + }else{ + whipLength = whipLengthNight; + } + }else{ + if(WaterMethods.isFullMoon(world)){ + whipLength = whipLengthFullMoon; + }else{ + whipLength = whipLengthNight; + } + } + } + } + + private void createInstance(){ + if(WaterArms.instances.containsKey(player)){ + waterArms = WaterArms.instances.get(player); + waterArms.switchPreferredArm(); + arm = waterArms.getActiveArm(); + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + if(arm.equals(Arm.Left)){ + if(waterArms.isLeftArmCooldown() || bPlayer.isOnCooldown("WaterArms_LEFT")){ + return; + }else{ + if(usageCooldownEnabled) + bPlayer.addCooldown("WaterArms_LEFT", usageCooldown); + waterArms.setLeftArmCooldown(true); + } + } + if(arm.equals(Arm.Right)){ + if(waterArms.isRightArmCooldown() || bPlayer.isOnCooldown("WaterArms_RIGHT")){ + return; + }else{ + if(usageCooldownEnabled) + bPlayer.addCooldown("WaterArms_RIGHT", usageCooldown); + waterArms.setRightArmCooldown(true); + } + } + }else{ + return; + } + if(!waterArms.isFullSource()){ + whipLength = whipLengthWeak; + } + id = ID; + instances.put(id, this); + if (ID == Integer.MAX_VALUE) + ID = Integer.MIN_VALUE; + ID++; + } + + private void progress(){ + if(!WaterArms.instances.containsKey(player)){ + remove(); + return; + } + if(player.isDead() || !player.isOnline()){ + remove(); + return; + } + if(!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")){ + remove(); + return; + } + + if(activeLength < whipLength && !reverting){ + activeLength+=whipSpeed; + }else if(activeLength > initLength){ + if(!grabbed){ + activeLength-=whipSpeed; + } + }else{ + remove(); + return; + } + + if(activeLength == whipLength && !grabbed){ + reverting = true; + } + + if(arm.equals(Arm.Left)){ + useLeftArm(); + }else{ + useRightArm(); + } + dragEntity(end); + grapplePlayer(end); + } + + //START OF RECODE + + private boolean canPlaceBlock(Block block){ + if(!EarthMethods.isTransparentToEarthbending(player, block) && !(WaterMethods.isWater(block) && TempBlock.isTempBlock(block))){ + return false; + } + return true; + } + + private void useLeftArm(){ + if(waterArms.displayLeftArm()){ + Location l1 = waterArms.getLeftArmEnd().clone(); + Vector dir = player.getLocation().getDirection(); + for(int i = 1; i <= activeLength; i++){ + Location l2 = l1.clone().add(dir.normalize().multiply(i)); + + if(!canPlaceBlock(l2.getBlock())){ + if(!l2.getBlock().getType().equals(Material.BARRIER)){ + grappled = true; + } + reverting = true; + break; + } + + new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, (byte) 0); + WaterArms.revert.put(l2.getBlock(), 0L); + + if(i == activeLength){ + Location l3 = GeneralMethods.getRightSide(l2, 1); + end = l3.clone(); + if(canPlaceBlock(l3.getBlock())){ + new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, (byte) 3); + WaterArms.revert.put(l3.getBlock(), 0L); + checkLocation(l3); + }else{ + if(!l3.getBlock().getType().equals(Material.BARRIER)){ + grappled = true; + } + reverting = true; + } + } + } + } + } + + private void useRightArm(){ + if(waterArms.displayLeftArm()){ + Location l1 = waterArms.getRightArmEnd().clone(); + Vector dir = player.getLocation().getDirection(); + for(int i = 1; i <= activeLength; i++){ + Location l2 = l1.clone().add(dir.normalize().multiply(i)); + + if(!canPlaceBlock(l2.getBlock())){ + if(!l2.getBlock().getType().equals(Material.BARRIER)){ + grappled = true; + } + reverting = true; + break; + } + + new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, (byte) 0); + WaterArms.revert.put(l2.getBlock(), 0L); + + if(i == activeLength){ + Location l3 = GeneralMethods.getLeftSide(l2, 1); + end = l3.clone(); + if(canPlaceBlock(l3.getBlock())){ + new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, (byte) 3); + WaterArms.revert.put(l3.getBlock(), 0L); + checkLocation(l3); + }else{ + if(!l3.getBlock().getType().equals(Material.BARRIER)){ + grappled = true; + } + reverting = true; + } + } + } + } + } + + private void checkLocation(Location location){ + Location endOfArm = waterArms.getLeftArmEnd().clone(); + switch(ability){ + case Pull: + for(Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)){ + if(entity instanceof Player && Commands.invincible.contains(((Player) entity).getName())){ + continue; + } + Vector vector = endOfArm.toVector().subtract(entity.getLocation().toVector()); + entity.setVelocity(vector.multiply(0.15)); + } + break; + case Punch: + for(Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)){ + if(entity instanceof Player && Commands.invincible.contains(((Player) entity).getName())){ + continue; + } + Vector vector = entity.getLocation().toVector().subtract(endOfArm.toVector()); + entity.setVelocity(vector.multiply(0.15)); + if(entity instanceof LivingEntity){ + if(entity.getEntityId() != player.getEntityId()){ + damaged = true; + GeneralMethods.damageEntity(player, entity, damage); + } + } + } + break; + case Grapple: + grapplePlayer(end); + break; + case Grab: + if(grabbedEntity == null){ + for(Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)){ + if(entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId() && !grabbedEntities.contains(entity)){ + System.out.println("Grabbed Entity!"); + grabbedEntities.add((LivingEntity) entity); + grabbedEntity = (LivingEntity) entity; + grabbed = true; + reverting = true; + waterArms.setActiveArmCooldown(true); + break; + } + } + } + break; + default: + break; + } + } + + private void dragEntity(Location location){ + if(grabbedEntity != null){ + if(!waterArms.canDisplayCurrentArm() || grabbedEntity.isDead()){ + grabbed = false; + grabbedEntities.remove(grabbedEntity); + return; + } + Location newlocation = grabbedEntity.getLocation(); + double distance = location.distance(newlocation); + double dx, dy, dz; + dx = location.getX() - newlocation.getX(); + dy = location.getY() - newlocation.getY(); + dz = location.getZ() - newlocation.getZ(); + Vector vector = new Vector(dx, dy, dz); + if (distance > .5) { + grabbedEntity.setVelocity(vector.normalize().multiply(1)); + } else { + grabbedEntity.setVelocity(new Vector(0, 0, 0)); + } + grabbedEntity.setFallDistance(0); + if (grabbedEntity instanceof Creature) { + ((Creature) grabbedEntity).setTarget(null); + } + } + } + + private void grapplePlayer(Location location){ + if(reverting && grappled && player != null && end != null && ability.equals(Whip.Grapple)){ + Vector vector = player.getLocation().toVector().subtract(location.toVector()); + player.setVelocity(vector.multiply(-0.25)); + player.setFallDistance(0); + } + } + + //END OF RECODE + + @SuppressWarnings("deprecation") + private void spawnFallingBlock(Location location, Location armbase){ + Block block = location.getBlock(); + Material mat = block.getType(); + byte data = block.getData(); + if(!GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", location)){ + Location spawnLoc = location.clone().toVector().subtract(player.getLocation().clone().getDirection().multiply(1)).toLocation(player.getWorld()); + + new TempBlock(block, Material.AIR, (byte) 0); + WaterArms.revert.put(block, System.currentTimeMillis() + pullBlocksRevertDelay); + + if(!WaterArms.isUnbreakable(spawnLoc.getBlock())){ + new TempBlock(spawnLoc.getBlock(), Material.AIR, (byte) 0); + WaterArms.revert.put(spawnLoc.getBlock(), System.currentTimeMillis() + pullBlocksRevertDelay); + }else{ + return; + } + + FallingBlock fBlock = player.getWorld().spawnFallingBlock(spawnLoc.clone(), mat, data); + fBlock.setDropItem(false); + Vector from = fBlock.getLocation().toVector(); + Vector to = armbase.clone().toVector(); + Vector vector = to.subtract(from); + fBlock.setVelocity(vector.multiply(0.15)); + WaterArms.falling.put(fBlock, player); + } + } + + private boolean canModifyBlock(Block block, Location toLoc){ + if(!EarthMethods.isTransparentToEarthbending(player, block) && !WaterMethods.isWater(block)){ + if(GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", block.getLocation())){ + if(!grappleRespectRegions() && block.getType().isSolid() && !EarthMethods.isTransparentToEarthbending(player, block)) + grappled = true; + reverting = true; + return true; + } + if(EarthMethods.isTransparentToEarthbending(player, block)){ + if(!block.getType().equals(Material.BARRIER)){ + grappled = true; + } + reverting = true; + return true; + } + if(!(TempBlock.isTempBlock(block) && TempBlock.get(block).equals(Material.AIR))){ + if(!block.isLiquid() && block.getType().isSolid() && ability.equals(Whip.Pull) && pullBlocks && player.hasPermission("bending.ability.WaterArms.PullBlocks")){ + if(!EarthMethods.isTransparentToEarthbending(player, block)) + spawnFallingBlock(block.getLocation(), toLoc); + } + grappled = true; + reverting = true; + return true; + } + } + return false; + } + + private boolean grappleRespectRegions(){ + if(!grappleRespectRegions) + if(!ability.equals(Whip.Grapple)) + return true; + else + return false; + else + return true; + } + + private void remove(){ + if(WaterArms.instances.containsKey(player)){ + if(arm.equals(Arm.Left)){ + waterArms.setLeftArmCooldown(false); + }else{ + waterArms.setRightArmCooldown(false); + } + if(damaged) + waterArms.setMaxPunches(waterArms.getMaxPunches() - 1); + waterArms.setMaxUses(waterArms.getMaxUses() - 1); + } + instances.remove(id); + } + + public static void progressAll(){ + for(int ID : instances.keySet()) + instances.get(ID).progress(); + } + + public static void removeAll(){ + instances.clear(); + } +} \ No newline at end of file From 3d01e279657cab0672f43234498fa3278e710709 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:19:23 +0100 Subject: [PATCH 15/25] Added support for MultiAbilityManager. Makes sure that abilities can't be bound while a MultiAbility is active. --- .../projectkorra/ProjectKorra/Commands.java | 3723 +++++++++-------- 1 file changed, 1866 insertions(+), 1857 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/Commands.java b/src/com/projectkorra/ProjectKorra/Commands.java index b7caefea..23abb11e 100644 --- a/src/com/projectkorra/ProjectKorra/Commands.java +++ b/src/com/projectkorra/ProjectKorra/Commands.java @@ -1,1857 +1,1866 @@ -package com.projectkorra.ProjectKorra; - -import java.io.File; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.PluginCommand; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scheduler.BukkitTask; - -import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; -import com.projectkorra.ProjectKorra.Ability.StockAbilities; -import com.projectkorra.ProjectKorra.Ability.Combo.ComboAbilityModule; -import com.projectkorra.ProjectKorra.Ability.Combo.ComboModuleManager; -import com.projectkorra.ProjectKorra.CustomEvents.PlayerChangeElementEvent; -import com.projectkorra.ProjectKorra.CustomEvents.PlayerChangeElementEvent.Result; -import com.projectkorra.ProjectKorra.Objects.Preset; -import com.projectkorra.ProjectKorra.Utilities.GrapplingHookAPI; -import com.projectkorra.ProjectKorra.airbending.AirMethods; -import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; -import com.projectkorra.ProjectKorra.earthbending.EarthMethods; -import com.projectkorra.ProjectKorra.firebending.FireMethods; -import com.projectkorra.ProjectKorra.waterbending.WaterMethods; -import com.projectkorra.rpg.RPGMethods; - -public class Commands { - - ProjectKorra plugin; - - public Commands(ProjectKorra plugin) { - this.plugin = plugin; - init(); - } - - /* - * Element Aliases - */ - String[] airaliases = {"air", "a", "airbending", "airbender"}; - String[] wateraliases = {"water", "w", "waterbending", "waterbender"}; - String[] earthaliases = {"earth", "e", "earthbending", "earthbender"}; - String[] firealiases = {"fire", "f", "firebending", "firebender"}; - String[] chialiases = {"chi", "c", "chiblocking", "chiblocker"}; - - /* - * Subelement Aliases - */ - - //Air - String[] flightaliases = {"flight", "fl"}; - String[] spiritualprojectionaliases = {"spiritualprojection", "sp", "spiritual"}; - - //Water - String[] bloodaliases = {"bloodbending", "bb"}; - String[] healingaliases = {"healing", "heal"}; - String[] plantaliases = {"plantbending", "plant"}; - - //Earth - String[] metalbendingaliases = {"metalbending", "mb", "metal"}; - String[] lavabendingaliases = {"lavabending", "lb", "lava"}; - String[] sandbendingaliases = {"sandbending", "sb", "sand"}; - - //Firebending - String[] combustionaliases = {"combustionbending", "combustion", "cb"}; - String[] lightningaliases = {"lightningbending", "lightning"}; - - - /* - * Command Aliases - */ - String[] helpaliases = {"help", "h"}; - String[] versionaliases = {"version", "v"}; - String[] permaremovealiases = {"permaremove", "premove", "permremove", "pr"}; - String[] choosealiases = {"choose", "ch"}; - String[] removealiases = {"remove", "rm"}; - String[] togglealiases = {"toggle", "t"}; - String[] displayaliases = {"display", "d"}; - String[] bindaliases = {"bind", "b"}; - String[] clearaliases = {"clear", "cl", "c"}; - String[] reloadaliases = {"reload", "r"}; - String[] addaliases = {"add", "a"}; - String[] whoaliases = {"who", "w"}; - String[] importaliases = {"import", "i"}; - String[] givealiases = {"give", "g", "spawn"}; - String[] invinciblealiases = {"invincible", "inv"}; - String[] presetaliases = {"preset", "presets", "pre", "set", "p"}; - String[] avataraliases = {"avatar", "ava"}; - - /* - * Item Aliases - */ - - public static Set invincible = new HashSet(); - - String[] grapplinghookaliases = {"grapplinghook", "grapplehook", "hook", "ghook"}; - - public static boolean debug = ProjectKorra.plugin.getConfig().getBoolean("debug"); - - public static boolean isToggledForAll = false; - - private static BukkitTask importTask; - private void init() { - PluginCommand projectkorra = plugin.getCommand("projectkorra"); - CommandExecutor exe; - - exe = new CommandExecutor() { - @SuppressWarnings("deprecation") - @Override - public boolean onCommand(CommandSender s, Command c, String label, String[] args) { - for(int i = 0; i < args.length; i++){ - args[i] = args[i].toLowerCase(); - } - if (args.length == 0) { - s.sendMessage(ChatColor.RED + "/bending help [Ability/Command] " + ChatColor.YELLOW + "Display help."); - s.sendMessage(ChatColor.RED + "/bending choose [Element] " + ChatColor.YELLOW + "Choose an element."); - s.sendMessage(ChatColor.RED + "/bending bind [Ability] # " + ChatColor.YELLOW + "Bind an ability."); - return true; - } - if (Arrays.asList(avataraliases).contains(args[0].toLowerCase())) { - if (!GeneralMethods.hasRPG()) { - s.sendMessage(ChatColor.RED + "This command cannot be used unless you have ProjectKorra (RPG) installed."); - return true; - } - - if (!s.hasPermission("bending.command.avatar")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (args.length != 2) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending avatar [Player]"); - return true; - } - - Player player = Bukkit.getPlayer(args[1]); - if (player == null) { - s.sendMessage(ChatColor.RED + "That player is not online."); - return true; - } - - UUID uuid = player.getUniqueId(); - - if (RPGMethods.hasBeenAvatar(uuid)) { - s.sendMessage(ChatColor.RED + "This player has already been the Avatar."); - return true; - } - - RPGMethods.setAvatar(uuid); - s.sendMessage(ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " is now the Avatar."); - player.sendMessage("You are now the Avatar."); - return true; - - } - if (args[0].equalsIgnoreCase("debug")) { - if (args.length != 1) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending debug"); - return true; - } - - if (!s.hasPermission("bending.admin.debug")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - GeneralMethods.runDebug(); - s.sendMessage(ChatColor.GREEN + "Debug File Created as debug.txt in the ProjectKorra plugin folder."); - s.sendMessage(ChatColor.GREEN + "Put contents on pastie.org and create a bug report on the ProjectKorra forum if you need to."); - return true; - } - if (Arrays.asList(presetaliases).contains(args[0].toLowerCase())) { - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "This command is only usable by players."); - return true; - } - - Player player = (Player) s; - - String[] deletealiases = {"delete", "d", "del"}; - String[] createaliases = {"create", "c", "save"}; - String[] listaliases = {"list", "l"}; - if (args.length == 2 && Arrays.asList(listaliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.preset.list")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - List listnames = Preset.presets.get(player.getUniqueId()); - List ln2 = new ArrayList(); - - if (listnames == null || listnames.isEmpty()) { - s.sendMessage(ChatColor.RED + "You don't have any presets."); - return true; - } - - for (Preset preset: listnames) { - ln2.add(preset.getName()); - } - - s.sendMessage(ChatColor.GREEN + "Your Presets: " + ChatColor.DARK_AQUA + ln2.toString()); - return true; - - }else if (args.length != 3) { // bending preset bind|create|delete {name} - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending preset create|bind|list|delete [name]"); - return true; - } - - String name = args[2]; - - if (Arrays.asList(deletealiases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.preset.delete")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - if (!Preset.presetExists(player, name)) { - s.sendMessage(ChatColor.RED + "You don't have a preset with that name."); - return true; - } - - Preset preset = Preset.getPreset(player, name); - preset.delete(); - s.sendMessage(ChatColor.GREEN + "You have deleted your preset named: " + name); - } - - if (Arrays.asList(bindaliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.preset.bind")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (!Preset.presetExists(player, name)) { - s.sendMessage(ChatColor.RED + "You don't have a preset with that name."); - return true; - } - - Preset.bindPreset(player, name); - s.sendMessage(ChatColor.GREEN + "Your bound slots have been set to match the " + name + " preset."); - return true; - } - - if (Arrays.asList(createaliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.preset.create")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - int limit = GeneralMethods.getMaxPresets(player); - - if (Preset.presets.get(player) != null && Preset.presets.get(player).size() >= limit) { - s.sendMessage(ChatColor.RED + "You have reached your max number of Presets."); - return true; - } - - if (Preset.presetExists(player, name)) { - s.sendMessage(ChatColor.RED + "A preset with that name already exists."); - return true; - } - - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - - if (bPlayer == null) return true; - - HashMap abilities = bPlayer.getAbilities(); - Preset preset = new Preset(player.getUniqueId(), name, abilities); - preset.save(); - s.sendMessage(ChatColor.GREEN + "Created preset with the name: " + name); - return true; - } - - } - if (Arrays.asList(invinciblealiases).contains(args[0].toLowerCase())) { - if (!s.hasPermission("bending.command.invincible")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "This command is only usable by players."); - return true; - } - - if (args.length != 1) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending invincible"); - return true; - } - - if (!invincible.contains(s.getName())) { - /* - * Player is not invincible. - */ - invincible.add(s.getName()); - s.sendMessage(ChatColor.GREEN + "You are now invincible to all bending damage and effects. Use this command again to disable this."); - return true; - } else { - invincible.remove(s.getName()); - s.sendMessage(ChatColor.RED + "You are no longer invincible to all bending damage and effects."); - } - } - if (Arrays.asList(givealiases).contains(args[0].toLowerCase())) { - if (!s.hasPermission("bending.command.give")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (args.length < 3) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending give [Player] [Item] "); - return true; - } - - Player player = Bukkit.getPlayer(args[1]); - - if (player == null) { - s.sendMessage(ChatColor.RED + "That player is not online."); - return true; - } - - if (Arrays.asList(grapplinghookaliases).contains(args[2].toLowerCase())) { - /* - * They are spawning in a grappling hook. - * bending give [Player] grapplinghook [# of Uses] - */ - - if (args.length != 4) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending give [Player] GrapplingHook <#OfUses>"); - return true; - } - int uses; - try { - uses = Integer.parseInt(args[3]); - } catch (NumberFormatException e) { - s.sendMessage(ChatColor.RED + "You must specify a number of uses you want the grappling hook to have."); - s.sendMessage(ChatColor.GOLD + "Example: /bending give " + s.getName() + " grapplinghook 25"); - return true; - } - - ItemStack hook = GrapplingHookAPI.createHook(uses); - player.getInventory().addItem(hook); - s.sendMessage(ChatColor.GREEN + "A grappling hook with " + uses + " uses has been added to your inventory."); - return true; - } else { - s.sendMessage(ChatColor.RED + "That is not a valid Bending item."); - s.sendMessage(ChatColor.GOLD + "Acceptable Items: GrapplingHook"); - return true; - } - } - if (Arrays.asList(reloadaliases).contains(args[0].toLowerCase())) { - if (args.length != 1) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending reload"); - return true; - } - - if (!s.hasPermission("bending.command.reload")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - GeneralMethods.reloadPlugin(); - s.sendMessage(ChatColor.AQUA + "Bending config reloaded."); - return true; - } - if (Arrays.asList(clearaliases).contains(args[0].toLowerCase())) { - if (args.length > 2) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending clear <#>"); - return true; - } - if (!s.hasPermission("bending.command.clear")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "This command is only usable by players."); - return true; - } - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); - if (args.length == 1) { - bPlayer.getAbilities().clear(); - for (int i = 1; i <= 9; i++) { - GeneralMethods.saveAbility(bPlayer, i, null); - } - s.sendMessage("Your bound abilities have been cleared."); - return true; - } - - if (args.length == 2) { - try { - int slot = Integer.parseInt(args[1]); - if (slot < 1 || slot > 9) { - s.sendMessage(ChatColor.RED + "The slot must be an integer between 0 and 9."); - return true; - } - if (bPlayer.getAbilities().get(slot) != null) { - bPlayer.getAbilities().remove(slot); - GeneralMethods.saveAbility(bPlayer, slot, null); - } - s.sendMessage("You have cleared slot #" + slot); - return true; - } catch (NumberFormatException e) { - s.sendMessage(ChatColor.RED + "The slot must be an integer between 0 and 9."); - } - } - } - if (Arrays.asList(bindaliases).contains(args[0].toLowerCase())) { - if (args.length > 3 || args.length == 1) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending bind [Ability] <#>"); - return true; - } - - if (!s.hasPermission("bending.command.bind")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (args.length == 2) { - // We bind the ability to the slot they have selected.. - // bending bind [Ability] - String abil = args[1]; - if (!GeneralMethods.abilityExists(abil)) { - s.sendMessage(ChatColor.RED + "That is not an ability."); - return true; - } - - String ability = GeneralMethods.getAbility(abil); - - if (!GeneralMethods.canBind(((Player) s).getName(), ability)) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - - } - if (AirMethods.isAirAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Air)) { - s.sendMessage(AirMethods.getAirColor() + "You must be an Airbender to bind this ability."); - return true; - } - if (WaterMethods.isWaterAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Water)) { - s.sendMessage(WaterMethods.getWaterColor() + "You must be a Waterbender to bind this ability."); - return true; - } - if (EarthMethods.isEarthAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Earth)) { - s.sendMessage(EarthMethods.getEarthColor() + "You must be an Earthbender to bind this ability."); - return true; - } - if (FireMethods.isFireAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Fire)) { - s.sendMessage(FireMethods.getFireColor() + "You must be a Firebender to bind this ability."); - return true; - } - if (ChiMethods.isChiAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Chi)) { - s.sendMessage(ChiMethods.getChiColor() + "You must be a ChiBlocker to bind this ability."); - return true; - } - - GeneralMethods.bindAbility((Player) s, ability); - // s.sendMessage("Ability Bound to slot"); - return true; - } - - if (args.length == 3) { - // bending bind ability [Slot] - String abil = args[1]; - if (!GeneralMethods.abilityExists(abil)) { - s.sendMessage(ChatColor.RED + "That ability doesn't exist."); - return true; - } - String ability = GeneralMethods.getAbility(abil); - int slot = 0; - try { - slot = Integer.parseInt(args[2]); - } catch (NumberFormatException e) { - s.sendMessage(ChatColor.RED + "Slot must be an integer between 1 and 9."); - return true; - } - if (slot < 1 || slot > 9) { - s.sendMessage(ChatColor.RED + "Slot must be an integer between 1 and 9."); - return true; - } - - if (!GeneralMethods.canBind(((Player) s).getName(), ability)) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (AirMethods.isAirAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Air)) { - s.sendMessage(AirMethods.getAirColor() + "You must be an Airbender to bind this ability."); - return true; - } - if (WaterMethods.isWaterAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Water)) { - s.sendMessage(WaterMethods.getWaterColor() + "You must be a Waterbender to bind this ability."); - return true; - } - if (EarthMethods.isEarthAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Earth)) { - s.sendMessage(EarthMethods.getEarthColor() + "You must be an Earthbender to bind this ability."); - return true; - } - if (FireMethods.isFireAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Fire)) { - s.sendMessage(FireMethods.getFireColor() + "You must be a Firebender to bind this ability."); - return true; - } - if (ChiMethods.isChiAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Chi)) { - s.sendMessage(ChiMethods.getChiColor() + "You must be a ChiBlocker to bind this ability."); - return true; - } - GeneralMethods.bindAbility((Player) s, ability, slot); - // s.sendMessage("Ability Bound"); - return true; - } - } - if (Arrays.asList(importaliases).contains(args[0].toLowerCase())) { - if (!s.hasPermission("bending.command.import")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - if (!GeneralMethods.isImportEnabled()) { - s.sendMessage(ChatColor.RED + "Importing has been disabled in the config"); - return true; - } - - s.sendMessage(ChatColor.GREEN + "Preparing data for import."); - File bendingPlayersFile = new File(".", "converted.yml"); - FileConfiguration bendingPlayers = YamlConfiguration.loadConfiguration(bendingPlayersFile); - - final LinkedList bPlayers = new LinkedList(); - for (String string: bendingPlayers.getConfigurationSection("").getKeys(false)) { - if (string.equalsIgnoreCase("version")) continue; - String playername = string; - UUID uuid = Bukkit.getOfflinePlayer(playername).getUniqueId(); - ArrayList element = new ArrayList(); - List oe = bendingPlayers.getIntegerList(string + ".BendingTypes"); - HashMap abilities = new HashMap(); - List oa = bendingPlayers.getIntegerList(string + ".SlotAbilities"); - boolean permaremoved = bendingPlayers.getBoolean(string + ".Permaremoved"); - - int slot = 1; - for (int i : oa) { - if (StockAbilities.getAbility(i) != null) { - abilities.put(slot, StockAbilities.getAbility(i).toString()); - slot++; - } else { - abilities.put(slot, null); - slot++; - } - } - - for (int i : oe) { - if (Element.getType(i) != null) { - element.add(Element.getType(i)); - } - } - - BendingPlayer bPlayer = new BendingPlayer(uuid, playername, element, abilities, permaremoved); - bPlayers.add(bPlayer); - } - - final int total = bPlayers.size(); - final CommandSender sender = s; - s.sendMessage(ChatColor.GREEN + "Import of data started. Do NOT stop / reload your server."); - if (debug) { - s.sendMessage(ChatColor.RED + "Console will print out all of the players that are imported if debug mode is enabled as they import."); - } - importTask = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { - public void run() { - int i = 0; - if (i >= 10) { - sender.sendMessage(ChatColor.GREEN + "10 / " + total + " players converted thus far!"); - return; - } - - while (i < 10) { - if (bPlayers.isEmpty()) { - sender.sendMessage(ChatColor.GREEN + "All data has been queued up, please allow up to 5 minutes for the data to complete, then reboot your server."); - Bukkit.getServer().getScheduler().cancelTask(importTask.getTaskId()); - plugin.getConfig().set("Properties.ImportEnabled", false); - plugin.saveConfig(); - for (Player player: Bukkit.getOnlinePlayers()) { - GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); - } - return; - } - StringBuilder elements = new StringBuilder(); - BendingPlayer bPlayer = bPlayers.pop(); - if (bPlayer.hasElement(Element.Air)) elements.append("a"); - if (bPlayer.hasElement(Element.Water)) elements.append("w"); - if (bPlayer.hasElement(Element.Earth)) elements.append("e"); - if (bPlayer.hasElement(Element.Fire)) elements.append("f"); - if (bPlayer.hasElement(Element.Chi)) elements.append("c"); - - HashMap abilities = bPlayer.getAbilities(); - - ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + bPlayer.uuid.toString() + "'"); - - try { - if (rs2.next()) { // SQL Data already exists for player. - DBConnection.sql.modifyQuery("UPDATE pk_players SET player = '" + bPlayer.player + "' WHERE uuid = '" + bPlayer.uuid.toString()); - DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + bPlayer.uuid.toString()); - DBConnection.sql.modifyQuery("UPDATE pk_players SET permaremoved = '" + bPlayer.isPermaRemoved() + "' WHERE uuid = '" + bPlayer.uuid.toString()); - for (int slot = 1; slot < 10; slot++) { - DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + slot + " = '" + abilities.get(slot) + "' WHERE player = '" + bPlayer.getPlayerName() + "'"); - } - } else { - DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player, element, permaremoved) VALUES ('" + bPlayer.uuid.toString() + "', '" + bPlayer.player + "', '" + elements + "', '" + bPlayer.isPermaRemoved() +"')"); - for (int slot = 1; slot < 10; slot++) { - DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + slot + " = '" + abilities.get(slot) + "' WHERE player = '" + bPlayer.getPlayerName() + "'"); - } - } - } catch (SQLException ex) { - ex.printStackTrace(); - } - i++; - if (debug) { - System.out.println("[ProjectKorra] Successfully imported " + bPlayer.player + ". " + bPlayers.size() + " players left to import."); - } - } - } - }, 0, 40); - return true; - - } - if (Arrays.asList(displayaliases).contains(args[0].toLowerCase())) { - if (args.length > 2) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending display "); - return true; - } - - if (!s.hasPermission("bending.command.display")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (args.length == 2) { - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "This command is only usable by players."); - return true; - } - //bending display [Element] - if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.airbendingabilities.isEmpty()) { - s.sendMessage(AirMethods.getAirColor() + "There are no airbending abilities available."); - return true; - } - for (String st: AbilityModuleManager.airbendingabilities) { - if (GeneralMethods.isSubAbility(st)) continue; - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(AirMethods.getAirColor() + st); - } - } - if (!AbilityModuleManager.flightabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + "Use /bending display Flight for all Flight subelement abilities."); - } - if (!AbilityModuleManager.spiritualprojectionabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + "Use /bending display SpiritualProjection for all Spiritual Projection subelement abilities."); - } - return true; - } - - if (Arrays.asList(flightaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.flightabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + "There are no flight abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.flightabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + st); - } - } - return true; - } - - if (Arrays.asList(spiritualprojectionaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.spiritualprojectionabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + "There are no Spiritual Projection abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.spiritualprojectionabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + st); - } - } - return true; - } - - - if (Arrays.asList(wateraliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.waterbendingabilities.isEmpty()) { - s.sendMessage(WaterMethods.getWaterColor() + "There are no waterbending abilities available."); - return true; - } - for (String st: AbilityModuleManager.waterbendingabilities) { - if (GeneralMethods.isSubAbility(st)) continue; - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(WaterMethods.getWaterColor() + st); - } - } - if (!AbilityModuleManager.bloodabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "Use /bending display Blood for bloodbending sub abilities."); - } - if (!AbilityModuleManager.healingabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "Use /bending display Healing for Healing sub abilities."); - } - if (!AbilityModuleManager.plantabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "Use /bending display Plant for Plantbending sub abilities."); - } - return true; - } - - if (Arrays.asList(bloodaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.bloodabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "There are no Bloodbending abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.bloodabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + st); - } - } - return true; - } - - if (Arrays.asList(healingaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.healingabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "There are no Healing abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.healingabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + st); - } - } - return true; - } - - if (Arrays.asList(plantaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.plantabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "There are no Plantbending abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.plantabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + st); - } - } - return true; - } - if (Arrays.asList(earthaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.earthbendingabilities.isEmpty()) { - s.sendMessage(EarthMethods.getEarthColor() + "There are no earthbending abilities available."); - return true; - } - for (String st: AbilityModuleManager.earthbendingabilities) { - if (GeneralMethods.isSubAbility(st)) continue; - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(EarthMethods.getEarthColor() + st); - } - } - if (!AbilityModuleManager.lavaabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "Use /bending display LavaBending for Lava sub abilities."); - } - if (!AbilityModuleManager.metalabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "Use /bending display Metalbending for Metal sub abilities."); - } - - if (!AbilityModuleManager.sandabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "Use /bending display Sand for Sandbending sub abilities."); - } - return true; - } - - if (Arrays.asList(lavabendingaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.lavaabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "There are no lavabending abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.lavaabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + st); - } - } - return true; - } - - if (Arrays.asList(metalbendingaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.metalabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "There are no metal abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.metalabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + st); - } - } - return true; - } - - if (Arrays.asList(sandbendingaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.sandabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "There are no sandbending abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.sandabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + st); - } - } - return true; - } - - if (Arrays.asList(firealiases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.firebendingabilities.isEmpty()) { - s.sendMessage(FireMethods.getFireColor() + "There are no firebending abilities available."); - return true; - } - for (String st: AbilityModuleManager.firebendingabilities) { - if (GeneralMethods.isSubAbility(st)) continue; - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(FireMethods.getFireColor() + st); - } - } - if (!AbilityModuleManager.combustionabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + "Use /bending display Combustion for Combustion sub abilities."); - } - if (!AbilityModuleManager.lightningabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + "Use /bending display Lightning for Lightning sub abilities."); - } - return true; - } - - if (Arrays.asList(lightningaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.lightningabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + "There are no lightning abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.lightningabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + st); - } - } - } - - if (Arrays.asList(combustionaliases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.combustionabilities.isEmpty()) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + "There are no combustion abilities installed on this server."); - return true; - } - - for (String st: AbilityModuleManager.combustionabilities) { - if (GeneralMethods.canView((Player) s, st)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + st); - } - } - } - - if (Arrays.asList(chialiases).contains(args[1].toLowerCase())) { - if (AbilityModuleManager.chiabilities.isEmpty()) { - s.sendMessage(ChiMethods.getChiColor() + "There are no chiblocking abilities available."); - return true; - } - - for (String st: AbilityModuleManager.chiabilities) { - if (GeneralMethods.hasPermission((Player) s, st)) { - s.sendMessage(ChiMethods.getChiColor() + st); - } - } - return true; - } else { - s.sendMessage(ChatColor.RED + "Not a valid Element." + ChatColor.WHITE + " Elements: " + - AirMethods.getAirColor() + "Air" + - ChatColor.WHITE + " | " + - WaterMethods.getWaterColor() + "Water" + - ChatColor.WHITE + " | " + - EarthMethods.getEarthColor() + "Earth" + - ChatColor.WHITE + " | " + - FireMethods.getFireColor() + "Fire" + - ChatColor.WHITE + " | " + - ChiMethods.getChiColor() + "Chi"); - - } - } - if (args.length == 1) { - //bending display - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "This command is only usable by players."); - return true; - } - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); - HashMap abilities = bPlayer.getAbilities(); - - if (abilities.isEmpty()) { - s.sendMessage("You don't have any bound abilities."); - s.sendMessage("If you would like to see a list of available abilities, please use the /bending display [Element] command. Use /bending help for more information."); - return true; - } - - for (int i = 1; i <= 9; i++) { - String ability = abilities.get(i); - if (ability != null) s.sendMessage(i + " - " + GeneralMethods.getAbilityColor(ability) + ability); - } - - return true; - } - } - if (Arrays.asList(togglealiases).contains(args[0].toLowerCase())) { - if (args.length > 2) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending toggle "); - return true; - } - if (args.length == 1) { - if (!s.hasPermission("bending.command.toggle")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "This command is only usable by players."); - return true; - } - - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); - - if (bPlayer.isToggled) { - s.sendMessage(ChatColor.RED + "Your bending has been toggled off. You will not be able to use most abilities until you toggle it back."); - bPlayer.isToggled = false; - return true; - } else { - s.sendMessage(ChatColor.GREEN + "You have turned your Bending back on."); - bPlayer.isToggled = true; - return true; - } - } else if (args.length == 2 && args[1].equalsIgnoreCase("all")) { - if (!s.hasPermission("bending.command.toggle.all")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (isToggledForAll) { // Bending is toggled off for all players. - isToggledForAll = false; - for (Player player: Bukkit.getOnlinePlayers()) { - player.sendMessage(ChatColor.GREEN + "Bending has been toggled back on for all players."); - return true; - } - } else { - isToggledForAll = true; - for (Player player: Bukkit.getOnlinePlayers()) { - player.sendMessage(ChatColor.RED + "Bending has been toggled off for all players."); - return true; - } - } - } else { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending toggle "); - return true; - } - } - if (Arrays.asList(whoaliases).contains(args[0].toLowerCase())) { - if (args.length > 2) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending who "); - return true; - } - if (!s.hasPermission("bending.command.who")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (args.length == 2) { - - Player p = Bukkit.getPlayer(args[1]); - if (p == null) { - s.sendMessage(ChatColor.GREEN + "You are running a lookup of an offline player, this may take a second."); - - final String player = args[1]; - final CommandSender sender = s; - new BukkitRunnable() { - @Override - public void run() { - ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE player = '" + player + "'"); - try { - final List messages = new ArrayList(); - - if (rs2.next()) { - UUID uuid = UUID.fromString(rs2.getString("uuid")); - String element = rs2.getString("element"); - - messages.add(player + " - "); - if (element.contains("a")) messages.add(AirMethods.getAirColor() + "- Airbender"); - if (element.contains("w")) messages.add(WaterMethods.getWaterColor() + "- Waterbender"); - if (element.contains("e")) messages.add(EarthMethods.getEarthColor() + "- Earthbender"); - if (element.contains("f")) messages.add(FireMethods.getFireColor() + "- Firebender"); - if (element.contains("c")) messages.add(ChiMethods.getChiColor() + "- Chiblocker"); - - if (GeneralMethods.hasRPG()) { - if (RPGMethods.isCurrentAvatar(uuid)) { - messages.add(GeneralMethods.getAvatarColor() + "Current Avatar"); - } else if (RPGMethods.hasBeenAvatar(uuid)) { - messages.add(GeneralMethods.getAvatarColor() + "Former Avatar"); - } else { - - } - } - } else { - messages.add(ChatColor.RED + "We could not find any player in your database with that username. Are you sure it is typed correctly?"); - } - - new BukkitRunnable() { - @Override - public void run() { - for (String message : messages) { - sender.sendMessage(message); - } - } - }.runTask(ProjectKorra.plugin); - } catch (SQLException e) { - e.printStackTrace(); - } - } - }.runTaskAsynchronously(ProjectKorra.plugin); - return true; - } - - String un = p.getName(); - s.sendMessage(un + " - "); - if (GeneralMethods.isBender(un, Element.Air)) { - s.sendMessage(AirMethods.getAirColor() + "- Airbender"); - if(AirMethods.canAirFlight(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + " Can Fly"); - } - if(AirMethods.canUseSpiritualProjection(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + " Can use Spiritual Projection"); - } - } - if (GeneralMethods.isBender(un, Element.Water)) { - s.sendMessage(WaterMethods.getWaterColor() + "- Waterbender"); - if (WaterMethods.canPlantbend(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Plantbend"); - } - if (WaterMethods.canBloodbend(p)) { - if(WaterMethods.canBloodbendAtAnytime(p)) - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Bloodbend anytime, on any day"); - else - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Bloodbend"); - } - if (WaterMethods.canIcebend(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Icebend"); - } - if (WaterMethods.canWaterHeal(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Heal"); - } - } - if (GeneralMethods.isBender(un, Element.Earth)) { - s.sendMessage(EarthMethods.getEarthColor() + "- Earthbender"); - if (EarthMethods.canMetalbend(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Metalbend"); - } - if (EarthMethods.canLavabend(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Lavabend"); - } - if (EarthMethods.canSandbend(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Sandbend"); - } - } - if (GeneralMethods.isBender(un, Element.Fire)) { - s.sendMessage(FireMethods.getFireColor() + "- Firebender"); - if(FireMethods.canCombustionbend(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + " Can Combustionbend"); - } - if(FireMethods.canLightningbend(p)) { - s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + " Can Bend Lightning"); - } - } - if (GeneralMethods.isBender(un, Element.Chi)) { - s.sendMessage(ChiMethods.getChiColor() + "- ChiBlocker"); - } - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(un); - UUID uuid2 = bPlayer.uuid; - if (bPlayer != null) { - s.sendMessage("Abilities: "); - for (int i = 1; i <= 9; i++) { - String ability = bPlayer.getAbilities().get(i); - if (ability == null || ability.equalsIgnoreCase("null")) { - continue; - } else { - s.sendMessage(i + " - " + GeneralMethods.getAbilityColor(ability) + ability); - } - } - } - - if (GeneralMethods.hasRPG()) { - if (RPGMethods.isCurrentAvatar(p.getUniqueId())) { - s.sendMessage(GeneralMethods.getAvatarColor() + "Current Avatar"); - } else if (RPGMethods.hasBeenAvatar(p.getUniqueId())) { - s.sendMessage(GeneralMethods.getAvatarColor() + "Former Avatar"); - } - } - - if (uuid2.toString().equals("8621211e-283b-46f5-87bc-95a66d68880e")) { - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Founder"); // MistPhizzle - } - - if (uuid2.toString().equals("9636d66a-bff8-48e4-993e-68f0e7891c3b") // codiaz - || uuid2.toString().equals("833a7132-a9ec-4f0a-ad9c-c3d6b8a1c7eb") // Jacklin213 - || uuid2.toString().equals("96f40c81-dd5d-46b6-9afe-365114d4a082") // Coolade - || uuid2.toString().equals("81adae76-d647-4b41-bfb0-8166516fa189") // AlexTheCoder - || uuid2.toString().equals("c364ffe2-de9e-4117-9735-6d14bde038f6") // Carbogen - || uuid2.toString().equals("a197291a-cd78-43bb-aa38-52b7c82bc68c")) // OmniCypher - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Developer"); - - if (uuid2.toString().equals("929b14fc-aaf1-4f0f-84c2-f20c55493f53")) { // vidcom - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Concept Designer"); - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Community Moderator"); - } - - if (uuid2.toString().equals("9c18ff57-04b3-4841-9726-9d64373d0d65")) { // coastyo - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Concept Designer"); - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Graphic Artist"); - } - - if (uuid2.toString().equals("b2d82a84-ce22-4518-a8fc-1b28aeda0c0b") // Shunky - || uuid2.toString().equals("15d1a5a7-76ef-49c3-b193-039b27c47e30")) { // Kiam - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Concept Designer"); - } - - if (uuid2.toString().equals("0fd77ff6-07fb-4a7d-ba87-ae6f802ed1f9")) { // Hit_Manx - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Concept Designer"); - s.sendMessage(ChatColor.YELLOW + "ProjectKorra Wiki Contributor"); - } - return true; - } - if (args.length == 1) { - List players = new ArrayList(); - for (Player player: Bukkit.getOnlinePlayers()) { - String un = player.getName(); - - BendingPlayer bp = GeneralMethods.getBendingPlayer(un); - if (bp.elements.size() > 1) { - players.add(GeneralMethods.getAvatarColor() + un); - continue; - } - if (bp.elements.size() == 0) { - players.add(un); - continue; - } - if (GeneralMethods.isBender(un, Element.Air)) { - players.add(AirMethods.getAirColor() + un); - continue; - } - if (GeneralMethods.isBender(un, Element.Water)){ - players.add(WaterMethods.getWaterColor() + un); - continue; - } - if (GeneralMethods.isBender(un, Element.Earth)) { - players.add(EarthMethods.getEarthColor() + un); - continue; - } - if (GeneralMethods.isBender(un, Element.Chi)) { - players.add(ChiMethods.getChiColor() + un); - continue; - } - if (GeneralMethods.isBender(un, Element.Fire)) { - players.add(FireMethods.getFireColor() + un); - continue; - } - } - for (String st: players) { - s.sendMessage(st); - } - return true; - } - } - if (Arrays.asList(versionaliases).contains(args[0].toLowerCase())) { - if (args.length != 1) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending version"); - return true; - } - - if (!s.hasPermission("bending.command.version")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - s.sendMessage(ChatColor.GREEN + "Core Version: " + ChatColor.RED + plugin.getDescription().getVersion()); - if (GeneralMethods.hasRPG()) { - s.sendMessage(ChatColor.GREEN + "RPG Version: " + ChatColor.RED + GeneralMethods.getRPG().getDescription().getVersion()); - } - if (GeneralMethods.hasItems()) { - s.sendMessage(ChatColor.GREEN + "Items Version: " + ChatColor.RED + GeneralMethods.getItems().getDescription().getVersion()); - } - s.sendMessage(ChatColor.GREEN + "Founded by: " + ChatColor.RED + "MistPhizzle"); - s.sendMessage(ChatColor.GREEN + "Learn More: " + ChatColor.RED + "http://projectkorra.com"); - return true; - } - if (Arrays.asList(removealiases).contains(args[0].toLowerCase())) { - //bending remove [Player] - if (args.length != 2) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending remove [Player]"); - return true; - } - - if (!s.hasPermission("bending.admin.remove")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - Player player = Bukkit.getPlayer(args[1]); - - if (player == null) { - s.sendMessage(ChatColor.RED + "That player is not online."); - return true; - } - - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - GeneralMethods.removeUnusableAbilities(player.getName()); - bPlayer.elements.clear(); - GeneralMethods.saveElements(bPlayer); - s.sendMessage(ChatColor.GREEN + "You have removed the bending of " + ChatColor.DARK_AQUA + player.getName()); - player.sendMessage(ChatColor.GREEN + "Your bending has been removed by " + ChatColor.DARK_AQUA + s.getName()); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, null, Result.REMOVE)); - return true; - - } - if (Arrays.asList(permaremovealiases).contains(args[0].toLowerCase())) { - //bending permaremove [Player] - if (args.length != 2) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending permaremove [Player]"); - return true; - } - - if (!s.hasPermission("bending.admin.permaremove")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - Player player = Bukkit.getPlayer(args[1]); - - if (player == null) { - s.sendMessage(ChatColor.RED + "That player is not online."); - return true; - } - - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - - if (bPlayer.isPermaRemoved()) { - bPlayer.permaRemoved = false; - GeneralMethods.savePermaRemoved(bPlayer); - s.sendMessage(ChatColor.RED + "You have restored the bending of: " + ChatColor.DARK_AQUA + player.getName()); - return true; - } - - bPlayer.elements.clear(); - GeneralMethods.removeUnusableAbilities(player.getName()); - GeneralMethods.saveElements(bPlayer); - bPlayer.permaRemoved = true; - GeneralMethods.savePermaRemoved(bPlayer); - player.sendMessage(ChatColor.RED + "Your bending has been permanently removed."); - s.sendMessage(ChatColor.RED + "You have permanently removed the bending of: " + ChatColor.DARK_AQUA + player.getName()); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, null, Result.PERMAREMOVE)); - return true; - } - if (Arrays.asList(addaliases).contains(args[0].toLowerCase())) { - //bending add [Player] [Element] - if (args.length > 3) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending add [Player] [Element]"); - s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, Chi"); - return true; - } - if (args.length == 3) { - if (!s.hasPermission("bending.command.add.others")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - Player player = Bukkit.getPlayer(args[1]); - if (player == null) { - s.sendMessage(ChatColor.RED + "That player is not online."); - return true; - } - - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - if (Arrays.asList(airaliases).contains(args[2].toLowerCase())) { - bPlayer.addElement(Element.Air); - GeneralMethods.saveElements(bPlayer); - player.sendMessage(AirMethods.getAirColor() + "You are also an Airbender."); - s.sendMessage(ChatColor.DARK_AQUA + player.getName() + AirMethods.getAirColor() + " is also an Airbender."); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Air, Result.ADD)); - return true; - } - - if (Arrays.asList(wateraliases).contains(args[2].toLowerCase())) { - bPlayer.addElement(Element.Water); - GeneralMethods.saveElements(bPlayer); - player.sendMessage(WaterMethods.getWaterColor() + "You are also a waterbender."); - s.sendMessage(ChatColor.DARK_AQUA + player.getName() + WaterMethods.getWaterColor() + " is also a Waterbender."); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Water, Result.ADD)); - return true; - } - - if (Arrays.asList(earthaliases).contains(args[2].toLowerCase())) { - bPlayer.addElement(Element.Earth); - GeneralMethods.saveElements(bPlayer); - player.sendMessage(EarthMethods.getEarthColor() + "You are also an Earthbender."); - s.sendMessage(ChatColor.DARK_AQUA + player.getName() + EarthMethods.getEarthColor() + " is also an Earthbender."); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Earth, Result.ADD)); - - return true; - } - - if (Arrays.asList(firealiases).contains(args[2].toLowerCase())) { - bPlayer.addElement(Element.Fire); - GeneralMethods.saveElements(bPlayer); - player.sendMessage(FireMethods.getFireColor() + "You are also a Firebender."); - s.sendMessage(ChatColor.DARK_AQUA + player.getName() + FireMethods.getFireColor() + " is also a Firebender"); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Fire, Result.ADD)); - return true; - } - if (Arrays.asList(chialiases).contains(args[2].toLowerCase())) { - bPlayer.addElement(Element.Chi); - GeneralMethods.saveElements(bPlayer); - player.sendMessage(ChiMethods.getChiColor() + "You are also a ChiBlocker."); - s.sendMessage(ChatColor.DARK_AQUA + player.getName() + ChiMethods.getChiColor() + " is also a ChiBlocker"); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Chi, Result.ADD)); - return true; - } - - s.sendMessage(ChatColor.RED + "You must specify an element."); - return true; - } - if (args.length == 2) { - // Target = Self - if (!s.hasPermission("bending.command.add")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "This command is only usable by Players."); - return true; - } - - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); - - if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.add.air")) { - s.sendMessage(ChatColor.RED + "You don't have permsision to add " + AirMethods.getAirColor() + "Airbending"); - return true; - } - bPlayer.addElement(Element.Air); - GeneralMethods.saveElements(bPlayer); - s.sendMessage(AirMethods.getAirColor() + "You are also an Airbender."); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Air, Result.ADD)); - return true; - } - - if (Arrays.asList(wateraliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.add.water")) { - s.sendMessage(ChatColor.RED + "You don't have permission to add " + WaterMethods.getWaterColor() + "Waterbending"); - return true; - } - bPlayer.addElement(Element.Water); - GeneralMethods.saveElements(bPlayer); - s.sendMessage(WaterMethods.getWaterColor() + "You are also a Waterbender."); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Water, Result.ADD)); - return true; - } - - if (Arrays.asList(earthaliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.add.earth")) { - s.sendMessage(ChatColor.RED + "You dont' have permission to add " + EarthMethods.getEarthColor() + "Earthbending"); - return true; - } - bPlayer.addElement(Element.Earth); - GeneralMethods.saveElements(bPlayer); - s.sendMessage(EarthMethods.getEarthColor() + "You are also an Earthbender."); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Earth, Result.ADD)); - return true; - } - - if (Arrays.asList(firealiases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.add.fire")) { - s.sendMessage(ChatColor.RED + "You don't have permission to add " + FireMethods.getFireColor() + "Firebending"); - return true; - } - bPlayer.addElement(Element.Fire); - GeneralMethods.saveElements(bPlayer); - s.sendMessage(FireMethods.getFireColor() + "You are also a Firebender."); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Fire, Result.ADD)); - return true; - } - if (Arrays.asList(chialiases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.add.chi")) { - s.sendMessage(ChatColor.RED + "You don't have permission to add " + ChiMethods.getChiColor() + "Chiblocking"); - return true; - } - bPlayer.addElement(Element.Chi); - GeneralMethods.saveElements(bPlayer); - s.sendMessage(ChiMethods.getChiColor() + "You are also a ChiBlocker."); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Chi, Result.ADD)); - return true; - } - s.sendMessage(ChatColor.RED + "You must specify an element."); - } - } - if (Arrays.asList(choosealiases).contains(args[0].toLowerCase())) { - // /bending choose [Player] [Element] - if (args.length > 3) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending choose [Player] [Element]"); - s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, and Chi"); - return true; - } - - if (args.length == 2) { - if (!s.hasPermission("bending.command.choose")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - - if (!(s instanceof Player)) { - s.sendMessage(ChatColor.RED + "This command is only usable by players."); - return true; - } - - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); - - if (bPlayer.isPermaRemoved()) { - s.sendMessage(ChatColor.RED + "Your bending was permanently removed."); - return true; - } - - if (!bPlayer.getElements().isEmpty()) { - if (!s.hasPermission("bending.command.rechoose")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - } - if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.choose.air")) { - s.sendMessage(ChatColor.RED + "You don't have permission to choose " + AirMethods.getAirColor() + "Airbending"); - return true; - } - bPlayer.setElement(Element.Air); - s.sendMessage(AirMethods.getAirColor() + "You are now an Airbender."); - GeneralMethods.removeUnusableAbilities(s.getName()); - GeneralMethods.saveElements(bPlayer); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Air, Result.CHOOSE)); - return true; - } - if (Arrays.asList(wateraliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.choose.water")) { - s.sendMessage(ChatColor.RED + "You don't have permission to choose " + WaterMethods.getWaterColor() + "Waterbending"); - return true; - } - bPlayer.setElement(Element.Water); - s.sendMessage(WaterMethods.getWaterColor() + "You are now a Waterbender."); - GeneralMethods.removeUnusableAbilities(s.getName()); - GeneralMethods.saveElements(bPlayer); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Water, Result.CHOOSE)); - return true; - } - if (Arrays.asList(earthaliases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.choose.earth")) { - s.sendMessage(ChatColor.RED + "You don't have permission to choose " + EarthMethods.getEarthColor() + "Earthbending"); - return true; - } - bPlayer.setElement(Element.Earth); - s.sendMessage(EarthMethods.getEarthColor() + "You are now an Earthbender."); - GeneralMethods.removeUnusableAbilities(s.getName()); - GeneralMethods.saveElements(bPlayer); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Earth, Result.CHOOSE)); - return true; - } - if (Arrays.asList(firealiases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.choose.fire")) { - s.sendMessage(ChatColor.RED + "You don't have permission to choose " + FireMethods.getFireColor() + "Firebending"); - return true; - } - bPlayer.setElement(Element.Fire); - s.sendMessage(FireMethods.getFireColor() + "You are now a Firebender."); - GeneralMethods.removeUnusableAbilities(s.getName()); - GeneralMethods.saveElements(bPlayer); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Fire, Result.CHOOSE)); - return true; - } - if (Arrays.asList(chialiases).contains(args[1].toLowerCase())) { - if (!s.hasPermission("bending.command.choose.chi")) { - s.sendMessage(ChatColor.RED + "You don't have permission to choose " + ChiMethods.getChiColor() + "Chiblocking"); - return true; - } - bPlayer.setElement(Element.Chi); - s.sendMessage(ChiMethods.getChiColor() + "You are now a ChiBlocker."); - GeneralMethods.removeUnusableAbilities(s.getName()); - GeneralMethods.saveElements(bPlayer); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Chi, Result.CHOOSE)); - return true; - } - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending choose [Element]"); - s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, Chi"); - return true; - } - if (args.length == 3) { - if (!s.hasPermission("bending.admin.choose")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - Player target = Bukkit.getPlayer(args[1]); - if (target == null) { - s.sendMessage(ChatColor.RED + "That player is not online."); - return true; - } - BendingPlayer bTarget = GeneralMethods.getBendingPlayer(target.getName()); - -// if (bTarget.isPermaRemoved()) { -// s.sendMessage(ChatColor.RED + "That player's bending was permanently removed."); -// return true; -// } - Element e = null; - if (Arrays.asList(airaliases).contains(args[2])) e = Element.Air; - if (Arrays.asList(wateraliases).contains(args[2])) e = Element.Water; - if (Arrays.asList(earthaliases).contains(args[2])) e = Element.Earth; - if (Arrays.asList(firealiases).contains(args[2])) e = Element.Fire; - if (Arrays.asList(chialiases).contains(args[2])) e = Element.Chi; - - if (e == null) { - s.sendMessage(ChatColor.RED + "You must specify an element."); - return true; - } else { - bTarget.setElement(e); - GeneralMethods.removeUnusableAbilities(target.getName()); - GeneralMethods.saveElements(bTarget); - s.sendMessage(ChatColor.RED + "You have changed " + ChatColor.DARK_AQUA + target.getName() + "'s " + ChatColor.RED + "element to " + ChatColor.DARK_AQUA + e.toString() + ChatColor.RED + "."); - target.sendMessage(ChatColor.RED + "Your bending has been changed to " + ChatColor.DARK_AQUA + e.toString() + ChatColor.RED + " by " + ChatColor.DARK_AQUA + s.getName()); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, target, e, Result.CHOOSE)); - return true; - } - } - } - if (Arrays.asList(helpaliases).contains(args[0].toLowerCase())) { - if (!s.hasPermission("bending.command.help")) { - s.sendMessage(ChatColor.RED + "You don't have permission to do that."); - return true; - } - if (args.length != 2) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending help Command/Ability"); - if (s.hasPermission("bending.command.add")) { - s.sendMessage(ChatColor.YELLOW + "/bending add [Element]"); - } - if (s.hasPermission("bending.command.bind")) - s.sendMessage(ChatColor.YELLOW + "/bending bind [Ability] "); - if (s.hasPermission("bending.command.clear")) - s.sendMessage(ChatColor.YELLOW + "/bending clear "); - if (s.hasPermission("bending.command.choose")) - s.sendMessage(ChatColor.YELLOW + "/bending choose [Element]"); - if (s.hasPermission("bending.command.display")) - s.sendMessage(ChatColor.YELLOW + "/bending display "); - if (s.hasPermission("bending.command.import")) - s.sendMessage(ChatColor.YELLOW + "/bending import"); - if (s.hasPermission("bending.admin.permaremove")) - s.sendMessage(ChatColor.YELLOW + "/bending permaremove "); - if (s.hasPermission("bending.admin.remove")) - s.sendMessage(ChatColor.YELLOW + "/bending remove [Player]"); - if (s.hasPermission("bending.command.toggle")) - s.sendMessage(ChatColor.YELLOW + "/bending toggle"); - if (s.hasPermission("bending.command.version")) - s.sendMessage(ChatColor.YELLOW + "/bending version"); - if (s.hasPermission("bending.command.who")) - s.sendMessage(ChatColor.YELLOW + "/bending who"); - if (s.hasPermission("bending.command.give")) - s.sendMessage(ChatColor.YELLOW + "/bending give [Player] [Item] "); - if (s.hasPermission("bending.command.invincible")) - s.sendMessage(ChatColor.YELLOW + "/bending invincible"); - return true; - } - if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { - s.sendMessage(AirMethods.getAirColor() + "Air is the element of freedom. Airbenders are natural pacifists and " - + "great explorers. There is nothing stopping them from scaling the tallest of mountains and walls easily. They specialize in redirection, " - + "from blasting things away with gusts of winds, to forming a shield around them to prevent damage. Easy to get across flat terrains, " - + "such as oceans, there is practically no terrain off limits to Airbenders. They lack much raw damage output, but make up for it with " - + "with their ridiculous amounts of utility and speed."); - s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/qffg9m3"); - } - if (Arrays.asList(wateraliases).contains(args[1].toLowerCase())) { - s.sendMessage(WaterMethods.getWaterColor() + "Water is the element of change. Waterbending focuses on using your " - + "opponents own force against them. Using redirection and various dodging tactics, you can be made " - + "practically untouchable by an opponent. Waterbending provides agility, along with strong offensive " - + "skills while in or near water."); - s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/lod3plv"); - } - if (Arrays.asList(earthaliases).contains(args[1].toLowerCase())) { - s.sendMessage(EarthMethods.getEarthColor() + "Earth is the element of substance. Earthbenders share many of the " - + "same fundamental techniques as Waterbenders, but their domain is quite different and more readily " - + "accessible. Earthbenders dominate the ground and subterranean, having abilities to pull columns " - + "of rock straight up from the earth or drill their way through the mountain. They can also launch " - + "themselves through the air using pillars of rock, and will not hurt themselves assuming they land " - + "on something they can bend. The more skilled Earthbenders can even bend metal."); - s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/qaudl42"); - } - if (Arrays.asList(firealiases).contains(args[1].toLowerCase())) { - s.sendMessage(FireMethods.getFireColor() + "Fire is the element of power. Firebenders focus on destruction and " - + "incineration. Their abilities are pretty straight forward: set things on fire. They do have a bit " - + "of utility however, being able to make themselves un-ignitable, extinguish large areas, cook food " - + "in their hands, extinguish large areas, small bursts of flight, and then comes the abilities to shoot " - + "fire from your hands."); - s.sendMessage(ChatColor.YELLOW + "Firebenders can chain their abilities into combos, type " - + FireMethods.getFireColor() + "/b help FireCombo" + ChatColor.YELLOW + " for more information."); - s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/k4fkjhb"); - } - if (Arrays.asList(chialiases).contains(args[1].toLowerCase())) { - s.sendMessage(ChiMethods.getChiColor() + "Chiblockers focus on bare handed combat, utilizing their agility and " - + "speed to stop any bender right in their path. Although they lack the ability to bend any of the " - + "other elements, they are great in combat, and a serious threat to any bender. Chiblocking was " - + "first shown to be used by Ty Lee in Avatar: The Last Airbender, then later by members of the " - + "Equalists in The Legend of Korra."); - s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/mkp9n6y"); - } - if (Arrays.asList(invinciblealiases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending invincible"); - s.sendMessage(ChatColor.YELLOW + "This command will make you impervious to all Bending damage. Once you " - + "use this command, you will stay invincible until you either log off, or use this command again."); - } - if (Arrays.asList(importaliases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending import"); - s.sendMessage(ChatColor.YELLOW + "This command will import your old bendingPlayers.yml from the Bending plugin." - + " It will generate a convert.yml file to convert the data to be used with this plugin." - + " You can delete the file once the complete message is displayed" - + " This command should only be used ONCE."); - } - if (Arrays.asList(displayaliases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending display "); - s.sendMessage(ChatColor.YELLOW + "This command will show you all of the elements you have bound if you do not specify an element." - + " If you do specify an element (Air, Water, Earth, Fire, or Chi), it will show you all of the available " - + " abilities of that element installed on the server."); - } - if (Arrays.asList(givealiases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending give [Player] [Item] "); - s.sendMessage(ChatColor.YELLOW + "This command will give you an item that was created for the Bending plugin so you do not have to craft it." - + " Each item may have its own properties involved, so the amount of arguments may change. However, the Player and Item will be " - + " required each time you use this command."); - s.sendMessage(ChatColor.DARK_AQUA + "Items: GrapplingHook"); - } - if (Arrays.asList(choosealiases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending choose [Element]"); - s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, Chi"); - s.sendMessage(ChatColor.YELLOW + "This command will allow the user to choose a player either for himself or if specified. " - + " This command can only be used once per player unless they have permission to rechoose their element."); - return true; - } - if (args[1].equalsIgnoreCase("add")) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending add [Element]"); - s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, Chi"); - s.sendMessage(ChatColor.YELLOW + "This command will allow the user to add an element to the targeted , or themselves if the target" - + " is not specified. This command is typically reserved for server administrators."); - return true; - } - if (Arrays.asList(permaremovealiases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending permaremove "); - s.sendMessage(ChatColor.YELLOW + "This command will permanently remove the Bending of the targeted . Once removed, a player" - + " may only receive Bending again if this command is run on them again. This command is typically reserved for" - + " administrators."); - return true; - } - if (Arrays.asList(versionaliases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending version"); - s.sendMessage(ChatColor.YELLOW + "This command will print out the version of ProjectKorra this server is running."); - return true; - } - - if (Arrays.asList(removealiases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending remove [Player]"); - s.sendMessage(ChatColor.YELLOW + "This command will remove the element of the targeted [Player]. The player will be able to re-pick " - + " their element after this command is run on them, assuming their Bending was not permaremoved."); - return true; - } - - if (Arrays.asList(togglealiases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending toggle "); - s.sendMessage(ChatColor.YELLOW + "This command will toggle a player's own Bending on or off. If toggled off, all abilities should stop" - + " working until it is toggled back on. Logging off will automatically toggle your Bending back on. If you run the command /bending toggle all, Bending will be turned off for all players and cannot be turned back on until the command is run again."); - return true; - } - if (args[1].equalsIgnoreCase("who")) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending who "); - s.sendMessage(ChatColor.YELLOW + "This command will tell you what element all players that are online are (If you don't specify a player)" - + " or give you information about the player that you specify."); - return true; - } - - if (Arrays.asList(clearaliases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending clear "); - s.sendMessage(ChatColor.YELLOW + "This command will clear the bound ability from the slot you specify (if you specify one." - + " If you choose not to specify a slot, all of your abilities will be cleared."); - } - if (Arrays.asList(reloadaliases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending reload"); - s.sendMessage(ChatColor.YELLOW + "This command will reload the Bending config file."); - return true; - } - if (Arrays.asList(bindaliases).contains(args[1].toLowerCase())) { - s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending bind [Ability] "); - s.sendMessage(ChatColor.YELLOW + "This command will bind an ability to the slot you specify (if you specify one), or the slot currently" - + " selected in your hotbar (If you do not specify a Slot #)."); - } - if (args[1].equalsIgnoreCase("FireCombo")) { - s.sendMessage(ChatColor.GOLD + "Fire Combos:"); - s.sendMessage(FireMethods.getFireColor() + "FireKick" + ChatColor.WHITE + ": A short ranged arc of fire launches from the player's feet dealing moderate damage to enemies."); - s.sendMessage(ChatColor.GOLD + "FireBlast > FireBlast > (Hold Shift) > FireBlast. "); - s.sendMessage(FireMethods.getFireColor() + "FireSpin" + ChatColor.WHITE + ": A circular array of fire that causes damage and massive knockback to nearby enemies."); - s.sendMessage(ChatColor.GOLD + "FireBlast > FireBlast > FireShield > (Tap Shift). "); - s.sendMessage(FireMethods.getFireColor() + "FireWheel" + ChatColor.WHITE + ": A high-speed wheel of fire that travels along the ground for long distances dealing high damage."); - s.sendMessage(ChatColor.GOLD + "FireShield (Hold Shift) > Right Click a block in front of you twice > Switch to Blaze > Release Shift. "); - s.sendMessage(FireMethods.getFireColor() + "JetBlast" + ChatColor.WHITE + ": Create an explosive blast that propels your FireJet at higher speeds."); - s.sendMessage(ChatColor.GOLD + "FireJet (Tap Shift) > FireJet (Tap Shift) > FireShield (Tap Shift) > FireJet. "); - s.sendMessage(FireMethods.getFireColor() + "JetBlaze" + ChatColor.WHITE + ": Damages and burns all enemies in the proximity of your FireJet."); - s.sendMessage(ChatColor.GOLD + "FireJet (Tap Shift) > FireJet (Tap Shift) > Blaze (Tap Shift) > FireJet. "); - for(ComboAbilityModule cam : ComboModuleManager.combo) - { - if(cam.getElement().equals(Element.Fire.toString())) - { - ChatColor color = GeneralMethods.getAvatarColor(); - if(cam.getSubElement() == null) - color = FireMethods.getFireColor(); - else color = GeneralMethods.getSubBendingColor(Element.Fire); - s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); - s.sendMessage(ChatColor.GOLD + cam.getInstructions()); - } - } - } - if (args[1].equalsIgnoreCase("AirCombo")) { - s.sendMessage(ChatColor.GOLD + "AirCombo:"); - s.sendMessage(AirMethods.getAirColor() + "Twister" + ChatColor.WHITE + ": Create a cyclone of air that travels along the ground grabbing nearby entities."); - s.sendMessage(ChatColor.GOLD + "AirShield (Tap Shift) > Tornado (Hold Shift) > AirBlast (Left Click)"); - s.sendMessage(AirMethods.getAirColor() + "AirStream" + ChatColor.WHITE + ": Control a large stream of air that grabs onto enemies allowing you to direct them temporarily."); - s.sendMessage(ChatColor.GOLD + "AirShield (Hold Shift) > AirSuction (Left Click) > AirBlast (Left Click)"); - s.sendMessage(AirMethods.getAirColor() + "AirSweep" + ChatColor.WHITE + ": Sweep the air in front of you hitting multiple enemies, causing moderate damage and a large knockback. The radius and direction of AirSweep is controlled by moving your mouse in a sweeping motion. For example, if you want to AirSweep upward, then move your mouse upward right after you left click AirBurst"); - s.sendMessage(ChatColor.GOLD + "AirSwipe (Left Click) > AirSwipe (Left Click) > AirBurst (Hold Shift) > AirBurst (Left Click)"); - for(ComboAbilityModule cam : ComboModuleManager.combo) - { - if(cam.getElement().equals(Element.Air.toString())) - { - ChatColor color = GeneralMethods.getAvatarColor(); - if(cam.getSubElement() == null) - color = AirMethods.getAirColor(); - else color = GeneralMethods.getSubBendingColor(Element.valueOf(cam.getElement())); - s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); - s.sendMessage(ChatColor.GOLD + cam.getInstructions()); - } - } - } - if (args[1].equalsIgnoreCase("WaterCombo")) { - s.sendMessage(ChatColor.GOLD + "WaterCombos:"); - s.sendMessage(WaterMethods.getWaterColor() + "IceWave" + ChatColor.WHITE + ": PhaseChange your WaterWave into an IceWave that freezes and damages enemies."); - s.sendMessage(ChatColor.GOLD + "Create a WaterSpout Wave > PhaseChange (Left Click)"); - s.sendMessage(WaterMethods.getWaterColor() + "IceBullet" + ChatColor.WHITE + ": Using a large cavern of ice, you can punch ice shards at your opponent causing moderate damage. To rapid fire, you must alternate between Left clicking and right clicking with IceBlast."); - s.sendMessage(ChatColor.GOLD + "WaterBubble (Tap Shift) > IceBlast (Hold Shift) > IceBlast (Left Click) > Wait for ice to Form > Then alternate between Left and Right click with IceBlast"); - for(ComboAbilityModule cam : ComboModuleManager.combo) - { - if(cam.getElement().equals(Element.Water.toString())) - { - ChatColor color = GeneralMethods.getAvatarColor(); - if(cam.getSubElement() == null) - color = WaterMethods.getWaterColor(); - else color = GeneralMethods.getSubBendingColor(Element.valueOf(cam.getElement())); - s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); - s.sendMessage(ChatColor.GOLD + cam.getInstructions()); - } - } - } - if (args[1].equalsIgnoreCase("EarthCombo")) { - s.sendMessage(ChatColor.GOLD + "EarthCombos:"); - for(ComboAbilityModule cam : ComboModuleManager.combo) - { - if(cam.getElement().equals(Element.Earth.toString())) - { - ChatColor color = GeneralMethods.getAvatarColor(); - if(cam.getSubElement() == null) - color = EarthMethods.getEarthColor(); - else color = GeneralMethods.getSubBendingColor(Element.valueOf(cam.getElement())); - s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); - s.sendMessage(ChatColor.GOLD + cam.getInstructions()); - } - } - } - if (args[1].equalsIgnoreCase("ChiCombo")) - { - s.sendMessage(ChatColor.GOLD + "ChiCombos:"); - s.sendMessage(ChiMethods.getChiColor() + "Immobilize" + ChatColor.WHITE + ": Deliver a series of strikes to an enemy to temporarely immobilize them."); - s.sendMessage(ChatColor.GOLD + "QuickStrike > SwiftKick > QuickStrike > QuickStrike"); - for(ComboAbilityModule cam : ComboModuleManager.combo) - { - if(cam.getElement().equals(Element.Chi.toString())) - { - ChatColor color = GeneralMethods.getAvatarColor(); - if(cam.getSubElement() == null) - color = ChiMethods.getChiColor(); - else color = GeneralMethods.getSubBendingColor(Element.valueOf(cam.getElement())); - s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); - s.sendMessage(ChatColor.GOLD + cam.getInstructions()); - } - } - } - if (GeneralMethods.abilityExists(args[1])) { - String ability = GeneralMethods.getAbility(args[1]); - if (AirMethods.isAirAbility(ability)) { - s.sendMessage(AirMethods.getAirColor() + ability + " - "); - s.sendMessage(AirMethods.getAirColor() + AbilityModuleManager.descriptions.get(ability)); - } - else if (WaterMethods.isWaterAbility(ability)) { - s.sendMessage(WaterMethods.getWaterColor() + ability + " - "); - s.sendMessage(WaterMethods.getWaterColor() + AbilityModuleManager.descriptions.get(ability)); - } - else if (EarthMethods.isEarthAbility(ability)) { - if (EarthMethods.isMetalbendingAbility(ability)) { - s.sendMessage(EarthMethods.getMetalbendingColor() + ability + " - "); - s.sendMessage(EarthMethods.getMetalbendingColor() + AbilityModuleManager.descriptions.get(ability)); - } else { - s.sendMessage(EarthMethods.getEarthColor() + ability + " - "); - s.sendMessage(EarthMethods.getEarthColor() + AbilityModuleManager.descriptions.get(ability)); - } - } - else if (FireMethods.isFireAbility(ability)) { - s.sendMessage(FireMethods.getFireColor() + ability + " - "); - s.sendMessage(FireMethods.getFireColor() + AbilityModuleManager.descriptions.get(ability)); - } - else if (ChiMethods.isChiAbility(ability)) { - s.sendMessage(ChiMethods.getChiColor() + ability + " - "); - s.sendMessage(ChiMethods.getChiColor() + AbilityModuleManager.descriptions.get(ability)); - } - else { - s.sendMessage(GeneralMethods.getAvatarColor() + ability + " - "); - s.sendMessage(GeneralMethods.getAvatarColor() + AbilityModuleManager.descriptions.get(ability)); - } - } - } - return true; - } - }; projectkorra.setExecutor(exe); - } - -} +package com.projectkorra.ProjectKorra; + +import java.io.File; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.PluginCommand; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; + +import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager; +import com.projectkorra.ProjectKorra.Ability.StockAbilities; +import com.projectkorra.ProjectKorra.Ability.Combo.ComboAbilityModule; +import com.projectkorra.ProjectKorra.Ability.Combo.ComboModuleManager; +import com.projectkorra.ProjectKorra.CustomEvents.PlayerChangeElementEvent; +import com.projectkorra.ProjectKorra.CustomEvents.PlayerChangeElementEvent.Result; +import com.projectkorra.ProjectKorra.Objects.Preset; +import com.projectkorra.ProjectKorra.Utilities.GrapplingHookAPI; +import com.projectkorra.ProjectKorra.airbending.AirMethods; +import com.projectkorra.ProjectKorra.chiblocking.ChiMethods; +import com.projectkorra.ProjectKorra.earthbending.EarthMethods; +import com.projectkorra.ProjectKorra.firebending.FireMethods; +import com.projectkorra.ProjectKorra.waterbending.WaterMethods; +import com.projectkorra.rpg.RPGMethods; + +public class Commands { + + ProjectKorra plugin; + + public Commands(ProjectKorra plugin) { + this.plugin = plugin; + init(); + } + + /* + * Element Aliases + */ + String[] airaliases = {"air", "a", "airbending", "airbender"}; + String[] wateraliases = {"water", "w", "waterbending", "waterbender"}; + String[] earthaliases = {"earth", "e", "earthbending", "earthbender"}; + String[] firealiases = {"fire", "f", "firebending", "firebender"}; + String[] chialiases = {"chi", "c", "chiblocking", "chiblocker"}; + + /* + * Subelement Aliases + */ + + //Air + String[] flightaliases = {"flight", "fl"}; + String[] spiritualprojectionaliases = {"spiritualprojection", "sp", "spiritual"}; + + //Water + String[] bloodaliases = {"bloodbending", "bb"}; + String[] healingaliases = {"healing", "heal"}; + String[] plantaliases = {"plantbending", "plant"}; + + //Earth + String[] metalbendingaliases = {"metalbending", "mb", "metal"}; + String[] lavabendingaliases = {"lavabending", "lb", "lava"}; + String[] sandbendingaliases = {"sandbending", "sb", "sand"}; + + //Firebending + String[] combustionaliases = {"combustionbending", "combustion", "cb"}; + String[] lightningaliases = {"lightningbending", "lightning"}; + + + /* + * Command Aliases + */ + String[] helpaliases = {"help", "h"}; + String[] versionaliases = {"version", "v"}; + String[] permaremovealiases = {"permaremove", "premove", "permremove", "pr"}; + String[] choosealiases = {"choose", "ch"}; + String[] removealiases = {"remove", "rm"}; + String[] togglealiases = {"toggle", "t"}; + String[] displayaliases = {"display", "d"}; + String[] bindaliases = {"bind", "b"}; + String[] clearaliases = {"clear", "cl", "c"}; + String[] reloadaliases = {"reload", "r"}; + String[] addaliases = {"add", "a"}; + String[] whoaliases = {"who", "w"}; + String[] importaliases = {"import", "i"}; + String[] givealiases = {"give", "g", "spawn"}; + String[] invinciblealiases = {"invincible", "inv"}; + String[] presetaliases = {"preset", "presets", "pre", "set", "p"}; + String[] avataraliases = {"avatar", "ava"}; + + /* + * Item Aliases + */ + + public static Set invincible = new HashSet(); + + String[] grapplinghookaliases = {"grapplinghook", "grapplehook", "hook", "ghook"}; + + public static boolean debug = ProjectKorra.plugin.getConfig().getBoolean("debug"); + + public static boolean isToggledForAll = false; + + private static BukkitTask importTask; + private void init() { + PluginCommand projectkorra = plugin.getCommand("projectkorra"); + CommandExecutor exe; + + exe = new CommandExecutor() { + @SuppressWarnings("deprecation") + @Override + public boolean onCommand(CommandSender s, Command c, String label, String[] args) { + for(int i = 0; i < args.length; i++){ + args[i] = args[i].toLowerCase(); + } + if (args.length == 0) { + s.sendMessage(ChatColor.RED + "/bending help [Ability/Command] " + ChatColor.YELLOW + "Display help."); + s.sendMessage(ChatColor.RED + "/bending choose [Element] " + ChatColor.YELLOW + "Choose an element."); + s.sendMessage(ChatColor.RED + "/bending bind [Ability] # " + ChatColor.YELLOW + "Bind an ability."); + return true; + } + if (Arrays.asList(avataraliases).contains(args[0].toLowerCase())) { + if (!GeneralMethods.hasRPG()) { + s.sendMessage(ChatColor.RED + "This command cannot be used unless you have ProjectKorra (RPG) installed."); + return true; + } + + if (!s.hasPermission("bending.command.avatar")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (args.length != 2) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending avatar [Player]"); + return true; + } + + Player player = Bukkit.getPlayer(args[1]); + if (player == null) { + s.sendMessage(ChatColor.RED + "That player is not online."); + return true; + } + + UUID uuid = player.getUniqueId(); + + if (RPGMethods.hasBeenAvatar(uuid)) { + s.sendMessage(ChatColor.RED + "This player has already been the Avatar."); + return true; + } + + RPGMethods.setAvatar(uuid); + s.sendMessage(ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " is now the Avatar."); + player.sendMessage("You are now the Avatar."); + return true; + + } + if (args[0].equalsIgnoreCase("debug")) { + if (args.length != 1) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending debug"); + return true; + } + + if (!s.hasPermission("bending.admin.debug")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + GeneralMethods.runDebug(); + s.sendMessage(ChatColor.GREEN + "Debug File Created as debug.txt in the ProjectKorra plugin folder."); + s.sendMessage(ChatColor.GREEN + "Put contents on pastie.org and create a bug report on the ProjectKorra forum if you need to."); + return true; + } + if (Arrays.asList(presetaliases).contains(args[0].toLowerCase())) { + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "This command is only usable by players."); + return true; + } + + if (MultiAbilityManager.hasMultiAbilityBound((Player) s)) { + s.sendMessage(ChatColor.RED + "You can't edit your binds right now!"); + return true; + } + + Player player = (Player) s; + + String[] deletealiases = {"delete", "d", "del"}; + String[] createaliases = {"create", "c", "save"}; + String[] listaliases = {"list", "l"}; + if (args.length == 2 && Arrays.asList(listaliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.preset.list")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + List listnames = Preset.presets.get(player.getUniqueId()); + List ln2 = new ArrayList(); + + if (listnames == null || listnames.isEmpty()) { + s.sendMessage(ChatColor.RED + "You don't have any presets."); + return true; + } + + for (Preset preset: listnames) { + ln2.add(preset.getName()); + } + + s.sendMessage(ChatColor.GREEN + "Your Presets: " + ChatColor.DARK_AQUA + ln2.toString()); + return true; + + }else if (args.length != 3) { // bending preset bind|create|delete {name} + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending preset create|bind|list|delete [name]"); + return true; + } + + String name = args[2]; + + if (Arrays.asList(deletealiases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.preset.delete")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + if (!Preset.presetExists(player, name)) { + s.sendMessage(ChatColor.RED + "You don't have a preset with that name."); + return true; + } + + Preset preset = Preset.getPreset(player, name); + preset.delete(); + s.sendMessage(ChatColor.GREEN + "You have deleted your preset named: " + name); + } + + if (Arrays.asList(bindaliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.preset.bind")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (!Preset.presetExists(player, name)) { + s.sendMessage(ChatColor.RED + "You don't have a preset with that name."); + return true; + } + + Preset.bindPreset(player, name); + s.sendMessage(ChatColor.GREEN + "Your bound slots have been set to match the " + name + " preset."); + return true; + } + + if (Arrays.asList(createaliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.preset.create")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + int limit = GeneralMethods.getMaxPresets(player); + + if (Preset.presets.get(player) != null && Preset.presets.get(player).size() >= limit) { + s.sendMessage(ChatColor.RED + "You have reached your max number of Presets."); + return true; + } + + if (Preset.presetExists(player, name)) { + s.sendMessage(ChatColor.RED + "A preset with that name already exists."); + return true; + } + + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + + if (bPlayer == null) return true; + + HashMap abilities = bPlayer.getAbilities(); + Preset preset = new Preset(player.getUniqueId(), name, abilities); + preset.save(); + s.sendMessage(ChatColor.GREEN + "Created preset with the name: " + name); + return true; + } + + } + if (Arrays.asList(invinciblealiases).contains(args[0].toLowerCase())) { + if (!s.hasPermission("bending.command.invincible")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "This command is only usable by players."); + return true; + } + + if (args.length != 1) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending invincible"); + return true; + } + + if (!invincible.contains(s.getName())) { + /* + * Player is not invincible. + */ + invincible.add(s.getName()); + s.sendMessage(ChatColor.GREEN + "You are now invincible to all bending damage and effects. Use this command again to disable this."); + return true; + } else { + invincible.remove(s.getName()); + s.sendMessage(ChatColor.RED + "You are no longer invincible to all bending damage and effects."); + } + } + if (Arrays.asList(givealiases).contains(args[0].toLowerCase())) { + if (!s.hasPermission("bending.command.give")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (args.length < 3) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending give [Player] [Item] "); + return true; + } + + Player player = Bukkit.getPlayer(args[1]); + + if (player == null) { + s.sendMessage(ChatColor.RED + "That player is not online."); + return true; + } + + if (Arrays.asList(grapplinghookaliases).contains(args[2].toLowerCase())) { + /* + * They are spawning in a grappling hook. + * bending give [Player] grapplinghook [# of Uses] + */ + + if (args.length != 4) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending give [Player] GrapplingHook <#OfUses>"); + return true; + } + int uses; + try { + uses = Integer.parseInt(args[3]); + } catch (NumberFormatException e) { + s.sendMessage(ChatColor.RED + "You must specify a number of uses you want the grappling hook to have."); + s.sendMessage(ChatColor.GOLD + "Example: /bending give " + s.getName() + " grapplinghook 25"); + return true; + } + + ItemStack hook = GrapplingHookAPI.createHook(uses); + player.getInventory().addItem(hook); + s.sendMessage(ChatColor.GREEN + "A grappling hook with " + uses + " uses has been added to your inventory."); + return true; + } else { + s.sendMessage(ChatColor.RED + "That is not a valid Bending item."); + s.sendMessage(ChatColor.GOLD + "Acceptable Items: GrapplingHook"); + return true; + } + } + if (Arrays.asList(reloadaliases).contains(args[0].toLowerCase())) { + if (args.length != 1) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending reload"); + return true; + } + + if (!s.hasPermission("bending.command.reload")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + GeneralMethods.reloadPlugin(); + s.sendMessage(ChatColor.AQUA + "Bending config reloaded."); + return true; + } + if (Arrays.asList(clearaliases).contains(args[0].toLowerCase())) { + if (args.length > 2) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending clear <#>"); + return true; + } + if (!s.hasPermission("bending.command.clear")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "This command is only usable by players."); + return true; + } + if (MultiAbilityManager.hasMultiAbilityBound((Player) s)) { + s.sendMessage(ChatColor.RED + "You can't edit your binds right now!"); + return true; + } + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); + if (args.length == 1) { + bPlayer.getAbilities().clear(); + for (int i = 1; i <= 9; i++) { + GeneralMethods.saveAbility(bPlayer, i, null); + } + s.sendMessage("Your bound abilities have been cleared."); + return true; + } + + if (args.length == 2) { + try { + int slot = Integer.parseInt(args[1]); + if (slot < 1 || slot > 9) { + s.sendMessage(ChatColor.RED + "The slot must be an integer between 0 and 9."); + return true; + } + if (bPlayer.getAbilities().get(slot) != null) { + bPlayer.getAbilities().remove(slot); + GeneralMethods.saveAbility(bPlayer, slot, null); + } + s.sendMessage("You have cleared slot #" + slot); + return true; + } catch (NumberFormatException e) { + s.sendMessage(ChatColor.RED + "The slot must be an integer between 0 and 9."); + } + } + } + if (Arrays.asList(bindaliases).contains(args[0].toLowerCase())) { + if (args.length > 3 || args.length == 1) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending bind [Ability] <#>"); + return true; + } + + if (!s.hasPermission("bending.command.bind")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (args.length == 2) { + // We bind the ability to the slot they have selected.. + // bending bind [Ability] + String abil = args[1]; + if (!GeneralMethods.abilityExists(abil)) { + s.sendMessage(ChatColor.RED + "That is not an ability."); + return true; + } + + String ability = GeneralMethods.getAbility(abil); + + if (!GeneralMethods.canBind(((Player) s).getName(), ability)) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + + } + if (AirMethods.isAirAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Air)) { + s.sendMessage(AirMethods.getAirColor() + "You must be an Airbender to bind this ability."); + return true; + } + if (WaterMethods.isWaterAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Water)) { + s.sendMessage(WaterMethods.getWaterColor() + "You must be a Waterbender to bind this ability."); + return true; + } + if (EarthMethods.isEarthAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Earth)) { + s.sendMessage(EarthMethods.getEarthColor() + "You must be an Earthbender to bind this ability."); + return true; + } + if (FireMethods.isFireAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Fire)) { + s.sendMessage(FireMethods.getFireColor() + "You must be a Firebender to bind this ability."); + return true; + } + if (ChiMethods.isChiAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Chi)) { + s.sendMessage(ChiMethods.getChiColor() + "You must be a ChiBlocker to bind this ability."); + return true; + } + + GeneralMethods.bindAbility((Player) s, ability); + // s.sendMessage("Ability Bound to slot"); + return true; + } + + if (args.length == 3) { + // bending bind ability [Slot] + String abil = args[1]; + if (!GeneralMethods.abilityExists(abil)) { + s.sendMessage(ChatColor.RED + "That ability doesn't exist."); + return true; + } + String ability = GeneralMethods.getAbility(abil); + int slot = 0; + try { + slot = Integer.parseInt(args[2]); + } catch (NumberFormatException e) { + s.sendMessage(ChatColor.RED + "Slot must be an integer between 1 and 9."); + return true; + } + if (slot < 1 || slot > 9) { + s.sendMessage(ChatColor.RED + "Slot must be an integer between 1 and 9."); + return true; + } + + if (!GeneralMethods.canBind(((Player) s).getName(), ability)) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (AirMethods.isAirAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Air)) { + s.sendMessage(AirMethods.getAirColor() + "You must be an Airbender to bind this ability."); + return true; + } + if (WaterMethods.isWaterAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Water)) { + s.sendMessage(WaterMethods.getWaterColor() + "You must be a Waterbender to bind this ability."); + return true; + } + if (EarthMethods.isEarthAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Earth)) { + s.sendMessage(EarthMethods.getEarthColor() + "You must be an Earthbender to bind this ability."); + return true; + } + if (FireMethods.isFireAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Fire)) { + s.sendMessage(FireMethods.getFireColor() + "You must be a Firebender to bind this ability."); + return true; + } + if (ChiMethods.isChiAbility(ability) && !GeneralMethods.isBender(s.getName(), Element.Chi)) { + s.sendMessage(ChiMethods.getChiColor() + "You must be a ChiBlocker to bind this ability."); + return true; + } + GeneralMethods.bindAbility((Player) s, ability, slot); + // s.sendMessage("Ability Bound"); + return true; + } + } + if (Arrays.asList(importaliases).contains(args[0].toLowerCase())) { + if (!s.hasPermission("bending.command.import")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + if (!GeneralMethods.isImportEnabled()) { + s.sendMessage(ChatColor.RED + "Importing has been disabled in the config"); + return true; + } + + s.sendMessage(ChatColor.GREEN + "Preparing data for import."); + File bendingPlayersFile = new File(".", "converted.yml"); + FileConfiguration bendingPlayers = YamlConfiguration.loadConfiguration(bendingPlayersFile); + + final LinkedList bPlayers = new LinkedList(); + for (String string: bendingPlayers.getConfigurationSection("").getKeys(false)) { + if (string.equalsIgnoreCase("version")) continue; + String playername = string; + UUID uuid = Bukkit.getOfflinePlayer(playername).getUniqueId(); + ArrayList element = new ArrayList(); + List oe = bendingPlayers.getIntegerList(string + ".BendingTypes"); + HashMap abilities = new HashMap(); + List oa = bendingPlayers.getIntegerList(string + ".SlotAbilities"); + boolean permaremoved = bendingPlayers.getBoolean(string + ".Permaremoved"); + + int slot = 1; + for (int i : oa) { + if (StockAbilities.getAbility(i) != null) { + abilities.put(slot, StockAbilities.getAbility(i).toString()); + slot++; + } else { + abilities.put(slot, null); + slot++; + } + } + + for (int i : oe) { + if (Element.getType(i) != null) { + element.add(Element.getType(i)); + } + } + + BendingPlayer bPlayer = new BendingPlayer(uuid, playername, element, abilities, permaremoved); + bPlayers.add(bPlayer); + } + + final int total = bPlayers.size(); + final CommandSender sender = s; + s.sendMessage(ChatColor.GREEN + "Import of data started. Do NOT stop / reload your server."); + if (debug) { + s.sendMessage(ChatColor.RED + "Console will print out all of the players that are imported if debug mode is enabled as they import."); + } + importTask = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() { + public void run() { + int i = 0; + if (i >= 10) { + sender.sendMessage(ChatColor.GREEN + "10 / " + total + " players converted thus far!"); + return; + } + + while (i < 10) { + if (bPlayers.isEmpty()) { + sender.sendMessage(ChatColor.GREEN + "All data has been queued up, please allow up to 5 minutes for the data to complete, then reboot your server."); + Bukkit.getServer().getScheduler().cancelTask(importTask.getTaskId()); + plugin.getConfig().set("Properties.ImportEnabled", false); + plugin.saveConfig(); + for (Player player: Bukkit.getOnlinePlayers()) { + GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); + } + return; + } + StringBuilder elements = new StringBuilder(); + BendingPlayer bPlayer = bPlayers.pop(); + if (bPlayer.hasElement(Element.Air)) elements.append("a"); + if (bPlayer.hasElement(Element.Water)) elements.append("w"); + if (bPlayer.hasElement(Element.Earth)) elements.append("e"); + if (bPlayer.hasElement(Element.Fire)) elements.append("f"); + if (bPlayer.hasElement(Element.Chi)) elements.append("c"); + + HashMap abilities = bPlayer.getAbilities(); + + ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + bPlayer.uuid.toString() + "'"); + + try { + if (rs2.next()) { // SQL Data already exists for player. + DBConnection.sql.modifyQuery("UPDATE pk_players SET player = '" + bPlayer.player + "' WHERE uuid = '" + bPlayer.uuid.toString()); + DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + bPlayer.uuid.toString()); + DBConnection.sql.modifyQuery("UPDATE pk_players SET permaremoved = '" + bPlayer.isPermaRemoved() + "' WHERE uuid = '" + bPlayer.uuid.toString()); + for (int slot = 1; slot < 10; slot++) { + DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + slot + " = '" + abilities.get(slot) + "' WHERE player = '" + bPlayer.getPlayerName() + "'"); + } + } else { + DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player, element, permaremoved) VALUES ('" + bPlayer.uuid.toString() + "', '" + bPlayer.player + "', '" + elements + "', '" + bPlayer.isPermaRemoved() +"')"); + for (int slot = 1; slot < 10; slot++) { + DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + slot + " = '" + abilities.get(slot) + "' WHERE player = '" + bPlayer.getPlayerName() + "'"); + } + } + } catch (SQLException ex) { + ex.printStackTrace(); + } + i++; + if (debug) { + System.out.println("[ProjectKorra] Successfully imported " + bPlayer.player + ". " + bPlayers.size() + " players left to import."); + } + } + } + }, 0, 40); + return true; + + } + if (Arrays.asList(displayaliases).contains(args[0].toLowerCase())) { + if (args.length > 2) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending display "); + return true; + } + + if (!s.hasPermission("bending.command.display")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (args.length == 2) { + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "This command is only usable by players."); + return true; + } + //bending display [Element] + if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.airbendingabilities.isEmpty()) { + s.sendMessage(AirMethods.getAirColor() + "There are no airbending abilities available."); + return true; + } + for (String st: AbilityModuleManager.airbendingabilities) { + if (GeneralMethods.isSubAbility(st)) continue; + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(AirMethods.getAirColor() + st); + } + } + if (!AbilityModuleManager.flightabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + "Use /bending display Flight for all Flight subelement abilities."); + } + if (!AbilityModuleManager.spiritualprojectionabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + "Use /bending display SpiritualProjection for all Spiritual Projection subelement abilities."); + } + return true; + } + + if (Arrays.asList(flightaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.flightabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + "There are no flight abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.flightabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + st); + } + } + return true; + } + + if (Arrays.asList(spiritualprojectionaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.spiritualprojectionabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + "There are no Spiritual Projection abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.spiritualprojectionabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + st); + } + } + return true; + } + + + if (Arrays.asList(wateraliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.waterbendingabilities.isEmpty()) { + s.sendMessage(WaterMethods.getWaterColor() + "There are no waterbending abilities available."); + return true; + } + for (String st: AbilityModuleManager.waterbendingabilities) { + if (GeneralMethods.isSubAbility(st)) continue; + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(WaterMethods.getWaterColor() + st); + } + } + if (!AbilityModuleManager.bloodabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "Use /bending display Blood for bloodbending sub abilities."); + } + if (!AbilityModuleManager.healingabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "Use /bending display Healing for Healing sub abilities."); + } + if (!AbilityModuleManager.plantabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "Use /bending display Plant for Plantbending sub abilities."); + } + return true; + } + + if (Arrays.asList(bloodaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.bloodabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "There are no Bloodbending abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.bloodabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + st); + } + } + return true; + } + + if (Arrays.asList(healingaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.healingabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "There are no Healing abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.healingabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + st); + } + } + return true; + } + + if (Arrays.asList(plantaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.plantabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + "There are no Plantbending abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.plantabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + st); + } + } + return true; + } + if (Arrays.asList(earthaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.earthbendingabilities.isEmpty()) { + s.sendMessage(EarthMethods.getEarthColor() + "There are no earthbending abilities available."); + return true; + } + for (String st: AbilityModuleManager.earthbendingabilities) { + if (GeneralMethods.isSubAbility(st)) continue; + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(EarthMethods.getEarthColor() + st); + } + } + if (!AbilityModuleManager.lavaabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "Use /bending display LavaBending for Lava sub abilities."); + } + if (!AbilityModuleManager.metalabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "Use /bending display Metalbending for Metal sub abilities."); + } + + if (!AbilityModuleManager.sandabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "Use /bending display Sand for Sandbending sub abilities."); + } + return true; + } + + if (Arrays.asList(lavabendingaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.lavaabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "There are no lavabending abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.lavaabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + st); + } + } + return true; + } + + if (Arrays.asList(metalbendingaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.metalabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "There are no metal abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.metalabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + st); + } + } + return true; + } + + if (Arrays.asList(sandbendingaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.sandabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + "There are no sandbending abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.sandabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + st); + } + } + return true; + } + + if (Arrays.asList(firealiases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.firebendingabilities.isEmpty()) { + s.sendMessage(FireMethods.getFireColor() + "There are no firebending abilities available."); + return true; + } + for (String st: AbilityModuleManager.firebendingabilities) { + if (GeneralMethods.isSubAbility(st)) continue; + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(FireMethods.getFireColor() + st); + } + } + if (!AbilityModuleManager.combustionabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + "Use /bending display Combustion for Combustion sub abilities."); + } + if (!AbilityModuleManager.lightningabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + "Use /bending display Lightning for Lightning sub abilities."); + } + return true; + } + + if (Arrays.asList(lightningaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.lightningabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + "There are no lightning abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.lightningabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + st); + } + } + } + + if (Arrays.asList(combustionaliases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.combustionabilities.isEmpty()) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + "There are no combustion abilities installed on this server."); + return true; + } + + for (String st: AbilityModuleManager.combustionabilities) { + if (GeneralMethods.canView((Player) s, st)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + st); + } + } + } + + if (Arrays.asList(chialiases).contains(args[1].toLowerCase())) { + if (AbilityModuleManager.chiabilities.isEmpty()) { + s.sendMessage(ChiMethods.getChiColor() + "There are no chiblocking abilities available."); + return true; + } + + for (String st: AbilityModuleManager.chiabilities) { + if (GeneralMethods.hasPermission((Player) s, st)) { + s.sendMessage(ChiMethods.getChiColor() + st); + } + } + return true; + } else { + s.sendMessage(ChatColor.RED + "Not a valid Element." + ChatColor.WHITE + " Elements: " + + AirMethods.getAirColor() + "Air" + + ChatColor.WHITE + " | " + + WaterMethods.getWaterColor() + "Water" + + ChatColor.WHITE + " | " + + EarthMethods.getEarthColor() + "Earth" + + ChatColor.WHITE + " | " + + FireMethods.getFireColor() + "Fire" + + ChatColor.WHITE + " | " + + ChiMethods.getChiColor() + "Chi"); + + } + } + if (args.length == 1) { + //bending display + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "This command is only usable by players."); + return true; + } + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); + HashMap abilities = bPlayer.getAbilities(); + + if (abilities.isEmpty()) { + s.sendMessage("You don't have any bound abilities."); + s.sendMessage("If you would like to see a list of available abilities, please use the /bending display [Element] command. Use /bending help for more information."); + return true; + } + + for (int i = 1; i <= 9; i++) { + String ability = abilities.get(i); + if (ability != null) s.sendMessage(i + " - " + GeneralMethods.getAbilityColor(ability) + ability); + } + + return true; + } + } + if (Arrays.asList(togglealiases).contains(args[0].toLowerCase())) { + if (args.length > 2) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending toggle "); + return true; + } + if (args.length == 1) { + if (!s.hasPermission("bending.command.toggle")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "This command is only usable by players."); + return true; + } + + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); + + if (bPlayer.isToggled) { + s.sendMessage(ChatColor.RED + "Your bending has been toggled off. You will not be able to use most abilities until you toggle it back."); + bPlayer.isToggled = false; + return true; + } else { + s.sendMessage(ChatColor.GREEN + "You have turned your Bending back on."); + bPlayer.isToggled = true; + return true; + } + } else if (args.length == 2 && args[1].equalsIgnoreCase("all")) { + if (!s.hasPermission("bending.command.toggle.all")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (isToggledForAll) { // Bending is toggled off for all players. + isToggledForAll = false; + for (Player player: Bukkit.getOnlinePlayers()) { + player.sendMessage(ChatColor.GREEN + "Bending has been toggled back on for all players."); + return true; + } + } else { + isToggledForAll = true; + for (Player player: Bukkit.getOnlinePlayers()) { + player.sendMessage(ChatColor.RED + "Bending has been toggled off for all players."); + return true; + } + } + } else { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending toggle "); + return true; + } + } + if (Arrays.asList(whoaliases).contains(args[0].toLowerCase())) { + if (args.length > 2) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending who "); + return true; + } + if (!s.hasPermission("bending.command.who")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (args.length == 2) { + + Player p = Bukkit.getPlayer(args[1]); + if (p == null) { + s.sendMessage(ChatColor.GREEN + "You are running a lookup of an offline player, this may take a second."); + + final String player = args[1]; + final CommandSender sender = s; + new BukkitRunnable() { + @Override + public void run() { + ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE player = '" + player + "'"); + try { + final List messages = new ArrayList(); + + if (rs2.next()) { + UUID uuid = UUID.fromString(rs2.getString("uuid")); + String element = rs2.getString("element"); + + messages.add(player + " - "); + if (element.contains("a")) messages.add(AirMethods.getAirColor() + "- Airbender"); + if (element.contains("w")) messages.add(WaterMethods.getWaterColor() + "- Waterbender"); + if (element.contains("e")) messages.add(EarthMethods.getEarthColor() + "- Earthbender"); + if (element.contains("f")) messages.add(FireMethods.getFireColor() + "- Firebender"); + if (element.contains("c")) messages.add(ChiMethods.getChiColor() + "- Chiblocker"); + + if (GeneralMethods.hasRPG()) { + if (RPGMethods.isCurrentAvatar(uuid)) { + messages.add(GeneralMethods.getAvatarColor() + "Current Avatar"); + } else if (RPGMethods.hasBeenAvatar(uuid)) { + messages.add(GeneralMethods.getAvatarColor() + "Former Avatar"); + } else { + + } + } + } else { + messages.add(ChatColor.RED + "We could not find any player in your database with that username. Are you sure it is typed correctly?"); + } + + new BukkitRunnable() { + @Override + public void run() { + for (String message : messages) { + sender.sendMessage(message); + } + } + }.runTask(ProjectKorra.plugin); + } catch (SQLException e) { + e.printStackTrace(); + } + } + }.runTaskAsynchronously(ProjectKorra.plugin); + return true; + } + + String un = p.getName(); + s.sendMessage(un + " - "); + if (GeneralMethods.isBender(un, Element.Air)) { + s.sendMessage(AirMethods.getAirColor() + "- Airbender"); + if(AirMethods.canAirFlight(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + " Can Fly"); + } + if(AirMethods.canUseSpiritualProjection(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + " Can use Spiritual Projection"); + } + } + if (GeneralMethods.isBender(un, Element.Water)) { + s.sendMessage(WaterMethods.getWaterColor() + "- Waterbender"); + if (WaterMethods.canPlantbend(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Plantbend"); + } + if (WaterMethods.canBloodbend(p)) { + if(WaterMethods.canBloodbendAtAnytime(p)) + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Bloodbend anytime, on any day"); + else + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Bloodbend"); + } + if (WaterMethods.canIcebend(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Icebend"); + } + if (WaterMethods.canWaterHeal(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Heal"); + } + } + if (GeneralMethods.isBender(un, Element.Earth)) { + s.sendMessage(EarthMethods.getEarthColor() + "- Earthbender"); + if (EarthMethods.canMetalbend(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Metalbend"); + } + if (EarthMethods.canLavabend(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Lavabend"); + } + if (EarthMethods.canSandbend(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Sandbend"); + } + } + if (GeneralMethods.isBender(un, Element.Fire)) { + s.sendMessage(FireMethods.getFireColor() + "- Firebender"); + if(FireMethods.canCombustionbend(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + " Can Combustionbend"); + } + if(FireMethods.canLightningbend(p)) { + s.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + " Can Bend Lightning"); + } + } + if (GeneralMethods.isBender(un, Element.Chi)) { + s.sendMessage(ChiMethods.getChiColor() + "- ChiBlocker"); + } + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(un); + UUID uuid2 = bPlayer.uuid; + if (bPlayer != null) { + s.sendMessage("Abilities: "); + for (int i = 1; i <= 9; i++) { + String ability = bPlayer.getAbilities().get(i); + if (ability == null || ability.equalsIgnoreCase("null")) { + continue; + } else { + s.sendMessage(i + " - " + GeneralMethods.getAbilityColor(ability) + ability); + } + } + } + + if (GeneralMethods.hasRPG()) { + if (RPGMethods.isCurrentAvatar(p.getUniqueId())) { + s.sendMessage(GeneralMethods.getAvatarColor() + "Current Avatar"); + } else if (RPGMethods.hasBeenAvatar(p.getUniqueId())) { + s.sendMessage(GeneralMethods.getAvatarColor() + "Former Avatar"); + } + } + + if (uuid2.toString().equals("8621211e-283b-46f5-87bc-95a66d68880e")) { + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Founder"); // MistPhizzle + } + + if (uuid2.toString().equals("9636d66a-bff8-48e4-993e-68f0e7891c3b") // codiaz + || uuid2.toString().equals("833a7132-a9ec-4f0a-ad9c-c3d6b8a1c7eb") // Jacklin213 + || uuid2.toString().equals("96f40c81-dd5d-46b6-9afe-365114d4a082") // Coolade + || uuid2.toString().equals("81adae76-d647-4b41-bfb0-8166516fa189") // AlexTheCoder + || uuid2.toString().equals("c364ffe2-de9e-4117-9735-6d14bde038f6") // Carbogen + || uuid2.toString().equals("a197291a-cd78-43bb-aa38-52b7c82bc68c")) // OmniCypher + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Developer"); + + if (uuid2.toString().equals("929b14fc-aaf1-4f0f-84c2-f20c55493f53")) { // vidcom + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Concept Designer"); + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Community Moderator"); + } + + if (uuid2.toString().equals("9c18ff57-04b3-4841-9726-9d64373d0d65")) { // coastyo + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Concept Designer"); + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Graphic Artist"); + } + + if (uuid2.toString().equals("b2d82a84-ce22-4518-a8fc-1b28aeda0c0b") // Shunky + || uuid2.toString().equals("15d1a5a7-76ef-49c3-b193-039b27c47e30")) { // Kiam + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Concept Designer"); + } + + if (uuid2.toString().equals("0fd77ff6-07fb-4a7d-ba87-ae6f802ed1f9")) { // Hit_Manx + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Concept Designer"); + s.sendMessage(ChatColor.YELLOW + "ProjectKorra Wiki Contributor"); + } + return true; + } + if (args.length == 1) { + List players = new ArrayList(); + for (Player player: Bukkit.getOnlinePlayers()) { + String un = player.getName(); + + BendingPlayer bp = GeneralMethods.getBendingPlayer(un); + if (bp.elements.size() > 1) { + players.add(GeneralMethods.getAvatarColor() + un); + continue; + } + if (bp.elements.size() == 0) { + players.add(un); + continue; + } + if (GeneralMethods.isBender(un, Element.Air)) { + players.add(AirMethods.getAirColor() + un); + continue; + } + if (GeneralMethods.isBender(un, Element.Water)){ + players.add(WaterMethods.getWaterColor() + un); + continue; + } + if (GeneralMethods.isBender(un, Element.Earth)) { + players.add(EarthMethods.getEarthColor() + un); + continue; + } + if (GeneralMethods.isBender(un, Element.Chi)) { + players.add(ChiMethods.getChiColor() + un); + continue; + } + if (GeneralMethods.isBender(un, Element.Fire)) { + players.add(FireMethods.getFireColor() + un); + continue; + } + } + for (String st: players) { + s.sendMessage(st); + } + return true; + } + } + if (Arrays.asList(versionaliases).contains(args[0].toLowerCase())) { + if (args.length != 1) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending version"); + return true; + } + + if (!s.hasPermission("bending.command.version")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + s.sendMessage(ChatColor.GREEN + "Core Version: " + ChatColor.RED + plugin.getDescription().getVersion()); + if (GeneralMethods.hasRPG()) { + s.sendMessage(ChatColor.GREEN + "RPG Version: " + ChatColor.RED + GeneralMethods.getRPG().getDescription().getVersion()); + } + if (GeneralMethods.hasItems()) { + s.sendMessage(ChatColor.GREEN + "Items Version: " + ChatColor.RED + GeneralMethods.getItems().getDescription().getVersion()); + } + s.sendMessage(ChatColor.GREEN + "Founded by: " + ChatColor.RED + "MistPhizzle"); + s.sendMessage(ChatColor.GREEN + "Learn More: " + ChatColor.RED + "http://projectkorra.com"); + return true; + } + if (Arrays.asList(removealiases).contains(args[0].toLowerCase())) { + //bending remove [Player] + if (args.length != 2) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending remove [Player]"); + return true; + } + + if (!s.hasPermission("bending.admin.remove")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + Player player = Bukkit.getPlayer(args[1]); + + if (player == null) { + s.sendMessage(ChatColor.RED + "That player is not online."); + return true; + } + + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + GeneralMethods.removeUnusableAbilities(player.getName()); + bPlayer.elements.clear(); + GeneralMethods.saveElements(bPlayer); + s.sendMessage(ChatColor.GREEN + "You have removed the bending of " + ChatColor.DARK_AQUA + player.getName()); + player.sendMessage(ChatColor.GREEN + "Your bending has been removed by " + ChatColor.DARK_AQUA + s.getName()); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, null, Result.REMOVE)); + return true; + + } + if (Arrays.asList(permaremovealiases).contains(args[0].toLowerCase())) { + //bending permaremove [Player] + if (args.length != 2) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending permaremove [Player]"); + return true; + } + + if (!s.hasPermission("bending.admin.permaremove")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + Player player = Bukkit.getPlayer(args[1]); + + if (player == null) { + s.sendMessage(ChatColor.RED + "That player is not online."); + return true; + } + + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + + if (bPlayer.isPermaRemoved()) { + bPlayer.permaRemoved = false; + GeneralMethods.savePermaRemoved(bPlayer); + s.sendMessage(ChatColor.RED + "You have restored the bending of: " + ChatColor.DARK_AQUA + player.getName()); + return true; + } + + bPlayer.elements.clear(); + GeneralMethods.removeUnusableAbilities(player.getName()); + GeneralMethods.saveElements(bPlayer); + bPlayer.permaRemoved = true; + GeneralMethods.savePermaRemoved(bPlayer); + player.sendMessage(ChatColor.RED + "Your bending has been permanently removed."); + s.sendMessage(ChatColor.RED + "You have permanently removed the bending of: " + ChatColor.DARK_AQUA + player.getName()); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, null, Result.PERMAREMOVE)); + return true; + } + if (Arrays.asList(addaliases).contains(args[0].toLowerCase())) { + //bending add [Player] [Element] + if (args.length > 3) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending add [Player] [Element]"); + s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, Chi"); + return true; + } + if (args.length == 3) { + if (!s.hasPermission("bending.command.add.others")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + Player player = Bukkit.getPlayer(args[1]); + if (player == null) { + s.sendMessage(ChatColor.RED + "That player is not online."); + return true; + } + + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + if (Arrays.asList(airaliases).contains(args[2].toLowerCase())) { + bPlayer.addElement(Element.Air); + GeneralMethods.saveElements(bPlayer); + player.sendMessage(AirMethods.getAirColor() + "You are also an Airbender."); + s.sendMessage(ChatColor.DARK_AQUA + player.getName() + AirMethods.getAirColor() + " is also an Airbender."); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Air, Result.ADD)); + return true; + } + + if (Arrays.asList(wateraliases).contains(args[2].toLowerCase())) { + bPlayer.addElement(Element.Water); + GeneralMethods.saveElements(bPlayer); + player.sendMessage(WaterMethods.getWaterColor() + "You are also a waterbender."); + s.sendMessage(ChatColor.DARK_AQUA + player.getName() + WaterMethods.getWaterColor() + " is also a Waterbender."); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Water, Result.ADD)); + return true; + } + + if (Arrays.asList(earthaliases).contains(args[2].toLowerCase())) { + bPlayer.addElement(Element.Earth); + GeneralMethods.saveElements(bPlayer); + player.sendMessage(EarthMethods.getEarthColor() + "You are also an Earthbender."); + s.sendMessage(ChatColor.DARK_AQUA + player.getName() + EarthMethods.getEarthColor() + " is also an Earthbender."); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Earth, Result.ADD)); + + return true; + } + + if (Arrays.asList(firealiases).contains(args[2].toLowerCase())) { + bPlayer.addElement(Element.Fire); + GeneralMethods.saveElements(bPlayer); + player.sendMessage(FireMethods.getFireColor() + "You are also a Firebender."); + s.sendMessage(ChatColor.DARK_AQUA + player.getName() + FireMethods.getFireColor() + " is also a Firebender"); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Fire, Result.ADD)); + return true; + } + if (Arrays.asList(chialiases).contains(args[2].toLowerCase())) { + bPlayer.addElement(Element.Chi); + GeneralMethods.saveElements(bPlayer); + player.sendMessage(ChiMethods.getChiColor() + "You are also a ChiBlocker."); + s.sendMessage(ChatColor.DARK_AQUA + player.getName() + ChiMethods.getChiColor() + " is also a ChiBlocker"); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, player, Element.Chi, Result.ADD)); + return true; + } + + s.sendMessage(ChatColor.RED + "You must specify an element."); + return true; + } + if (args.length == 2) { + // Target = Self + if (!s.hasPermission("bending.command.add")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "This command is only usable by Players."); + return true; + } + + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); + + if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.add.air")) { + s.sendMessage(ChatColor.RED + "You don't have permsision to add " + AirMethods.getAirColor() + "Airbending"); + return true; + } + bPlayer.addElement(Element.Air); + GeneralMethods.saveElements(bPlayer); + s.sendMessage(AirMethods.getAirColor() + "You are also an Airbender."); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Air, Result.ADD)); + return true; + } + + if (Arrays.asList(wateraliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.add.water")) { + s.sendMessage(ChatColor.RED + "You don't have permission to add " + WaterMethods.getWaterColor() + "Waterbending"); + return true; + } + bPlayer.addElement(Element.Water); + GeneralMethods.saveElements(bPlayer); + s.sendMessage(WaterMethods.getWaterColor() + "You are also a Waterbender."); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Water, Result.ADD)); + return true; + } + + if (Arrays.asList(earthaliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.add.earth")) { + s.sendMessage(ChatColor.RED + "You dont' have permission to add " + EarthMethods.getEarthColor() + "Earthbending"); + return true; + } + bPlayer.addElement(Element.Earth); + GeneralMethods.saveElements(bPlayer); + s.sendMessage(EarthMethods.getEarthColor() + "You are also an Earthbender."); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Earth, Result.ADD)); + return true; + } + + if (Arrays.asList(firealiases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.add.fire")) { + s.sendMessage(ChatColor.RED + "You don't have permission to add " + FireMethods.getFireColor() + "Firebending"); + return true; + } + bPlayer.addElement(Element.Fire); + GeneralMethods.saveElements(bPlayer); + s.sendMessage(FireMethods.getFireColor() + "You are also a Firebender."); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Fire, Result.ADD)); + return true; + } + if (Arrays.asList(chialiases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.add.chi")) { + s.sendMessage(ChatColor.RED + "You don't have permission to add " + ChiMethods.getChiColor() + "Chiblocking"); + return true; + } + bPlayer.addElement(Element.Chi); + GeneralMethods.saveElements(bPlayer); + s.sendMessage(ChiMethods.getChiColor() + "You are also a ChiBlocker."); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Chi, Result.ADD)); + return true; + } + s.sendMessage(ChatColor.RED + "You must specify an element."); + } + } + if (Arrays.asList(choosealiases).contains(args[0].toLowerCase())) { + // /bending choose [Player] [Element] + if (args.length > 3) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending choose [Player] [Element]"); + s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, and Chi"); + return true; + } + + if (args.length == 2) { + if (!s.hasPermission("bending.command.choose")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + + if (!(s instanceof Player)) { + s.sendMessage(ChatColor.RED + "This command is only usable by players."); + return true; + } + + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(s.getName()); + + if (bPlayer.isPermaRemoved()) { + s.sendMessage(ChatColor.RED + "Your bending was permanently removed."); + return true; + } + + if (!bPlayer.getElements().isEmpty()) { + if (!s.hasPermission("bending.command.rechoose")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + } + if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.choose.air")) { + s.sendMessage(ChatColor.RED + "You don't have permission to choose " + AirMethods.getAirColor() + "Airbending"); + return true; + } + bPlayer.setElement(Element.Air); + s.sendMessage(AirMethods.getAirColor() + "You are now an Airbender."); + GeneralMethods.removeUnusableAbilities(s.getName()); + GeneralMethods.saveElements(bPlayer); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Air, Result.CHOOSE)); + return true; + } + if (Arrays.asList(wateraliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.choose.water")) { + s.sendMessage(ChatColor.RED + "You don't have permission to choose " + WaterMethods.getWaterColor() + "Waterbending"); + return true; + } + bPlayer.setElement(Element.Water); + s.sendMessage(WaterMethods.getWaterColor() + "You are now a Waterbender."); + GeneralMethods.removeUnusableAbilities(s.getName()); + GeneralMethods.saveElements(bPlayer); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Water, Result.CHOOSE)); + return true; + } + if (Arrays.asList(earthaliases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.choose.earth")) { + s.sendMessage(ChatColor.RED + "You don't have permission to choose " + EarthMethods.getEarthColor() + "Earthbending"); + return true; + } + bPlayer.setElement(Element.Earth); + s.sendMessage(EarthMethods.getEarthColor() + "You are now an Earthbender."); + GeneralMethods.removeUnusableAbilities(s.getName()); + GeneralMethods.saveElements(bPlayer); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Earth, Result.CHOOSE)); + return true; + } + if (Arrays.asList(firealiases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.choose.fire")) { + s.sendMessage(ChatColor.RED + "You don't have permission to choose " + FireMethods.getFireColor() + "Firebending"); + return true; + } + bPlayer.setElement(Element.Fire); + s.sendMessage(FireMethods.getFireColor() + "You are now a Firebender."); + GeneralMethods.removeUnusableAbilities(s.getName()); + GeneralMethods.saveElements(bPlayer); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Fire, Result.CHOOSE)); + return true; + } + if (Arrays.asList(chialiases).contains(args[1].toLowerCase())) { + if (!s.hasPermission("bending.command.choose.chi")) { + s.sendMessage(ChatColor.RED + "You don't have permission to choose " + ChiMethods.getChiColor() + "Chiblocking"); + return true; + } + bPlayer.setElement(Element.Chi); + s.sendMessage(ChiMethods.getChiColor() + "You are now a ChiBlocker."); + GeneralMethods.removeUnusableAbilities(s.getName()); + GeneralMethods.saveElements(bPlayer); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, (Player) s, Element.Chi, Result.CHOOSE)); + return true; + } + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending choose [Element]"); + s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, Chi"); + return true; + } + if (args.length == 3) { + if (!s.hasPermission("bending.admin.choose")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + Player target = Bukkit.getPlayer(args[1]); + if (target == null) { + s.sendMessage(ChatColor.RED + "That player is not online."); + return true; + } + BendingPlayer bTarget = GeneralMethods.getBendingPlayer(target.getName()); + +// if (bTarget.isPermaRemoved()) { +// s.sendMessage(ChatColor.RED + "That player's bending was permanently removed."); +// return true; +// } + Element e = null; + if (Arrays.asList(airaliases).contains(args[2])) e = Element.Air; + if (Arrays.asList(wateraliases).contains(args[2])) e = Element.Water; + if (Arrays.asList(earthaliases).contains(args[2])) e = Element.Earth; + if (Arrays.asList(firealiases).contains(args[2])) e = Element.Fire; + if (Arrays.asList(chialiases).contains(args[2])) e = Element.Chi; + + if (e == null) { + s.sendMessage(ChatColor.RED + "You must specify an element."); + return true; + } else { + bTarget.setElement(e); + GeneralMethods.removeUnusableAbilities(target.getName()); + GeneralMethods.saveElements(bTarget); + s.sendMessage(ChatColor.RED + "You have changed " + ChatColor.DARK_AQUA + target.getName() + "'s " + ChatColor.RED + "element to " + ChatColor.DARK_AQUA + e.toString() + ChatColor.RED + "."); + target.sendMessage(ChatColor.RED + "Your bending has been changed to " + ChatColor.DARK_AQUA + e.toString() + ChatColor.RED + " by " + ChatColor.DARK_AQUA + s.getName()); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(s, target, e, Result.CHOOSE)); + return true; + } + } + } + if (Arrays.asList(helpaliases).contains(args[0].toLowerCase())) { + if (!s.hasPermission("bending.command.help")) { + s.sendMessage(ChatColor.RED + "You don't have permission to do that."); + return true; + } + if (args.length != 2) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending help Command/Ability"); + if (s.hasPermission("bending.command.add")) { + s.sendMessage(ChatColor.YELLOW + "/bending add [Element]"); + } + if (s.hasPermission("bending.command.bind")) + s.sendMessage(ChatColor.YELLOW + "/bending bind [Ability] "); + if (s.hasPermission("bending.command.clear")) + s.sendMessage(ChatColor.YELLOW + "/bending clear "); + if (s.hasPermission("bending.command.choose")) + s.sendMessage(ChatColor.YELLOW + "/bending choose [Element]"); + if (s.hasPermission("bending.command.display")) + s.sendMessage(ChatColor.YELLOW + "/bending display "); + if (s.hasPermission("bending.command.import")) + s.sendMessage(ChatColor.YELLOW + "/bending import"); + if (s.hasPermission("bending.admin.permaremove")) + s.sendMessage(ChatColor.YELLOW + "/bending permaremove "); + if (s.hasPermission("bending.admin.remove")) + s.sendMessage(ChatColor.YELLOW + "/bending remove [Player]"); + if (s.hasPermission("bending.command.toggle")) + s.sendMessage(ChatColor.YELLOW + "/bending toggle"); + if (s.hasPermission("bending.command.version")) + s.sendMessage(ChatColor.YELLOW + "/bending version"); + if (s.hasPermission("bending.command.who")) + s.sendMessage(ChatColor.YELLOW + "/bending who"); + if (s.hasPermission("bending.command.give")) + s.sendMessage(ChatColor.YELLOW + "/bending give [Player] [Item] "); + if (s.hasPermission("bending.command.invincible")) + s.sendMessage(ChatColor.YELLOW + "/bending invincible"); + return true; + } + if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { + s.sendMessage(AirMethods.getAirColor() + "Air is the element of freedom. Airbenders are natural pacifists and " + + "great explorers. There is nothing stopping them from scaling the tallest of mountains and walls easily. They specialize in redirection, " + + "from blasting things away with gusts of winds, to forming a shield around them to prevent damage. Easy to get across flat terrains, " + + "such as oceans, there is practically no terrain off limits to Airbenders. They lack much raw damage output, but make up for it with " + + "with their ridiculous amounts of utility and speed."); + s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/qffg9m3"); + } + if (Arrays.asList(wateraliases).contains(args[1].toLowerCase())) { + s.sendMessage(WaterMethods.getWaterColor() + "Water is the element of change. Waterbending focuses on using your " + + "opponents own force against them. Using redirection and various dodging tactics, you can be made " + + "practically untouchable by an opponent. Waterbending provides agility, along with strong offensive " + + "skills while in or near water."); + s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/lod3plv"); + } + if (Arrays.asList(earthaliases).contains(args[1].toLowerCase())) { + s.sendMessage(EarthMethods.getEarthColor() + "Earth is the element of substance. Earthbenders share many of the " + + "same fundamental techniques as Waterbenders, but their domain is quite different and more readily " + + "accessible. Earthbenders dominate the ground and subterranean, having abilities to pull columns " + + "of rock straight up from the earth or drill their way through the mountain. They can also launch " + + "themselves through the air using pillars of rock, and will not hurt themselves assuming they land " + + "on something they can bend. The more skilled Earthbenders can even bend metal."); + s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/qaudl42"); + } + if (Arrays.asList(firealiases).contains(args[1].toLowerCase())) { + s.sendMessage(FireMethods.getFireColor() + "Fire is the element of power. Firebenders focus on destruction and " + + "incineration. Their abilities are pretty straight forward: set things on fire. They do have a bit " + + "of utility however, being able to make themselves un-ignitable, extinguish large areas, cook food " + + "in their hands, extinguish large areas, small bursts of flight, and then comes the abilities to shoot " + + "fire from your hands."); + s.sendMessage(ChatColor.YELLOW + "Firebenders can chain their abilities into combos, type " + + FireMethods.getFireColor() + "/b help FireCombo" + ChatColor.YELLOW + " for more information."); + s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/k4fkjhb"); + } + if (Arrays.asList(chialiases).contains(args[1].toLowerCase())) { + s.sendMessage(ChiMethods.getChiColor() + "Chiblockers focus on bare handed combat, utilizing their agility and " + + "speed to stop any bender right in their path. Although they lack the ability to bend any of the " + + "other elements, they are great in combat, and a serious threat to any bender. Chiblocking was " + + "first shown to be used by Ty Lee in Avatar: The Last Airbender, then later by members of the " + + "Equalists in The Legend of Korra."); + s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/mkp9n6y"); + } + if (Arrays.asList(invinciblealiases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending invincible"); + s.sendMessage(ChatColor.YELLOW + "This command will make you impervious to all Bending damage. Once you " + + "use this command, you will stay invincible until you either log off, or use this command again."); + } + if (Arrays.asList(importaliases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending import"); + s.sendMessage(ChatColor.YELLOW + "This command will import your old bendingPlayers.yml from the Bending plugin." + + " It will generate a convert.yml file to convert the data to be used with this plugin." + + " You can delete the file once the complete message is displayed" + + " This command should only be used ONCE."); + } + if (Arrays.asList(displayaliases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending display "); + s.sendMessage(ChatColor.YELLOW + "This command will show you all of the elements you have bound if you do not specify an element." + + " If you do specify an element (Air, Water, Earth, Fire, or Chi), it will show you all of the available " + + " abilities of that element installed on the server."); + } + if (Arrays.asList(givealiases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending give [Player] [Item] "); + s.sendMessage(ChatColor.YELLOW + "This command will give you an item that was created for the Bending plugin so you do not have to craft it." + + " Each item may have its own properties involved, so the amount of arguments may change. However, the Player and Item will be " + + " required each time you use this command."); + s.sendMessage(ChatColor.DARK_AQUA + "Items: GrapplingHook"); + } + if (Arrays.asList(choosealiases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending choose [Element]"); + s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, Chi"); + s.sendMessage(ChatColor.YELLOW + "This command will allow the user to choose a player either for himself or if specified. " + + " This command can only be used once per player unless they have permission to rechoose their element."); + return true; + } + if (args[1].equalsIgnoreCase("add")) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending add [Element]"); + s.sendMessage(ChatColor.GOLD + "Applicable Elements: " + ChatColor.DARK_AQUA + "Air, Water, Earth, Fire, Chi"); + s.sendMessage(ChatColor.YELLOW + "This command will allow the user to add an element to the targeted , or themselves if the target" + + " is not specified. This command is typically reserved for server administrators."); + return true; + } + if (Arrays.asList(permaremovealiases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending permaremove "); + s.sendMessage(ChatColor.YELLOW + "This command will permanently remove the Bending of the targeted . Once removed, a player" + + " may only receive Bending again if this command is run on them again. This command is typically reserved for" + + " administrators."); + return true; + } + if (Arrays.asList(versionaliases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending version"); + s.sendMessage(ChatColor.YELLOW + "This command will print out the version of ProjectKorra this server is running."); + return true; + } + + if (Arrays.asList(removealiases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending remove [Player]"); + s.sendMessage(ChatColor.YELLOW + "This command will remove the element of the targeted [Player]. The player will be able to re-pick " + + " their element after this command is run on them, assuming their Bending was not permaremoved."); + return true; + } + + if (Arrays.asList(togglealiases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending toggle "); + s.sendMessage(ChatColor.YELLOW + "This command will toggle a player's own Bending on or off. If toggled off, all abilities should stop" + + " working until it is toggled back on. Logging off will automatically toggle your Bending back on. If you run the command /bending toggle all, Bending will be turned off for all players and cannot be turned back on until the command is run again."); + return true; + } + if (args[1].equalsIgnoreCase("who")) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending who "); + s.sendMessage(ChatColor.YELLOW + "This command will tell you what element all players that are online are (If you don't specify a player)" + + " or give you information about the player that you specify."); + return true; + } + + if (Arrays.asList(clearaliases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending clear "); + s.sendMessage(ChatColor.YELLOW + "This command will clear the bound ability from the slot you specify (if you specify one." + + " If you choose not to specify a slot, all of your abilities will be cleared."); + } + if (Arrays.asList(reloadaliases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending reload"); + s.sendMessage(ChatColor.YELLOW + "This command will reload the Bending config file."); + return true; + } + if (Arrays.asList(bindaliases).contains(args[1].toLowerCase())) { + s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending bind [Ability] "); + s.sendMessage(ChatColor.YELLOW + "This command will bind an ability to the slot you specify (if you specify one), or the slot currently" + + " selected in your hotbar (If you do not specify a Slot #)."); + } + if (args[1].equalsIgnoreCase("FireCombo")) { + s.sendMessage(ChatColor.GOLD + "Fire Combos:"); + s.sendMessage(FireMethods.getFireColor() + "FireKick" + ChatColor.WHITE + ": A short ranged arc of fire launches from the player's feet dealing moderate damage to enemies."); + s.sendMessage(ChatColor.GOLD + "FireBlast > FireBlast > (Hold Shift) > FireBlast. "); + s.sendMessage(FireMethods.getFireColor() + "FireSpin" + ChatColor.WHITE + ": A circular array of fire that causes damage and massive knockback to nearby enemies."); + s.sendMessage(ChatColor.GOLD + "FireBlast > FireBlast > FireShield > (Tap Shift). "); + s.sendMessage(FireMethods.getFireColor() + "FireWheel" + ChatColor.WHITE + ": A high-speed wheel of fire that travels along the ground for long distances dealing high damage."); + s.sendMessage(ChatColor.GOLD + "FireShield (Hold Shift) > Right Click a block in front of you twice > Switch to Blaze > Release Shift. "); + s.sendMessage(FireMethods.getFireColor() + "JetBlast" + ChatColor.WHITE + ": Create an explosive blast that propels your FireJet at higher speeds."); + s.sendMessage(ChatColor.GOLD + "FireJet (Tap Shift) > FireJet (Tap Shift) > FireShield (Tap Shift) > FireJet. "); + s.sendMessage(FireMethods.getFireColor() + "JetBlaze" + ChatColor.WHITE + ": Damages and burns all enemies in the proximity of your FireJet."); + s.sendMessage(ChatColor.GOLD + "FireJet (Tap Shift) > FireJet (Tap Shift) > Blaze (Tap Shift) > FireJet. "); + for(ComboAbilityModule cam : ComboModuleManager.combo) + { + if(cam.getElement().equals(Element.Fire.toString())) + { + ChatColor color = GeneralMethods.getAvatarColor(); + if(cam.getSubElement() == null) + color = FireMethods.getFireColor(); + else color = GeneralMethods.getSubBendingColor(Element.Fire); + s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); + s.sendMessage(ChatColor.GOLD + cam.getInstructions()); + } + } + } + if (args[1].equalsIgnoreCase("AirCombo")) { + s.sendMessage(ChatColor.GOLD + "AirCombo:"); + s.sendMessage(AirMethods.getAirColor() + "Twister" + ChatColor.WHITE + ": Create a cyclone of air that travels along the ground grabbing nearby entities."); + s.sendMessage(ChatColor.GOLD + "AirShield (Tap Shift) > Tornado (Hold Shift) > AirBlast (Left Click)"); + s.sendMessage(AirMethods.getAirColor() + "AirStream" + ChatColor.WHITE + ": Control a large stream of air that grabs onto enemies allowing you to direct them temporarily."); + s.sendMessage(ChatColor.GOLD + "AirShield (Hold Shift) > AirSuction (Left Click) > AirBlast (Left Click)"); + s.sendMessage(AirMethods.getAirColor() + "AirSweep" + ChatColor.WHITE + ": Sweep the air in front of you hitting multiple enemies, causing moderate damage and a large knockback. The radius and direction of AirSweep is controlled by moving your mouse in a sweeping motion. For example, if you want to AirSweep upward, then move your mouse upward right after you left click AirBurst"); + s.sendMessage(ChatColor.GOLD + "AirSwipe (Left Click) > AirSwipe (Left Click) > AirBurst (Hold Shift) > AirBurst (Left Click)"); + for(ComboAbilityModule cam : ComboModuleManager.combo) + { + if(cam.getElement().equals(Element.Air.toString())) + { + ChatColor color = GeneralMethods.getAvatarColor(); + if(cam.getSubElement() == null) + color = AirMethods.getAirColor(); + else color = GeneralMethods.getSubBendingColor(Element.valueOf(cam.getElement())); + s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); + s.sendMessage(ChatColor.GOLD + cam.getInstructions()); + } + } + } + if (args[1].equalsIgnoreCase("WaterCombo")) { + s.sendMessage(ChatColor.GOLD + "WaterCombos:"); + s.sendMessage(WaterMethods.getWaterColor() + "IceWave" + ChatColor.WHITE + ": PhaseChange your WaterWave into an IceWave that freezes and damages enemies."); + s.sendMessage(ChatColor.GOLD + "Create a WaterSpout Wave > PhaseChange (Left Click)"); + s.sendMessage(WaterMethods.getWaterColor() + "IceBullet" + ChatColor.WHITE + ": Using a large cavern of ice, you can punch ice shards at your opponent causing moderate damage. To rapid fire, you must alternate between Left clicking and right clicking with IceBlast."); + s.sendMessage(ChatColor.GOLD + "WaterBubble (Tap Shift) > IceBlast (Hold Shift) > IceBlast (Left Click) > Wait for ice to Form > Then alternate between Left and Right click with IceBlast"); + for(ComboAbilityModule cam : ComboModuleManager.combo) + { + if(cam.getElement().equals(Element.Water.toString())) + { + ChatColor color = GeneralMethods.getAvatarColor(); + if(cam.getSubElement() == null) + color = WaterMethods.getWaterColor(); + else color = GeneralMethods.getSubBendingColor(Element.valueOf(cam.getElement())); + s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); + s.sendMessage(ChatColor.GOLD + cam.getInstructions()); + } + } + } + if (args[1].equalsIgnoreCase("EarthCombo")) { + s.sendMessage(ChatColor.GOLD + "EarthCombos:"); + for(ComboAbilityModule cam : ComboModuleManager.combo) + { + if(cam.getElement().equals(Element.Earth.toString())) + { + ChatColor color = GeneralMethods.getAvatarColor(); + if(cam.getSubElement() == null) + color = EarthMethods.getEarthColor(); + else color = GeneralMethods.getSubBendingColor(Element.valueOf(cam.getElement())); + s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); + s.sendMessage(ChatColor.GOLD + cam.getInstructions()); + } + } + } + if (args[1].equalsIgnoreCase("ChiCombo")) + { + s.sendMessage(ChatColor.GOLD + "ChiCombos:"); + s.sendMessage(ChiMethods.getChiColor() + "Immobilize" + ChatColor.WHITE + ": Deliver a series of strikes to an enemy to temporarely immobilize them."); + s.sendMessage(ChatColor.GOLD + "QuickStrike > SwiftKick > QuickStrike > QuickStrike"); + for(ComboAbilityModule cam : ComboModuleManager.combo) + { + if(cam.getElement().equals(Element.Chi.toString())) + { + ChatColor color = GeneralMethods.getAvatarColor(); + if(cam.getSubElement() == null) + color = ChiMethods.getChiColor(); + else color = GeneralMethods.getSubBendingColor(Element.valueOf(cam.getElement())); + s.sendMessage(color + cam.getName() + ChatColor.WHITE + ": " + cam.getDescription()); + s.sendMessage(ChatColor.GOLD + cam.getInstructions()); + } + } + } + if (GeneralMethods.abilityExists(args[1])) { + String ability = GeneralMethods.getAbility(args[1]); + if (AirMethods.isAirAbility(ability)) { + s.sendMessage(AirMethods.getAirColor() + ability + " - "); + s.sendMessage(AirMethods.getAirColor() + AbilityModuleManager.descriptions.get(ability)); + } + else if (WaterMethods.isWaterAbility(ability)) { + s.sendMessage(WaterMethods.getWaterColor() + ability + " - "); + s.sendMessage(WaterMethods.getWaterColor() + AbilityModuleManager.descriptions.get(ability)); + } + else if (EarthMethods.isEarthAbility(ability)) { + if (EarthMethods.isMetalbendingAbility(ability)) { + s.sendMessage(EarthMethods.getMetalbendingColor() + ability + " - "); + s.sendMessage(EarthMethods.getMetalbendingColor() + AbilityModuleManager.descriptions.get(ability)); + } else { + s.sendMessage(EarthMethods.getEarthColor() + ability + " - "); + s.sendMessage(EarthMethods.getEarthColor() + AbilityModuleManager.descriptions.get(ability)); + } + } + else if (FireMethods.isFireAbility(ability)) { + s.sendMessage(FireMethods.getFireColor() + ability + " - "); + s.sendMessage(FireMethods.getFireColor() + AbilityModuleManager.descriptions.get(ability)); + } + else if (ChiMethods.isChiAbility(ability)) { + s.sendMessage(ChiMethods.getChiColor() + ability + " - "); + s.sendMessage(ChiMethods.getChiColor() + AbilityModuleManager.descriptions.get(ability)); + } + else { + s.sendMessage(GeneralMethods.getAvatarColor() + ability + " - "); + s.sendMessage(GeneralMethods.getAvatarColor() + AbilityModuleManager.descriptions.get(ability)); + } + } + } + return true; + } + }; projectkorra.setExecutor(exe); + } + +} From 7a4af1ef01a75a91828bc465d39026587a16c3ba Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:20:05 +0100 Subject: [PATCH 16/25] Added more WaterArms config options. --- .../ProjectKorra/ConfigManager.java | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/ConfigManager.java b/src/com/projectkorra/ProjectKorra/ConfigManager.java index af9f9922..4bba285a 100644 --- a/src/com/projectkorra/ProjectKorra/ConfigManager.java +++ b/src/com/projectkorra/ProjectKorra/ConfigManager.java @@ -372,8 +372,10 @@ public class ConfigManager { + "\nPull - Use your Arms to pull blocks, items, mobs or even players towards you!" + "\nPunch - An offensive attack, harming players or mobs!" + "\nGrapple - Scale walls and speed across battlefields, using your Arms as a grappling hook!" + + "\nGrab - Grab an entity with your arm, and swing them about!" + "\nFreeze - Use your Arms to fire small blasts of ice in any direction!" + "\nSpear - Throw your Arms in any direction, freezing whatever it hits!"); + config.addDefault("Abilities.Water.WaterArms.SneakMessage", "Active Ability:"); config.addDefault("Abilities.Water.WaterArms.Arms.InitialLength", 4); config.addDefault("Abilities.Water.WaterArms.Arms.SourceGrabRange", 4); @@ -381,7 +383,6 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterArms.Arms.MaxAlternateUsage", 50); config.addDefault("Abilities.Water.WaterArms.Arms.MaxIceShots", 5); config.addDefault("Abilities.Water.WaterArms.Arms.Cooldown", 20000); - config.addDefault("Abilities.Water.WaterArms.Arms.AllowSpectatorUse", false); config.addDefault("Abilities.Water.WaterArms.Arms.AllowPlantSource", true); config.addDefault("Abilities.Water.WaterArms.Arms.Lightning.Enabled", true); @@ -391,38 +392,34 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldownEnabled", false); config.addDefault("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown", 200); - config.addDefault("Abilities.Water.WaterArms.WhipMode.MaxLength", 20); - config.addDefault("Abilities.Water.WaterArms.WhipMode.MaxLengthWeak", 12); + config.addDefault("Abilities.Water.WaterArms.Whip.MaxLength", 20); + config.addDefault("Abilities.Water.WaterArms.Whip.MaxLengthWeak", 12); - config.addDefault("Abilities.Water.WaterArms.WhipMode.NightAugments.MaxLength.Normal", 24); - config.addDefault("Abilities.Water.WaterArms.WhipMode.NightAugments.MaxLength.FullMoon", 30); + config.addDefault("Abilities.Water.WaterArms.Whip.NightAugments.MaxLength.Normal", 24); + config.addDefault("Abilities.Water.WaterArms.Whip.NightAugments.MaxLength.FullMoon", 30); - config.addDefault("Abilities.Water.WaterArms.WhipMode.Pull.PullBlocks", true); - config.addDefault("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamage", Double.valueOf(2.0)); - config.addDefault("Abilities.Water.WaterArms.WhipMode.Pull.BlockRevertDelay", 20000); - config.addDefault("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamageUser", false); + config.addDefault("Abilities.Water.WaterArms.Whip.Punch.PunchDamage", Double.valueOf(3.0)); - config.addDefault("Abilities.Water.WaterArms.WhipMode.Punch.PunchDamage", Double.valueOf(3.0)); + config.addDefault("Abilities.Water.WaterArms.Whip.Grapple.RespectRegions", false); - config.addDefault("Abilities.Water.WaterArms.WhipMode.Grapple.GrappleBarriers", false); - config.addDefault("Abilities.Water.WaterArms.WhipMode.Grapple.RespectRegions", false); + config.addDefault("Abilities.Water.WaterArms.Whip.Grab.HoldTime", 10000); - config.addDefault("Abilities.Water.WaterArms.IceMode.Range", 20); - config.addDefault("Abilities.Water.WaterArms.IceMode.Damage", Double.valueOf(2.0)); + config.addDefault("Abilities.Water.WaterArms.Freeze.Range", 20); + config.addDefault("Abilities.Water.WaterArms.Freeze.Damage", Double.valueOf(2.0)); - config.addDefault("Abilities.Water.WaterArms.SpearMode.Range", 40); - config.addDefault("Abilities.Water.WaterArms.SpearMode.Damage", Double.valueOf(4.0)); - config.addDefault("Abilities.Water.WaterArms.SpearMode.DamageEnabled", true); - config.addDefault("Abilities.Water.WaterArms.SpearMode.Sphere", 2); - config.addDefault("Abilities.Water.WaterArms.SpearMode.Duration", 6000); - config.addDefault("Abilities.Water.WaterArms.SpearMode.Length", 18); + config.addDefault("Abilities.Water.WaterArms.Spear.Range", 40); + config.addDefault("Abilities.Water.WaterArms.Spear.Damage", Double.valueOf(4.0)); + config.addDefault("Abilities.Water.WaterArms.Spear.DamageEnabled", true); + config.addDefault("Abilities.Water.WaterArms.Spear.Sphere", 2); + config.addDefault("Abilities.Water.WaterArms.Spear.Duration", 6000); + config.addDefault("Abilities.Water.WaterArms.Spear.Length", 18); - config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Range.Normal", 45); - config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Range.FullMoon", 60); - config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Sphere.Normal", 3); - config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Sphere.FullMoon", 6); - config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Duration.Normal", 7000); - config.addDefault("Abilities.Water.WaterArms.SpearMode.NightAugments.Duration.FullMoon", 12000); + config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Range.Normal", 45); + config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Range.FullMoon", 60); + config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Sphere.Normal", 3); + config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Sphere.FullMoon", 6); + config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Duration.Normal", 7000); + config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Duration.FullMoon", 12000); config.addDefault("Abilities.Water.WaterBubble.Enabled", true); config.addDefault("Abilities.Water.WaterBubble.Description","To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."); From 72321963be0b075ba6294755fe09f655bd838b2b Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:20:49 +0100 Subject: [PATCH 17/25] Added WaterArms sneak event to display a little note of what ability is bound. --- src/com/projectkorra/ProjectKorra/PKListener.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/PKListener.java b/src/com/projectkorra/ProjectKorra/PKListener.java index 6b4b599c..e7d949da 100644 --- a/src/com/projectkorra/ProjectKorra/PKListener.java +++ b/src/com/projectkorra/ProjectKorra/PKListener.java @@ -443,6 +443,11 @@ public class PKListener implements Listener { event.setCancelled(true); return; } + + if(!player.isSneaking() && WaterArms.hasPlayer(player)){ + WaterArms.displayBoundMsg(player); + return; + } AirScooter.check(player); @@ -716,10 +721,6 @@ public class PKListener implements Listener { LavaSurge.falling.remove(entity); event.setCancelled(true); } - if (WaterArms.falling.containsKey(entity)) { - WaterArms.falling.remove(entity); - event.setCancelled(true); - } } } From 706ee1cd8c0c5dadb7c4e52031a505b703d7abed Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:21:50 +0100 Subject: [PATCH 18/25] Added method for a chi blocker to highjump out of WaterArms grab mode. --- .../ProjectKorra/chiblocking/HighJump.java | 83 ++++++++++--------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/chiblocking/HighJump.java b/src/com/projectkorra/ProjectKorra/chiblocking/HighJump.java index 47af4f29..b93eafab 100644 --- a/src/com/projectkorra/ProjectKorra/chiblocking/HighJump.java +++ b/src/com/projectkorra/ProjectKorra/chiblocking/HighJump.java @@ -1,38 +1,45 @@ -package com.projectkorra.ProjectKorra.chiblocking; - -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import com.projectkorra.ProjectKorra.BendingPlayer; -import com.projectkorra.ProjectKorra.GeneralMethods; -import com.projectkorra.ProjectKorra.ProjectKorra; - -public class HighJump { - - private int jumpheight = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.HighJump.Height"); - private long cooldown = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.HighJump.Cooldown"); - - public HighJump(Player p) { - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(p.getName()); - - if (bPlayer.isOnCooldown("HighJump")) return; - jump(p); - bPlayer.addCooldown("HighJump", cooldown); - - } - - private void jump(Player p) { - if (!GeneralMethods.isSolid(p.getLocation().getBlock() - .getRelative(BlockFace.DOWN))) - return; - Vector vec = p.getVelocity(); - vec.setY(jumpheight); - p.setVelocity(vec); - return; - } - - public static String getDescription() { - return "To use this ability, simply click. You will jump quite high. This ability has a short cooldown."; - } -} +package com.projectkorra.ProjectKorra.chiblocking; + +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import com.projectkorra.ProjectKorra.BendingPlayer; +import com.projectkorra.ProjectKorra.GeneralMethods; +import com.projectkorra.ProjectKorra.ProjectKorra; +import com.projectkorra.ProjectKorra.waterbending.WaterArmsWhip; + +public class HighJump { + + private int jumpheight = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.HighJump.Height"); + private long cooldown = ProjectKorra.plugin.getConfig().getInt("Abilities.Chi.HighJump.Cooldown"); + + public HighJump(Player p) { + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(p.getName()); + + if (bPlayer.isOnCooldown("HighJump")) return; + if (WaterArmsWhip.grabbedEntities.containsKey(p)) { + WaterArmsWhip waw = WaterArmsWhip.instances.get(WaterArmsWhip.grabbedEntities.get(p)); + if (waw != null) { + waw.setGrabbed(false); + } + } + jump(p); + bPlayer.addCooldown("HighJump", cooldown); + + } + + private void jump(Player p) { + if (!GeneralMethods.isSolid(p.getLocation().getBlock() + .getRelative(BlockFace.DOWN))) + return; + Vector vec = p.getVelocity(); + vec.setY(jumpheight); + p.setVelocity(vec); + return; + } + + public static String getDescription() { + return "To use this ability, simply click. You will jump quite high. This ability has a short cooldown."; + } +} From 50e83f6e35525685332191a58693651c48df7136 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:22:12 +0100 Subject: [PATCH 19/25] Completed Recode and added getters and setters. --- .../ProjectKorra/waterbending/WaterArms.java | 527 +++++++++++------- 1 file changed, 318 insertions(+), 209 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/waterbending/WaterArms.java b/src/com/projectkorra/ProjectKorra/waterbending/WaterArms.java index f7531abe..f5106e9f 100644 --- a/src/com/projectkorra/ProjectKorra/waterbending/WaterArms.java +++ b/src/com/projectkorra/ProjectKorra/waterbending/WaterArms.java @@ -11,9 +11,6 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Entity; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import com.projectkorra.ProjectKorra.GeneralMethods; @@ -26,7 +23,7 @@ import com.projectkorra.ProjectKorra.firebending.FireMethods; import com.projectkorra.ProjectKorra.firebending.Lightning; import com.projectkorra.ProjectKorra.waterbending.WaterArmsWhip.Whip; -public class WaterArms{ +public class WaterArms { /** * Arm Enum value for deciding which arm is being used. @@ -34,14 +31,14 @@ public class WaterArms{ public enum Arm { Right, Left; } - + private static FileConfiguration config = ProjectKorra.plugin.getConfig(); public static ConcurrentHashMap instances = new ConcurrentHashMap(); public static ConcurrentHashMap revert = new ConcurrentHashMap(); - public static ConcurrentHashMap falling = new ConcurrentHashMap(); - - private static Integer[] unbreakable = {7, 8, 9, 10, 11, 49, 54, 90, 119, 120, 130, 146}; + + private static Integer[] unbreakable = { 7, 8, 9, 10, 11, 49, 54, 90, 119, + 120, 130, 146 }; private Player player; private World world; @@ -57,49 +54,78 @@ public class WaterArms{ private int lengthReduction = 0; - private int initLength = config.getInt("Abilities.Water.WaterArms.Arms.InitialLength"); - private int sourceGrabRange = config.getInt("Abilities.Water.WaterArms.Arms.SourceGrabRange"); - private int maxPunches = config.getInt("Abilities.Water.WaterArms.Arms.MaxAttacks"); - private int maxIceBlasts = config.getInt("Abilities.Water.WaterArms.Arms.MaxIceShots"); - private int maxUses = config.getInt("Abilities.Water.WaterArms.Arms.MaxAlternateUsage"); - private long cooldown = config.getLong("Abilities.Water.WaterArms.Arms.cooldown"); - private boolean canUsePlantSource = config.getBoolean("Abilities.Water.WaterArms.Arms.AllowPlantSource"); + private int initLength = config + .getInt("Abilities.Water.WaterArms.Arms.InitialLength"); + private int sourceGrabRange = config + .getInt("Abilities.Water.WaterArms.Arms.SourceGrabRange"); + private int maxPunches = config + .getInt("Abilities.Water.WaterArms.Arms.MaxAttacks"); + private int maxIceBlasts = config + .getInt("Abilities.Water.WaterArms.Arms.MaxIceShots"); + private int maxUses = config + .getInt("Abilities.Water.WaterArms.Arms.MaxAlternateUsage"); + private long cooldown = config + .getLong("Abilities.Water.WaterArms.Arms.Cooldown"); + private boolean canUsePlantSource = config + .getBoolean("Abilities.Water.WaterArms.Arms.AllowPlantSource"); - private boolean lightningEnabled = config.getBoolean("Abilities.Water.WaterArms.Arms.Lightning.Enabled"); - private double lightningDamage = config.getDouble("Abilities.Water.WaterArms.Arms.Lightning.Damage"); - private boolean lightningKill = config.getBoolean("Abilities.Water.WaterArms.Arms.Lightning.KillUser"); - - private static double blockDamage = config.getDouble("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamage"); - private static boolean pullBlocksDamageUser = config.getBoolean("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamageUser"); + private boolean lightningEnabled = config + .getBoolean("Abilities.Water.WaterArms.Arms.Lightning.Enabled"); + private double lightningDamage = config + .getDouble("Abilities.Water.WaterArms.Arms.Lightning.Damage"); + private boolean lightningKill = config + .getBoolean("Abilities.Water.WaterArms.Arms.Lightning.KillUser"); + + private static String sneakMsg = config + .getString("Abilities.Water.WaterArms.SneakMessage"); private int selectedSlot = 0; private int freezeSlot = 4; private long lastClickTime; - public WaterArms(Player player){ - if(instances.containsKey(player)){ - if(player.isSneaking()){ + public WaterArms(Player player) { + if (instances.containsKey(player)) { + if (player.isSneaking()) { instances.get(player).prepareCancel(); - }else{ - switch(player.getInventory().getHeldItemSlot()){ + } else { + switch (player.getInventory().getHeldItemSlot()) { case 0: - new WaterArmsWhip(player, Whip.Pull); + if (player.hasPermission("bending.ability.WaterArms.Pull")) { + new WaterArmsWhip(player, Whip.Pull); + } break; case 1: - new WaterArmsWhip(player, Whip.Punch); + if (player.hasPermission("bending.ability.WaterArms.Punch")) { + new WaterArmsWhip(player, Whip.Punch); + } break; case 2: - new WaterArmsWhip(player, Whip.Grapple); + if (player + .hasPermission("bending.ability.WaterArms.Grapple")) { + new WaterArmsWhip(player, Whip.Grapple); + } break; case 3: - new WaterArmsWhip(player, Whip.Grab); + if (player.hasPermission("bending.ability.WaterArms.Grab")) { + new WaterArmsWhip(player, Whip.Grab); + } break; case 4: - //new WaterArmsIce(player); + if (player + .hasPermission("bending.ability.WaterArms.Freeze") + && WaterMethods.canIcebend(player)) { + new WaterArmsFreeze(player); + } break; case 5: - //new WaterArmsSpear(player); + if (player.hasPermission("bending.ability.WaterArms.Spear")) { + if (WaterMethods.canIcebend(player)) { + new WaterArmsSpear(player, true); + } else { + new WaterArmsSpear(player, false); + } + } break; default: break; @@ -108,40 +134,50 @@ public class WaterArms{ return; } this.player = player; - if(canUse(player) && prepare()){ + if (canUse(player) && prepare()) { world = player.getWorld(); instances.put(player, this); MultiAbilityManager.bindMultiAbility(player, "WaterArms"); - if(ChatColor.stripColor(GeneralMethods.getBoundAbility(player)) == null){ + if (ChatColor.stripColor(GeneralMethods.getBoundAbility(player)) == null) { remove(); return; } + player.sendMessage(WaterMethods.getWaterColor() + sneakMsg + " " + + GeneralMethods.getBoundAbility(player)); } } - private boolean canUse(Player player){ - if(GeneralMethods.getBoundAbility(player) == null) + private boolean canUse(Player player) { + if (GeneralMethods.getBoundAbility(player) == null) return false; - if(!GeneralMethods.canBend(player.getName(), "WaterArms")) + if (!GeneralMethods.canBend(player.getName(), "WaterArms")) return false; - if(GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", player.getLocation())) + if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", + player.getLocation())) return false; - if(GeneralMethods.getBendingPlayer(player.getName()).isOnCooldown("WaterArms")) + if (GeneralMethods.getBendingPlayer(player.getName()).isOnCooldown( + "WaterArms")) return false; - if(GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterArms")) + if (GeneralMethods.getBoundAbility(player) + .equalsIgnoreCase("WaterArms")) return true; return false; } - private boolean prepare(){ - Block sourceblock = WaterMethods.getWaterSourceBlock(player, sourceGrabRange, canUsePlantSource); - if(sourceblock != null){ - if(WaterMethods.isPlant(sourceblock)){ + private boolean prepare() { + Block sourceblock = WaterMethods.getWaterSourceBlock(player, + sourceGrabRange, canUsePlantSource); + if (sourceblock != null) { + if (WaterMethods.isPlant(sourceblock)) { fullSource = false; } - ParticleEffect.LARGE_SMOKE.display(WaterMethods.getWaterSourceBlock(player, sourceGrabRange, canUsePlantSource).getLocation().clone().add(0.5,0.5,0.5), 0, 0, 0, 0F, 4); + ParticleEffect.LARGE_SMOKE.display( + WaterMethods + .getWaterSourceBlock(player, sourceGrabRange, + canUsePlantSource).getLocation().clone() + .add(0.5, 0.5, 0.5), 0, 0, 0, 0F, 4); return true; - }else if(WaterReturn.hasWaterBottle(player)){ + } else if (WaterReturn.hasWaterBottle(player)) { WaterReturn.emptyWaterBottle(player); fullSource = false; return true; @@ -149,23 +185,24 @@ public class WaterArms{ return false; } - private void progress(){ - if (!instances.containsKey(player)){ + private void progress() { + if (!instances.containsKey(player)) { return; } - if(player.isDead() || !player.isOnline() || world != player.getWorld()){ + if (player.isDead() || !player.isOnline() || world != player.getWorld()) { remove(); return; } - if(!GeneralMethods.getBendingPlayer(player.getName()).isToggled()){ + if (!GeneralMethods.getBendingPlayer(player.getName()).isToggled()) { remove(); return; } - if(!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")){ + if (!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")) { remove(); return; } - if(maxPunches == 0 || maxUses == 0 || maxIceBlasts == 0 || (leftArmConsumed && rightArmConsumed)){ + if (maxPunches == 0 || maxUses == 0 || maxIceBlasts == 0 + || (leftArmConsumed && rightArmConsumed)) { remove(); return; } @@ -174,54 +211,67 @@ public class WaterArms{ displayRightArm(); displayLeftArm(); - if(lightningEnabled) + if (lightningEnabled) checkIfZapped(); } - private boolean canPlaceBlock(Block block){ - if(!EarthMethods.isTransparentToEarthbending(player, block) && !(WaterMethods.isWater(block) && TempBlock.isTempBlock(block))) + private boolean canPlaceBlock(Block block) { + if (!EarthMethods.isTransparentToEarthbending(player, block) + && !(WaterMethods.isWater(block) && TempBlock + .isTempBlock(block))) return false; return true; } /** - * Displays the right arm. - * Returns false if the arm cannot be fully displayed. + * Displays the right arm. Returns false if the arm cannot be fully + * displayed. + * * @return */ - public boolean displayRightArm(){ - if(rightArmConsumed) + public boolean displayRightArm() { + if (rightArmConsumed) return false; - Location r1 = GeneralMethods.getRightSide(player.getLocation(), 1).add(0, 1.5, 0); - if(!canPlaceBlock(r1.getBlock())) + Location r1 = GeneralMethods.getRightSide(player.getLocation(), 1).add( + 0, 1.5, 0); + if (!canPlaceBlock(r1.getBlock())) return false; - if(!(getRightHandPos().getBlock().getLocation().equals(r1.getBlock().getLocation()))){ + if (!(getRightHandPos().getBlock().getLocation().equals(r1.getBlock() + .getLocation()))) { new TempBlock(r1.getBlock(), Material.STATIONARY_WATER, (byte) 5); revert.put(r1.getBlock(), 0L); } - Location r2 = GeneralMethods.getRightSide(player.getLocation(), 2).add(0, 1.5, 0); - if(!canPlaceBlock(r2.getBlock())) + Location r2 = GeneralMethods.getRightSide(player.getLocation(), 2).add( + 0, 1.5, 0); + if (!canPlaceBlock(r2.getBlock())) return false; new TempBlock(r2.getBlock(), Material.STATIONARY_WATER, (byte) 0); revert.put(r2.getBlock(), 0L); - for(int j = 0; j <= initLength; j++){ - Location r3 = r2.clone().toVector().add(player.getLocation().clone().getDirection().multiply(j)).toLocation(player.getWorld()); - if(!canPlaceBlock(r3.getBlock())){ - if(selectedSlot == freezeSlot && r3.getBlock().getType().equals(Material.ICE)) + for (int j = 0; j <= initLength; j++) { + Location r3 = r2 + .clone() + .toVector() + .add(player.getLocation().clone().getDirection() + .multiply(j)).toLocation(player.getWorld()); + if (!canPlaceBlock(r3.getBlock())) { + if (selectedSlot == freezeSlot + && r3.getBlock().getType().equals(Material.ICE)) continue; return false; } - if(j >= 1 && selectedSlot == freezeSlot){ + if (j >= 1 && selectedSlot == freezeSlot + && WaterMethods.canIcebend(player)) { new TempBlock(r3.getBlock(), Material.ICE, (byte) 0); revert.put(r3.getBlock(), 0L); - }else{ - new TempBlock(r3.getBlock(), Material.STATIONARY_WATER, (byte) 0); + } else { + new TempBlock(r3.getBlock(), Material.STATIONARY_WATER, + (byte) 0); revert.put(r3.getBlock(), 0L); } } @@ -230,43 +280,54 @@ public class WaterArms{ } /** - * Displays the left arm. - * Returns false if the arm cannot be fully displayed. + * Displays the left arm. Returns false if the arm cannot be fully + * displayed. + * * @return */ - public boolean displayLeftArm(){ - if(leftArmConsumed) + public boolean displayLeftArm() { + if (leftArmConsumed) return false; - Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 1).add(0, 1.5, 0); - if(!canPlaceBlock(l1.getBlock())) + Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 1).add( + 0, 1.5, 0); + if (!canPlaceBlock(l1.getBlock())) return false; - if(!(getLeftHandPos().getBlock().getLocation().equals(l1.getBlock().getLocation()))){ + if (!(getLeftHandPos().getBlock().getLocation().equals(l1.getBlock() + .getLocation()))) { new TempBlock(l1.getBlock(), Material.STATIONARY_WATER, (byte) 5); revert.put(l1.getBlock(), 0L); } - Location l2 = GeneralMethods.getLeftSide(player.getLocation(), 2).add(0, 1.5, 0); - if(!canPlaceBlock(l2.getBlock())) + Location l2 = GeneralMethods.getLeftSide(player.getLocation(), 2).add( + 0, 1.5, 0); + if (!canPlaceBlock(l2.getBlock())) return false; new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, (byte) 0); revert.put(l2.getBlock(), 0L); - for(int j = 0; j <= initLength; j++){ - Location l3 = l2.clone().toVector().add(player.getLocation().clone().getDirection().multiply(j)).toLocation(player.getWorld()); - if(!canPlaceBlock(l3.getBlock())){ - if(selectedSlot == freezeSlot && l3.getBlock().getType().equals(Material.ICE)) + for (int j = 0; j <= initLength; j++) { + Location l3 = l2 + .clone() + .toVector() + .add(player.getLocation().clone().getDirection() + .multiply(j)).toLocation(player.getWorld()); + if (!canPlaceBlock(l3.getBlock())) { + if (selectedSlot == freezeSlot + && l3.getBlock().getType().equals(Material.ICE)) continue; return false; } - if(j >= 1 && selectedSlot == freezeSlot){ + if (j >= 1 && selectedSlot == freezeSlot + && WaterMethods.canIcebend(player)) { new TempBlock(l3.getBlock(), Material.ICE, (byte) 0); revert.put(l3.getBlock(), 0L); - }else{ - new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, (byte) 0); + } else { + new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, + (byte) 0); revert.put(l3.getBlock(), 0L); } } @@ -276,85 +337,81 @@ public class WaterArms{ /** * Calculate roughly where the player's right hand is. + * * @return */ - private Location getRightHandPos(){ - return GeneralMethods.getRightSide(player.getLocation(), .34).add(0, 1.5, 0); + private Location getRightHandPos() { + return GeneralMethods.getRightSide(player.getLocation(), .34).add(0, + 1.5, 0); } /** * Calculate roughly where the player's left hand is. + * * @return */ - private Location getLeftHandPos(){ - return GeneralMethods.getLeftSide(player.getLocation(), .34).add(0, 1.5, 0); + private Location getLeftHandPos() { + return GeneralMethods.getLeftSide(player.getLocation(), .34).add(0, + 1.5, 0); } /** - * Returns the location of the tip of the right arm, assuming it is fully extended. - * Use the displayRightArm() check to see if it is fully extended. + * Returns the location of the tip of the right arm, assuming it is fully + * extended. Use the displayRightArm() check to see if it is fully extended. + * * @return */ - public Location getRightArmEnd(){ - Location r1 = GeneralMethods.getRightSide(player.getLocation(), 2).add(0, 1.5, 0); - return r1.clone().add(player.getLocation().getDirection().normalize().multiply(initLength)); + public Location getRightArmEnd() { + Location r1 = GeneralMethods.getRightSide(player.getLocation(), 2).add( + 0, 1.5, 0); + return r1.clone().add( + player.getLocation().getDirection().normalize() + .multiply(initLength)); } /** - * Returns the location of the tip of the left arm assuming it is fully extended. - * Use the displayLeftArm() check to see if it is fully extended. + * Returns the location of the tip of the left arm assuming it is fully + * extended. Use the displayLeftArm() check to see if it is fully extended. + * * @return */ - public Location getLeftArmEnd(){ - Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 2).add(0, 1.5, 0); - return l1.clone().add(player.getLocation().getDirection().normalize().multiply(initLength)); + public Location getLeftArmEnd() { + Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 2).add( + 0, 1.5, 0); + return l1.clone().add( + player.getLocation().getDirection().normalize() + .multiply(initLength)); } - private static void progressRevert(boolean ignoreTime){ - for(Block block : revert.keySet()){ + private static void progressRevert(boolean ignoreTime) { + for (Block block : revert.keySet()) { long time = revert.get(block); - if(System.currentTimeMillis() > time || ignoreTime){ - if(TempBlock.isTempBlock(block)) + if (System.currentTimeMillis() > time || ignoreTime) { + if (TempBlock.isTempBlock(block)) TempBlock.revertBlock(block, Material.AIR); revert.remove(block); } } } - - private static void trackEntities(boolean remove){ - for(FallingBlock fallingBlock : falling.keySet()){ - if(remove){ - fallingBlock.remove(); - falling.remove(fallingBlock); - } - if(!fallingBlock.isDead()){ - for(Entity entity : GeneralMethods.getEntitiesAroundPoint(fallingBlock.getLocation(), 2.0)){ - if(entity instanceof LivingEntity){ - if(!pullBlocksDamageUser && entity.getEntityId() == falling.get(fallingBlock).getEntityId()) - continue; - GeneralMethods.damageEntity(falling.get(fallingBlock), entity, blockDamage); - fallingBlock.remove(); - falling.remove(fallingBlock); - } - } - } - } - } - - private void checkIfZapped(){ - for (int i = 0; i < Lightning.instances.size(); i++){ + private void checkIfZapped() { + for (int i = 0; i < Lightning.instances.size(); i++) { Lightning l = Lightning.instances.get(i); - for(Lightning.Arc arc : l.getArcs()){ - for(Block arm : revert.keySet()){ - for(Location loc : arc.getPoints()){ - if(arm.getLocation().getWorld() == loc.getWorld() && loc.distance(arm.getLocation()) <= 2.5){ - for(Location l1 : getOffsetLocations(4, arm.getLocation(), 1.25)) + for (Lightning.Arc arc : l.getArcs()) { + for (Block arm : revert.keySet()) { + for (Location loc : arc.getPoints()) { + if (arm.getLocation().getWorld() == loc.getWorld() + && loc.distance(arm.getLocation()) <= 2.5) { + for (Location l1 : getOffsetLocations(4, + arm.getLocation(), 1.25)) FireMethods.playLightningbendingParticle(l1); - if(lightningKill) - GeneralMethods.damageEntity(Lightning.instances.get(i).getPlayer(), player, 60D); + if (lightningKill) + GeneralMethods.damageEntity(Lightning.instances + .get(i).getPlayer(), player, 60D); else - GeneralMethods.damageEntity(Lightning.instances.get(i).getPlayer(), player, lightningDamage); + GeneralMethods.damageEntity(Lightning.instances + .get(i).getPlayer(), player, + lightningDamage); } } } @@ -362,70 +419,87 @@ public class WaterArms{ } } - private static List getOffsetLocations(int amount, Location location, double offset){ + private static List getOffsetLocations(int amount, + Location location, double offset) { List locations = new ArrayList(); - for(int i = 0; i < amount; i++) - locations.add(location.clone().add((float) (Math.random()*offset), (float) (Math.random()*offset), (float) (Math.random()*offset))); + for (int i = 0; i < amount; i++) + locations.add(location.clone().add( + (float) (Math.random() * offset), + (float) (Math.random() * offset), + (float) (Math.random() * offset))); return locations; } - public static void remove(Player player){ - if(instances.containsKey(player)) + public static void remove(Player player) { + if (instances.containsKey(player)) instances.get(player).remove(); } - - public void remove(){ + + public void remove() { MultiAbilityManager.unbindMultiAbility(player); - if(player.isOnline()) - GeneralMethods.getBendingPlayer(player.getName()).addCooldown("WaterArms", cooldown); + if (player.isOnline()) + GeneralMethods.getBendingPlayer(player.getName()).addCooldown( + "WaterArms", cooldown); instances.remove(player); } - public void prepareCancel(){ - if(System.currentTimeMillis() < lastClickTime + 500L){ + public void prepareCancel() { + if (System.currentTimeMillis() < lastClickTime + 500L) { remove(); - }else{ + } else { lastClickTime = System.currentTimeMillis(); } } - public static void progressAll(){ + public static void progressAll() { progressRevert(false); - trackEntities(false); - for(Player p : instances.keySet()) + for (Player p : instances.keySet()) instances.get(p).progress(); WaterArmsWhip.progressAll(); + WaterArmsFreeze.progressAll(); + WaterArmsSpear.progressAll(); } - public static void removeAll(){ + public static void removeAll() { progressRevert(true); - trackEntities(true); revert.clear(); - falling.clear(); instances.clear(); WaterArmsWhip.removeAll(); + WaterArmsFreeze.removeAll(); + WaterArmsSpear.removeAll(); } - - + @SuppressWarnings("deprecation") public static boolean isUnbreakable(Block block) { - if (Arrays.asList(unbreakable).contains(block.getTypeId())) return true; + if (Arrays.asList(unbreakable).contains(block.getTypeId())) + return true; return false; } + public static void displayBoundMsg(Player player){ + player.sendMessage(WaterMethods.getWaterColor() + sneakMsg + " " + + GeneralMethods.getBoundAbility(player)); + } + + public void displayBoundMsg(){ + player.sendMessage(WaterMethods.getWaterColor() + sneakMsg + " " + + GeneralMethods.getBoundAbility(player)); + } + /** * Returns the active arm of the player. + * * @return */ - public Arm getActiveArm(){ + public Arm getActiveArm() { return activeArm; } /** * Switches the active arm of a player. */ - public void switchActiveArm(){ - if(activeArm.equals(Arm.Right)) + public void switchActiveArm() { + if (activeArm.equals(Arm.Right)) activeArm = Arm.Left; else activeArm = Arm.Right; @@ -433,25 +507,26 @@ public class WaterArms{ /** * Switches to the most suitable arm for the player. + * * @return */ - public Arm switchPreferredArm(){ + public Arm switchPreferredArm() { switchActiveArm(); - if(activeArm.equals(Arm.Left)){ - if(!displayLeftArm()){ + if (activeArm.equals(Arm.Left)) { + if (!displayLeftArm()) { switchActiveArm(); } } - if(activeArm.equals(Arm.Right)){ - if(!displayRightArm()){ + if (activeArm.equals(Arm.Right)) { + if (!displayRightArm()) { switchActiveArm(); - } + } } return getActiveArm(); } - - public boolean canDisplayCurrentArm(){ - switch(activeArm){ + + public boolean canDisplayActiveArm() { + switch (activeArm) { case Left: return displayLeftArm(); case Right: @@ -460,81 +535,115 @@ public class WaterArms{ return false; } } - - public Player getPlayer(){ + + public Location getActiveArmEnd() { + switch (activeArm) { + case Left: + return getLeftArmEnd(); + case Right: + return getRightArmEnd(); + default: + return null; + } + } + + public static boolean hasPlayer(Player player) { + if (instances.containsKey(player)) { + return true; + } + return false; + } + + public Player getPlayer() { return player; } - - public Boolean isFullSource(){ + + public Boolean isFullSource() { return fullSource; } - - public Integer getLengthReduction(){ + + public boolean getLeftArmConsumed() { + return leftArmConsumed; + } + + public void setLeftArmConsumed(boolean consumed) { + this.leftArmConsumed = consumed; + } + + public boolean getRightArmConsumed() { + return rightArmConsumed; + } + + public void setRightArmConsumed(boolean consumed) { + this.rightArmConsumed = consumed; + } + + public Integer getLengthReduction() { return lengthReduction; } - - public void setLengthReduction(int lengthReduction){ + + public void setLengthReduction(int lengthReduction) { this.lengthReduction = lengthReduction; } - - public Integer getMaxPunches(){ + + public Integer getMaxPunches() { return maxPunches; } - - public void setMaxPunches(int maxPunches){ + + public void setMaxPunches(int maxPunches) { this.maxPunches = maxPunches; } - - public Integer getMaxUses(){ + + public Integer getMaxUses() { return maxUses; } - - public void setMaxUses(int maxUses){ + + public void setMaxUses(int maxUses) { this.maxUses = maxUses; } - - public Integer getMaxIceBlasts(){ + + public Integer getMaxIceBlasts() { return maxIceBlasts; } - - public void setMaxIceBlasts(int maxIceBlasts){ + + public void setMaxIceBlasts(int maxIceBlasts) { this.maxIceBlasts = maxIceBlasts; } - - public boolean canLightningDamage(){ + + public boolean canLightningDamage() { return lightningEnabled; } - - public void setCanLightningDamage(boolean lightningEnabled){ + + public void setCanLightningDamage(boolean lightningEnabled) { this.lightningEnabled = lightningEnabled; } - - public double getLightningDamage(){ + + public double getLightningDamage() { return lightningDamage; } - - public void setLightningDamage(double lightningDamage){ + + public void setLightningDamage(double lightningDamage) { this.lightningDamage = lightningDamage; } - - public boolean isLeftArmCooldown(){ + + public boolean isLeftArmCooldown() { return cooldownLeft; } - - public void setLeftArmCooldown(boolean cooldown){ + + public void setLeftArmCooldown(boolean cooldown) { this.cooldownLeft = cooldown; } - - public boolean isRightArmCooldown(){ + + public boolean isRightArmCooldown() { return cooldownRight; } - - public void setRightArmCooldown(boolean cooldown){ + + public void setRightArmCooldown(boolean cooldown) { this.cooldownRight = cooldown; } - - public void setActiveArmCooldown(boolean cooldown){ - switch(activeArm){ + + public void setActiveArmCooldown(boolean cooldown) { + switch (activeArm) { case Left: setLeftArmCooldown(cooldown); return; @@ -545,7 +654,7 @@ public class WaterArms{ break; } } - + public long getCooldown() { return cooldown; } From ee79f70142f046c25a1b768d9e3e3f6ac3cae092 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:23:06 +0100 Subject: [PATCH 20/25] Finished recode and added getters and setters. Also added Grab attack. --- .../waterbending/WaterArmsWhip.java | 453 ++++++++++-------- 1 file changed, 250 insertions(+), 203 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsWhip.java b/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsWhip.java index 6598db3c..9e293efa 100644 --- a/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsWhip.java +++ b/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsWhip.java @@ -1,6 +1,6 @@ package com.projectkorra.ProjectKorra.waterbending; -import java.util.ArrayList; +import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Location; @@ -10,7 +10,6 @@ import org.bukkit.block.Block; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; -import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -26,7 +25,7 @@ import com.projectkorra.ProjectKorra.earthbending.EarthMethods; import com.projectkorra.ProjectKorra.waterbending.WaterArms.Arm; import com.projectkorra.rpg.WorldEvents; -public class WaterArmsWhip{ +public class WaterArmsWhip { /** * Whip Enum value for deciding what ability should be executed. @@ -38,31 +37,43 @@ public class WaterArmsWhip{ private static FileConfiguration config = ProjectKorra.plugin.getConfig(); public static ConcurrentHashMap instances = new ConcurrentHashMap(); - public static ArrayList grabbedEntities = new ArrayList(); + public static HashMap grabbedEntities = new HashMap(); private Player player; private WaterArms waterArms; - private int whipLength = config.getInt("Abilities.Water.WaterArms.WhipMode.MaxLength"); - private int whipLengthWeak = config.getInt("Abilities.Water.WaterArms.WhipMode.MaxLengthWeak"); + private int whipLength = config + .getInt("Abilities.Water.WaterArms.Whip.MaxLength"); + private int whipLengthWeak = config + .getInt("Abilities.Water.WaterArms.Whip.MaxLengthWeak"); - private int whipLengthNight = config.getInt("Abilities.Water.WaterArms.WhipMode.NightAugments.MaxLength.Normal"); - private int whipLengthFullMoon = config.getInt("Abilities.Water.WaterArms.WhipMode.NightAugments.MaxLength.FullMoon"); + private int whipLengthNight = config + .getInt("Abilities.Water.WaterArms.Whip.NightAugments.MaxLength.Normal"); + private int whipLengthFullMoon = config + .getInt("Abilities.Water.WaterArms.Whip.NightAugments.MaxLength.FullMoon"); - private int initLength = config.getInt("Abilities.Water.WaterArms.Arms.InitialLength"); - private double damage = config.getDouble("Abilities.Water.WaterArms.WhipMode.Punch.PunchDamage"); - private boolean pullBlocks = config.getBoolean("Abilities.Water.WaterArms.WhipMode.Pull.PullBlocks"); - private long pullBlocksRevertDelay = config.getLong("Abilities.Water.WaterArms.WhipMode.Pull.BlockRevertDelay"); - private boolean grappleRespectRegions = config.getBoolean("Abilities.Water.WaterArms.WhipMode.Grapple.RespectRegions"); - private boolean usageCooldownEnabled = config.getBoolean("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldownEnabled"); - private long usageCooldown = config.getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown"); + private int initLength = config + .getInt("Abilities.Water.WaterArms.Arms.InitialLength"); + private double punchDamage = config + .getDouble("Abilities.Water.WaterArms.Whip.Punch.PunchDamage"); + private boolean grappleRespectRegions = config + .getBoolean("Abilities.Water.WaterArms.Whip.Grapple.RespectRegions"); + private long holdTime = config + .getLong("Abilities.Water.WaterArms.Whip.Grab.HoldTime"); + private boolean usageCooldownEnabled = config + .getBoolean("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldownEnabled"); + private long usageCooldown = config + .getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown"); private int activeLength = initLength; private int whipSpeed = 2; private boolean reverting = false; - private boolean damaged = false; + private boolean hasDamaged = false; private boolean grappled = false; private boolean grabbed = false; + private double playerHealth; + private long time; + private LivingEntity grabbedEntity; private Location end; private Arm arm; @@ -71,62 +82,86 @@ public class WaterArmsWhip{ private int id; private static int ID = Integer.MIN_VALUE; - public WaterArmsWhip(Player player, Whip m){ + public WaterArmsWhip(Player player, Whip ability) { + if (instances.containsKey(getId(player))) { + WaterArmsWhip waw = instances.get(getId(player)); + if (waw.grabbed) { + waw.grabbed = false; + if (waw.grabbedEntity != null) { + grabbedEntities.remove(waw.grabbedEntity); + waw.grabbedEntity.setVelocity(waw.grabbedEntity + .getVelocity().multiply(2.5)); + } + return; + } + if (!waw.arm.equals(WaterArms.instances.get(player).getActiveArm())) { + return; + } + } this.player = player; - ability = m; + this.ability = ability; getNightAugments(); createInstance(); } - private void getNightAugments(){ + private void getNightAugments() { World world = player.getWorld(); - if(WaterMethods.isNight(world)){ - if(GeneralMethods.hasRPG()){ - if(BendingManager.events.get(world).equalsIgnoreCase(WorldEvents.LunarEclipse.toString())){ + if (WaterMethods.isNight(world)) { + if (GeneralMethods.hasRPG()) { + if (BendingManager.events.get(world).equalsIgnoreCase( + WorldEvents.LunarEclipse.toString())) { whipLength = whipLengthFullMoon; - }else if (BendingManager.events.get(world).equalsIgnoreCase("FullMoon")){ + } else if (BendingManager.events.get(world).equalsIgnoreCase( + "FullMoon")) { whipLength = whipLengthFullMoon; - }else{ + } else { whipLength = whipLengthNight; } - }else{ - if(WaterMethods.isFullMoon(world)){ + } else { + if (WaterMethods.isFullMoon(world)) { whipLength = whipLengthFullMoon; - }else{ + } else { whipLength = whipLengthNight; } } } } - private void createInstance(){ - if(WaterArms.instances.containsKey(player)){ + private void createInstance() { + if (WaterArms.instances.containsKey(player)) { waterArms = WaterArms.instances.get(player); waterArms.switchPreferredArm(); arm = waterArms.getActiveArm(); - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - if(arm.equals(Arm.Left)){ - if(waterArms.isLeftArmCooldown() || bPlayer.isOnCooldown("WaterArms_LEFT")){ + time = System.currentTimeMillis() + holdTime; + playerHealth = player.getHealth(); + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player + .getName()); + if (arm.equals(Arm.Left)) { + if (waterArms.isLeftArmCooldown() + || bPlayer.isOnCooldown("WaterArms_LEFT")) { return; - }else{ - if(usageCooldownEnabled) + } else { + if (usageCooldownEnabled) { bPlayer.addCooldown("WaterArms_LEFT", usageCooldown); + } waterArms.setLeftArmCooldown(true); } } - if(arm.equals(Arm.Right)){ - if(waterArms.isRightArmCooldown() || bPlayer.isOnCooldown("WaterArms_RIGHT")){ + if (arm.equals(Arm.Right)) { + if (waterArms.isRightArmCooldown() + || bPlayer.isOnCooldown("WaterArms_RIGHT")) { return; - }else{ - if(usageCooldownEnabled) + } else { + if (usageCooldownEnabled) { bPlayer.addCooldown("WaterArms_RIGHT", usageCooldown); + } waterArms.setRightArmCooldown(true); } } - }else{ + } else { return; } - if(!waterArms.isFullSource()){ + if (!waterArms.isFullSource()) { whipLength = whipLengthWeak; } id = ID; @@ -136,116 +171,99 @@ public class WaterArmsWhip{ ID++; } - private void progress(){ - if(!WaterArms.instances.containsKey(player)){ + private void progress() { + if (!WaterArms.instances.containsKey(player)) { remove(); return; } - if(player.isDead() || !player.isOnline()){ + if (player.isDead() || !player.isOnline()) { remove(); return; } - if(!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")){ + if (!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")) { remove(); return; } - if(activeLength < whipLength && !reverting){ - activeLength+=whipSpeed; - }else if(activeLength > initLength){ - if(!grabbed){ - activeLength-=whipSpeed; + if (activeLength < whipLength && !reverting) { + activeLength += whipSpeed; + } else if (activeLength > initLength) { + if (!grabbed) { + activeLength -= whipSpeed; } - }else{ + } else { remove(); return; } - if(activeLength == whipLength && !grabbed){ + if (activeLength == whipLength && !grabbed) { reverting = true; } - if(arm.equals(Arm.Left)){ - useLeftArm(); - }else{ - useRightArm(); + if (grabbed + && (System.currentTimeMillis() > time || playerHealth > player + .getHealth())) { + grabbed = false; + reverting = true; } + + useArm(); dragEntity(end); grapplePlayer(end); } - //START OF RECODE - - private boolean canPlaceBlock(Block block){ - if(!EarthMethods.isTransparentToEarthbending(player, block) && !(WaterMethods.isWater(block) && TempBlock.isTempBlock(block))){ + private boolean canPlaceBlock(Block block) { + if (!EarthMethods.isTransparentToEarthbending(player, block) + && !(WaterMethods.isWater(block) && TempBlock + .isTempBlock(block))) { + return false; + } + if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", + block.getLocation())) { return false; } return true; } - private void useLeftArm(){ - if(waterArms.displayLeftArm()){ - Location l1 = waterArms.getLeftArmEnd().clone(); - Vector dir = player.getLocation().getDirection(); - for(int i = 1; i <= activeLength; i++){ - Location l2 = l1.clone().add(dir.normalize().multiply(i)); - - if(!canPlaceBlock(l2.getBlock())){ - if(!l2.getBlock().getType().equals(Material.BARRIER)){ - grappled = true; - } - reverting = true; - break; - } - - new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, (byte) 0); - WaterArms.revert.put(l2.getBlock(), 0L); - - if(i == activeLength){ - Location l3 = GeneralMethods.getRightSide(l2, 1); - end = l3.clone(); - if(canPlaceBlock(l3.getBlock())){ - new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, (byte) 3); - WaterArms.revert.put(l3.getBlock(), 0L); - checkLocation(l3); - }else{ - if(!l3.getBlock().getType().equals(Material.BARRIER)){ - grappled = true; - } - reverting = true; - } - } + private void useArm() { + if (waterArms.canDisplayActiveArm()) { + Location l1 = null; + if (arm.equals(Arm.Left)) { + l1 = waterArms.getLeftArmEnd().clone(); + } else { + l1 = waterArms.getRightArmEnd().clone(); } - } - } - - private void useRightArm(){ - if(waterArms.displayLeftArm()){ - Location l1 = waterArms.getRightArmEnd().clone(); Vector dir = player.getLocation().getDirection(); - for(int i = 1; i <= activeLength; i++){ + for (int i = 1; i <= activeLength; i++) { Location l2 = l1.clone().add(dir.normalize().multiply(i)); - if(!canPlaceBlock(l2.getBlock())){ - if(!l2.getBlock().getType().equals(Material.BARRIER)){ + if (!canPlaceBlock(l2.getBlock())) { + if (!l2.getBlock().getType().equals(Material.BARRIER)) { grappled = true; } reverting = true; break; } - new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, (byte) 0); + new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, + (byte) 0); WaterArms.revert.put(l2.getBlock(), 0L); - if(i == activeLength){ - Location l3 = GeneralMethods.getLeftSide(l2, 1); + if (i == activeLength) { + Location l3 = null; + if (arm.equals(Arm.Left)) { + l3 = GeneralMethods.getRightSide(l2, 1); + } else { + l3 = GeneralMethods.getLeftSide(l2, 1); + } end = l3.clone(); - if(canPlaceBlock(l3.getBlock())){ - new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, (byte) 3); + if (canPlaceBlock(l3.getBlock())) { + new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, + (byte) 3); WaterArms.revert.put(l3.getBlock(), 0L); - checkLocation(l3); - }else{ - if(!l3.getBlock().getType().equals(Material.BARRIER)){ + performAction(l3); + } else { + if (!l3.getBlock().getType().equals(Material.BARRIER)) { grappled = true; } reverting = true; @@ -255,29 +273,38 @@ public class WaterArmsWhip{ } } - private void checkLocation(Location location){ + private void performAction(Location location) { Location endOfArm = waterArms.getLeftArmEnd().clone(); - switch(ability){ + switch (ability) { case Pull: - for(Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)){ - if(entity instanceof Player && Commands.invincible.contains(((Player) entity).getName())){ + for (Entity entity : GeneralMethods.getEntitiesAroundPoint( + location, 2)) { + if (entity instanceof Player + && Commands.invincible.contains(((Player) entity) + .getName())) { continue; } - Vector vector = endOfArm.toVector().subtract(entity.getLocation().toVector()); + Vector vector = endOfArm.toVector().subtract( + entity.getLocation().toVector()); entity.setVelocity(vector.multiply(0.15)); } break; case Punch: - for(Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)){ - if(entity instanceof Player && Commands.invincible.contains(((Player) entity).getName())){ + for (Entity entity : GeneralMethods.getEntitiesAroundPoint( + location, 2)) { + if (entity instanceof Player + && Commands.invincible.contains(((Player) entity) + .getName())) { continue; } - Vector vector = entity.getLocation().toVector().subtract(endOfArm.toVector()); + Vector vector = entity.getLocation().toVector() + .subtract(endOfArm.toVector()); entity.setVelocity(vector.multiply(0.15)); - if(entity instanceof LivingEntity){ - if(entity.getEntityId() != player.getEntityId()){ - damaged = true; - GeneralMethods.damageEntity(player, entity, damage); + if (entity instanceof LivingEntity) { + if (entity.getEntityId() != player.getEntityId()) { + hasDamaged = true; + GeneralMethods + .damageEntity(player, entity, punchDamage); } } } @@ -286,11 +313,13 @@ public class WaterArmsWhip{ grapplePlayer(end); break; case Grab: - if(grabbedEntity == null){ - for(Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)){ - if(entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId() && !grabbedEntities.contains(entity)){ - System.out.println("Grabbed Entity!"); - grabbedEntities.add((LivingEntity) entity); + if (grabbedEntity == null) { + for (Entity entity : GeneralMethods.getEntitiesAroundPoint( + location, 2)) { + if (entity instanceof LivingEntity + && entity.getEntityId() != player.getEntityId() + && !grabbedEntities.containsKey(entity)) { + grabbedEntities.put((LivingEntity) entity, id); grabbedEntity = (LivingEntity) entity; grabbed = true; reverting = true; @@ -305,9 +334,9 @@ public class WaterArmsWhip{ } } - private void dragEntity(Location location){ - if(grabbedEntity != null){ - if(!waterArms.canDisplayCurrentArm() || grabbedEntity.isDead()){ + private void dragEntity(Location location) { + if (grabbedEntity != null && grabbed) { + if (!waterArms.canDisplayActiveArm() || grabbedEntity.isDead()) { grabbed = false; grabbedEntities.remove(grabbedEntity); return; @@ -330,103 +359,121 @@ public class WaterArmsWhip{ } } } - - private void grapplePlayer(Location location){ - if(reverting && grappled && player != null && end != null && ability.equals(Whip.Grapple)){ - Vector vector = player.getLocation().toVector().subtract(location.toVector()); + + private void grapplePlayer(Location location) { + if (reverting && grappled && player != null && end != null + && ability.equals(Whip.Grapple)) { + if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", + location) && grappleRespectRegions) { + return; + } + Vector vector = player.getLocation().toVector() + .subtract(location.toVector()); player.setVelocity(vector.multiply(-0.25)); player.setFallDistance(0); } } - //END OF RECODE - - @SuppressWarnings("deprecation") - private void spawnFallingBlock(Location location, Location armbase){ - Block block = location.getBlock(); - Material mat = block.getType(); - byte data = block.getData(); - if(!GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", location)){ - Location spawnLoc = location.clone().toVector().subtract(player.getLocation().clone().getDirection().multiply(1)).toLocation(player.getWorld()); - - new TempBlock(block, Material.AIR, (byte) 0); - WaterArms.revert.put(block, System.currentTimeMillis() + pullBlocksRevertDelay); - - if(!WaterArms.isUnbreakable(spawnLoc.getBlock())){ - new TempBlock(spawnLoc.getBlock(), Material.AIR, (byte) 0); - WaterArms.revert.put(spawnLoc.getBlock(), System.currentTimeMillis() + pullBlocksRevertDelay); - }else{ - return; + public static Integer getId(Player player) { + for (int id : instances.keySet()) { + if (instances.get(id).player.equals(player)) { + return id; } + } + return 0; + } - FallingBlock fBlock = player.getWorld().spawnFallingBlock(spawnLoc.clone(), mat, data); - fBlock.setDropItem(false); - Vector from = fBlock.getLocation().toVector(); - Vector to = armbase.clone().toVector(); - Vector vector = to.subtract(from); - fBlock.setVelocity(vector.multiply(0.15)); - WaterArms.falling.put(fBlock, player); + public static void checkValidEntities() { + for (LivingEntity e : grabbedEntities.keySet()) { + if (instances.containsKey(grabbedEntities.get(e))) { + if (instances.get(grabbedEntities.get(e)).grabbedEntity == null) { + grabbedEntities.remove(e); + } + } else { + grabbedEntities.remove(e); + } } } - private boolean canModifyBlock(Block block, Location toLoc){ - if(!EarthMethods.isTransparentToEarthbending(player, block) && !WaterMethods.isWater(block)){ - if(GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", block.getLocation())){ - if(!grappleRespectRegions() && block.getType().isSolid() && !EarthMethods.isTransparentToEarthbending(player, block)) - grappled = true; - reverting = true; - return true; - } - if(EarthMethods.isTransparentToEarthbending(player, block)){ - if(!block.getType().equals(Material.BARRIER)){ - grappled = true; - } - reverting = true; - return true; - } - if(!(TempBlock.isTempBlock(block) && TempBlock.get(block).equals(Material.AIR))){ - if(!block.isLiquid() && block.getType().isSolid() && ability.equals(Whip.Pull) && pullBlocks && player.hasPermission("bending.ability.WaterArms.PullBlocks")){ - if(!EarthMethods.isTransparentToEarthbending(player, block)) - spawnFallingBlock(block.getLocation(), toLoc); - } - grappled = true; - reverting = true; - return true; - } - } - return false; - } - - private boolean grappleRespectRegions(){ - if(!grappleRespectRegions) - if(!ability.equals(Whip.Grapple)) - return true; - else - return false; - else - return true; - } - - private void remove(){ - if(WaterArms.instances.containsKey(player)){ - if(arm.equals(Arm.Left)){ + private void remove() { + if (WaterArms.instances.containsKey(player)) { + if (arm.equals(Arm.Left)) { waterArms.setLeftArmCooldown(false); - }else{ + } else { waterArms.setRightArmCooldown(false); } - if(damaged) + if (hasDamaged) { waterArms.setMaxPunches(waterArms.getMaxPunches() - 1); + } waterArms.setMaxUses(waterArms.getMaxUses() - 1); } instances.remove(id); } - public static void progressAll(){ - for(int ID : instances.keySet()) + public static void progressAll() { + checkValidEntities(); + for (int ID : instances.keySet()) instances.get(ID).progress(); } - public static void removeAll(){ + public static void removeAll() { + grabbedEntities.clear(); instances.clear(); } + + public Player getPlayer() { + return player; + } + + public Integer getWhipLength() { + return whipLength; + } + + public void setArmLength(int armLength) { + this.whipLength = armLength; + } + + public Double getPunchDamage() { + return punchDamage; + } + + public void setPunchDamage(double damage) { + this.punchDamage = damage; + } + + public long getHoldTime() { + return holdTime; + } + + public void setHoldTime(long holdTime) { + this.holdTime = holdTime; + } + + public boolean getReverting() { + return reverting; + } + + public void setReverting(boolean reverting) { + this.reverting = reverting; + } + + public boolean getGrappled() { + return grappled; + } + + public void setGrappled(boolean grappled) { + this.grappled = grappled; + } + + public boolean getGrabbed() { + return grabbed; + } + + public void setGrabbed(boolean grabbed) { + this.grabbed = grabbed; + } + + public LivingEntity getHeldEntity() { + return grabbedEntity; + } } \ No newline at end of file From 5a10da3f1f01c5cd0dd67723eeb46d5c7dd43fc9 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:23:21 +0100 Subject: [PATCH 21/25] Added permissions for WaterArms. --- src/plugin.yml | 389 +++++++++++++++++++++++++------------------------ 1 file changed, 198 insertions(+), 191 deletions(-) diff --git a/src/plugin.yml b/src/plugin.yml index c87ac29f..a5af8dbb 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,192 +1,199 @@ -name: ProjectKorra -author: ProjectKorra -version: 1.7.0 BETA 3 -main: com.projectkorra.ProjectKorra.ProjectKorra -softdepend: [PreciousStones, WorldGuard, WorldEdit, Factions, MassiveCore, GriefPrevention, Towny, NoCheatPlus, LWC] -commands: - projectkorra: - aliases: [b,bending,mtla,tla,korra,pk,bend] - usage: / -permissions: - bending.admin: - default: op - description: Grants access to all commands and abilities. - children: - bending.player: true - bending.command.reload: true - bending.admin.permaremove: true - bending.command.avatar: true - bending.command.add.others: true - bending.command.add: true - bending.command.rechoose: true - bending.admin.choose: true - bending.ability.AvatarState: true - bending.ability.Bloodbending: true - bending.ability.Flight: true - bending.ability.MetalClips.loot: true - bending.ability.MetalClips.4clips: true - bending.command.import: true - bending.command.toggle.all: true - bending.command.give: true - bending.command.invincible: true - bending.admin.debug: true - bending.admin.remove: true - bending.player: - default: true - description: Grants access to most abilities and basic commands. - children: - bending.command.bind: true - bending.command.display: true - bending.command.toggle: true - bending.command.choose: true - bending.command.version: true - bending.command.help: true - bending.command.clear: true - bending.command.who: true - bending.command.preset.list: true - bending.command.preset.create.2: true - bending.command.preset.create: true - bending.command.preset.bind: true - bending.command.preset.delete: true - bending.air: true - bending.water: true - bending.earth: true - bending.fire: true - bending.chi: true - bending.air: - default: true - description: Grants access to all airbending abilities. - children: - bending.command.add.air: true - bending.command.choose.air: true - bending.ability.AirBlast: true - bending.ability.AirBubble: true - bending.ability.AirBurst: true - bending.ability.AirScooter: true - bending.ability.AirShield: true - bending.ability.AirSpout: true - bending.ability.AirSuction: true - bending.ability.AirSwipe: true - bending.ability.Suffocate: true - bending.ability.Tornado: true - bending.ability.AirCombo: true - bending.air.passive: true - bending.air.flight: true - bending.water: - default: true - description: Grants access to most waterbending abilities. - children: - bending.command.add.water: true - bending.command.choose.water: true - bending.ability.HealingWaters: true - bending.ability.IceBlast: true - bending.ability.IceSpike: true - bending.ability.OctopusForm: true - bending.ability.PhaseChange: true - bending.ability.Surge: true - bending.ability.Torrent: true - bending.ability.WaterBubble: true - bending.ability.WaterManipulation: true - bending.ability.WaterSpout: true - bending.ability.WaterSpout.Wave: true - bending.ability.WaterCombo: true - bending.water.plantbending: true - bending.message.nightmessage: true - bending.water.passive: true - bending.water.icebending: true - bending.water.healing: true - bending.earth: - default: true - description: Grants access to all Earthbending abilities. - children: - bending.command.add.earth: true - bending.command.choose.earth: true - bending.ability.Catapult: true - bending.ability.Collapse: true - bending.ability.EarthArmor: true - bending.ability.EarthBlast: true - bending.ability.EarthGrab: true - bending.ability.EarthTunnel: true - bending.ability.RaiseEarth: true - bending.ability.Shockwave: true - bending.ability.Tremorsense: true - bending.ability.Extraction: true - bending.ability.MetalClips: true - bending.ability.MetalClips.loot: false - bending.ability.MetalClips.4clips: false - bending.earth.passive: true - bending.earth.metalbending: true - bending.earth.lavabending: true - bending.earth.sandbending: true - bending.earth.grapplinghook: true - bending.ability.LavaSurge: true - bending.ability.LavaFlow: true - bending.ability.EarthSmash: true - bending.fire: - default: true - description: Grants access to all firebending abilities. - children: - bending.command.add.fire: true - bending.command.choose.fire: true - bending.ability.Blaze: true - bending.ability.FireBlast: true - bending.ability.FireBurst: true - bending.ability.FireJet: true - bending.ability.FireShield: true - bending.ability.HeatControl: true - bending.ability.Illumination: true - bending.ability.Lightning: true - bending.ability.WallOfFire: true - bending.ability.Combustion: true - bending.ability.FireCombo: true - bending.message.daymessage: true - bending.fire.passive: true - bending.fire.lightningbending: true - bending.fire.combustionbending: true - bending.chi: - default: true - description: Grants access to all ChiBlocking abilities. - children: - bending.command.add.chi: true - bending.command.choose.chi: true - bending.ability.HighJump: true - bending.ability.Paralyze: true - bending.ability.RapidPunch: true - bending.ability.Smokescreen: true - bending.ability.WarriorStance: true - bending.ability.AcrobatStance: true - bending.ability.QuickStrike: true - bending.ability.SwiftKick: true - bending.ability.ChiCombo: true - bending.chi.passive: true - bending.chi.grapplinghook: true - bending.avatar: - default: false - description: Grants the Avatar Color. - bending.ability.MetalClips.loot: - default: false - description: Lets a Metalbender loot a player's inventory of its iron. - bending.ability.AirCombo: - default: false - description: Grants access to all AirCombos. - children: - bending.ability.AirSweep: true - bending.ability.AirStream: true - bending.ability.Tornado: true - bending.ability.WaterCombo: - default: false - description: Grants access to all WaterCombos. - children: - bending.ability.IceWave: true - bending.ability.IceBullet: true - bending.ability.IceBulletLeftClick: true - bending.ability.IceBulletRightClick: true - bending.ability.FireCombo: - default: false - description: Grants access to all FireCombos. - children: - bending.ability.FireKick: true - bending.ability.FireSpin: true - bending.ability.JetBlast: true - bending.ability.JetBlaze: true +name: ProjectKorra +author: ProjectKorra +version: 1.7.0 BETA 3 +main: com.projectkorra.ProjectKorra.ProjectKorra +softdepend: [PreciousStones, WorldGuard, WorldEdit, Factions, MassiveCore, GriefPrevention, Towny, NoCheatPlus, LWC] +commands: + projectkorra: + aliases: [b,bending,mtla,tla,korra,pk,bend] + usage: / +permissions: + bending.admin: + default: op + description: Grants access to all commands and abilities. + children: + bending.player: true + bending.command.reload: true + bending.admin.permaremove: true + bending.command.avatar: true + bending.command.add.others: true + bending.command.add: true + bending.command.rechoose: true + bending.admin.choose: true + bending.ability.AvatarState: true + bending.ability.Bloodbending: true + bending.ability.Flight: true + bending.ability.MetalClips.loot: true + bending.ability.MetalClips.4clips: true + bending.ability.WaterArms.Grab: true + bending.ability.WaterArms.Freeze: true + bending.ability.WaterArms.Spear: true + bending.command.import: true + bending.command.toggle.all: true + bending.command.give: true + bending.command.invincible: true + bending.admin.debug: true + bending.admin.remove: true + bending.player: + default: true + description: Grants access to most abilities and basic commands. + children: + bending.command.bind: true + bending.command.display: true + bending.command.toggle: true + bending.command.choose: true + bending.command.version: true + bending.command.help: true + bending.command.clear: true + bending.command.who: true + bending.command.preset.list: true + bending.command.preset.create.2: true + bending.command.preset.create: true + bending.command.preset.bind: true + bending.command.preset.delete: true + bending.air: true + bending.water: true + bending.earth: true + bending.fire: true + bending.chi: true + bending.air: + default: true + description: Grants access to all airbending abilities. + children: + bending.command.add.air: true + bending.command.choose.air: true + bending.ability.AirBlast: true + bending.ability.AirBubble: true + bending.ability.AirBurst: true + bending.ability.AirScooter: true + bending.ability.AirShield: true + bending.ability.AirSpout: true + bending.ability.AirSuction: true + bending.ability.AirSwipe: true + bending.ability.Suffocate: true + bending.ability.Tornado: true + bending.ability.AirCombo: true + bending.air.passive: true + bending.air.flight: true + bending.water: + default: true + description: Grants access to most waterbending abilities. + children: + bending.command.add.water: true + bending.command.choose.water: true + bending.ability.HealingWaters: true + bending.ability.IceBlast: true + bending.ability.IceSpike: true + bending.ability.OctopusForm: true + bending.ability.PhaseChange: true + bending.ability.Surge: true + bending.ability.Torrent: true + bending.ability.WaterBubble: true + bending.ability.WaterManipulation: true + bending.ability.WaterSpout: true + bending.ability.WaterSpout.Wave: true + bending.ability.WaterCombo: true + bending.ability.WaterArms: true + bending.ability.WaterArms.Pull: true + bending.ability.WaterArms.Punch: true + bending.ability.WaterArms.Grapple: true + bending.water.plantbending: true + bending.message.nightmessage: true + bending.water.passive: true + bending.water.icebending: true + bending.water.healing: true + bending.earth: + default: true + description: Grants access to all Earthbending abilities. + children: + bending.command.add.earth: true + bending.command.choose.earth: true + bending.ability.Catapult: true + bending.ability.Collapse: true + bending.ability.EarthArmor: true + bending.ability.EarthBlast: true + bending.ability.EarthGrab: true + bending.ability.EarthTunnel: true + bending.ability.RaiseEarth: true + bending.ability.Shockwave: true + bending.ability.Tremorsense: true + bending.ability.Extraction: true + bending.ability.MetalClips: true + bending.ability.MetalClips.loot: false + bending.ability.MetalClips.4clips: false + bending.earth.passive: true + bending.earth.metalbending: true + bending.earth.lavabending: true + bending.earth.sandbending: true + bending.earth.grapplinghook: true + bending.ability.LavaSurge: true + bending.ability.LavaFlow: true + bending.ability.EarthSmash: true + bending.fire: + default: true + description: Grants access to all firebending abilities. + children: + bending.command.add.fire: true + bending.command.choose.fire: true + bending.ability.Blaze: true + bending.ability.FireBlast: true + bending.ability.FireBurst: true + bending.ability.FireJet: true + bending.ability.FireShield: true + bending.ability.HeatControl: true + bending.ability.Illumination: true + bending.ability.Lightning: true + bending.ability.WallOfFire: true + bending.ability.Combustion: true + bending.ability.FireCombo: true + bending.message.daymessage: true + bending.fire.passive: true + bending.fire.lightningbending: true + bending.fire.combustionbending: true + bending.chi: + default: true + description: Grants access to all ChiBlocking abilities. + children: + bending.command.add.chi: true + bending.command.choose.chi: true + bending.ability.HighJump: true + bending.ability.Paralyze: true + bending.ability.RapidPunch: true + bending.ability.Smokescreen: true + bending.ability.WarriorStance: true + bending.ability.AcrobatStance: true + bending.ability.QuickStrike: true + bending.ability.SwiftKick: true + bending.ability.ChiCombo: true + bending.chi.passive: true + bending.chi.grapplinghook: true + bending.avatar: + default: false + description: Grants the Avatar Color. + bending.ability.MetalClips.loot: + default: false + description: Lets a Metalbender loot a player's inventory of its iron. + bending.ability.AirCombo: + default: false + description: Grants access to all AirCombos. + children: + bending.ability.AirSweep: true + bending.ability.AirStream: true + bending.ability.Tornado: true + bending.ability.WaterCombo: + default: false + description: Grants access to all WaterCombos. + children: + bending.ability.IceWave: true + bending.ability.IceBullet: true + bending.ability.IceBulletLeftClick: true + bending.ability.IceBulletRightClick: true + bending.ability.FireCombo: + default: false + description: Grants access to all FireCombos. + children: + bending.ability.FireKick: true + bending.ability.FireSpin: true + bending.ability.JetBlast: true + bending.ability.JetBlaze: true bending.ability.FireWheel: true \ No newline at end of file From 633aca108ed21f934a3766d1895eb140164ae325 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:23:35 +0100 Subject: [PATCH 22/25] Added WaterArms Freeze attack. --- .../waterbending/WaterArmsFreeze.java | 209 ++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 src/com/projectkorra/ProjectKorra/waterbending/WaterArmsFreeze.java diff --git a/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsFreeze.java b/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsFreeze.java new file mode 100644 index 00000000..562d5345 --- /dev/null +++ b/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsFreeze.java @@ -0,0 +1,209 @@ +package com.projectkorra.ProjectKorra.waterbending; + +import java.util.concurrent.ConcurrentHashMap; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +import com.projectkorra.ProjectKorra.BendingPlayer; +import com.projectkorra.ProjectKorra.GeneralMethods; +import com.projectkorra.ProjectKorra.ProjectKorra; +import com.projectkorra.ProjectKorra.TempBlock; +import com.projectkorra.ProjectKorra.TempPotionEffect; +import com.projectkorra.ProjectKorra.Utilities.ParticleEffect; +import com.projectkorra.ProjectKorra.earthbending.EarthMethods; +import com.projectkorra.ProjectKorra.waterbending.WaterArms.Arm; + +public class WaterArmsFreeze { + + private static FileConfiguration config = ProjectKorra.plugin.getConfig(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap(); + + private Player player; + private WaterArms waterArms; + + private int iceRange = config + .getInt("Abilities.Water.WaterArms.Freeze.Range"); + private double iceDamage = config + .getInt("Abilities.Water.WaterArms.Freeze.Damage"); + + private boolean usageCooldownEnabled = config + .getBoolean("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldownEnabled"); + private long usageCooldown = config + .getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown"); + + private Location location; + private Vector direction; + private int distanceTravelled; + private Arm arm; + private boolean cancelled; + + private int id; + private static int ID = Integer.MIN_VALUE; + + public WaterArmsFreeze(Player player) { + this.player = player; + direction = player.getEyeLocation().getDirection(); + createInstance(); + } + + private void createInstance() { + if (WaterArms.instances.containsKey(player)) { + waterArms = WaterArms.instances.get(player); + waterArms.switchPreferredArm(); + arm = waterArms.getActiveArm(); + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player + .getName()); + if (arm.equals(Arm.Left)) { + if (waterArms.isLeftArmCooldown() + || bPlayer.isOnCooldown("WaterArms_LEFT")) { + return; + } else { + if (usageCooldownEnabled) { + bPlayer.addCooldown("WaterArms_LEFT", usageCooldown); + } + waterArms.setLeftArmCooldown(true); + } + } + if (arm.equals(Arm.Right)) { + if (waterArms.isRightArmCooldown() + || bPlayer.isOnCooldown("WaterArms_RIGHT")) { + return; + } else { + if (usageCooldownEnabled) { + bPlayer.addCooldown("WaterArms_RIGHT", usageCooldown); + } + waterArms.setRightArmCooldown(true); + } + } + Vector dir = player.getLocation().getDirection(); + location = waterArms.getActiveArmEnd().add( + dir.normalize().multiply(1)); + direction = GeneralMethods.getDirection( + location, + GeneralMethods.getTargetedLocation(player, iceRange, + new Integer[] { 8, 9, 79, 174 })).normalize(); + } else { + return; + } + id = ID; + instances.put(id, this); + if (ID == Integer.MAX_VALUE) + ID = Integer.MIN_VALUE; + ID++; + } + + private void progress() { + if (player.isDead() || !player.isOnline()) { + remove(); + return; + } + if (distanceTravelled > iceRange) { + remove(); + return; + } + if (distanceTravelled >= 5 && !cancelled) { + cancelled = true; + if (WaterArms.instances.containsKey(player)) { + if (arm.equals(Arm.Left)) { + waterArms.setLeftArmCooldown(false); + } else { + waterArms.setRightArmCooldown(false); + } + waterArms.setMaxIceBlasts(waterArms.getMaxIceBlasts() - 1); + } + } + if (!canPlaceBlock(location.getBlock())) { + remove(); + return; + } + progressIce(); + } + + private boolean canPlaceBlock(Block block) { + if (!EarthMethods.isTransparentToEarthbending(player, block) + && !((WaterMethods.isWater(block) || WaterMethods + .isIcebendable(block)) && TempBlock.isTempBlock(block))) { + return false; + } + if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", + block.getLocation())) { + return false; + } + return true; + } + + private void progressIce() { + ParticleEffect.SNOW_SHOVEL.display(location, (float) Math.random(), + (float) Math.random(), (float) Math.random(), (float) 0.05, 5); + new TempBlock(location.getBlock(), Material.ICE, (byte) 0); + WaterArms.revert.put(location.getBlock(), + System.currentTimeMillis() + 10L); + + for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, + 2.5)) { + if (entity instanceof LivingEntity + && entity.getEntityId() != player.getEntityId() + && !(entity instanceof ArmorStand)) { + GeneralMethods.damageEntity(player, entity, iceDamage); + PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, + 40, 2); + new TempPotionEffect((LivingEntity) entity, effect); + remove(); + return; + } + } + + for (int i = 0; i < 2; i++) { + location = location.add(direction.clone().multiply(1)); + if (!canPlaceBlock(location.getBlock())) + return; + distanceTravelled++; + } + } + + private void remove() { + if (WaterArms.instances.containsKey(player)) { + if (!cancelled) { + if (arm.equals(Arm.Left)) { + waterArms.setLeftArmCooldown(false); + } else { + waterArms.setRightArmCooldown(false); + } + waterArms.setMaxIceBlasts(waterArms.getMaxIceBlasts() - 1); + } + } + instances.remove(id); + } + + public static void progressAll() { + for (int ID : instances.keySet()) + instances.get(ID).progress(); + } + + public static void removeAll() { + instances.clear(); + } + + public Player getPlayer() { + return player; + } + + public boolean getCancelled() { + return cancelled; + } + + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } +} \ No newline at end of file From 3143334c7970dc0c322e7ae9919952a02955ac01 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:23:47 +0100 Subject: [PATCH 23/25] Added WaterArms Spear attack. --- .../waterbending/WaterArmsSpear.java | 321 ++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 src/com/projectkorra/ProjectKorra/waterbending/WaterArmsSpear.java diff --git a/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsSpear.java b/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsSpear.java new file mode 100644 index 00000000..66874f7a --- /dev/null +++ b/src/com/projectkorra/ProjectKorra/waterbending/WaterArmsSpear.java @@ -0,0 +1,321 @@ +package com.projectkorra.ProjectKorra.waterbending; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import com.projectkorra.ProjectKorra.BendingManager; +import com.projectkorra.ProjectKorra.BendingPlayer; +import com.projectkorra.ProjectKorra.GeneralMethods; +import com.projectkorra.ProjectKorra.ProjectKorra; +import com.projectkorra.ProjectKorra.TempBlock; +import com.projectkorra.ProjectKorra.earthbending.EarthMethods; +import com.projectkorra.ProjectKorra.waterbending.WaterArms.Arm; +import com.projectkorra.rpg.WorldEvents; + +public class WaterArmsSpear { + + private static FileConfiguration config = ProjectKorra.plugin.getConfig(); + + public static ConcurrentHashMap instances = new ConcurrentHashMap(); + + private Player player; + private WaterArms waterArms; + + private List spearLocations = new ArrayList<>(); + + private int spearRange = config + .getInt("Abilities.Water.WaterArms.Spear.Range"); + private double spearDamage = config + .getDouble("Abilities.Water.WaterArms.Spear.Damage"); + private boolean spearDamageEnabled = config + .getBoolean("Abilities.Water.WaterArms.Spear.DamageEnabled"); + private int spearSphere = config + .getInt("Abilities.Water.WaterArms.Spear.Sphere"); + private long spearDuration = config + .getLong("Abilities.Water.WaterArms.Spear.Duration"); + private int spearLength = config + .getInt("Abilities.Water.WaterArms.Spear.Length"); + + private int spearRangeNight = config + .getInt("Abilities.Water.WaterArms.Spear.NightAugments.Range.Normal"); + private int spearRangeFullMoon = config + .getInt("Abilities.Water.WaterArms.Spear.NightAugments.Range.FullMoon"); + private int spearSphereNight = config + .getInt("Abilities.Water.WaterArms.Spear.NightAugments.Sphere.Normal"); + private int spearSphereFullMoon = config + .getInt("Abilities.Water.WaterArms.Spear.NightAugments.Sphere.FullMoon"); + private long spearDurationNight = config + .getLong("Abilities.Water.WaterArms.Spear.NightAugments.Duration.Normal"); + private long spearDurationFullMoon = config + .getLong("Abilities.Water.WaterArms.Spear.NightAugments.Duration.FullMoon"); + + private boolean usageCooldownEnabled = config + .getBoolean("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldownEnabled"); + private long usageCooldown = config + .getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown"); + + private Location location; + private Location initLocation; + private int distanceTravelled; + private Arm arm; + private int layer; + private boolean hitEntity; + private boolean canFreeze; + + private int id; + private static int ID = Integer.MIN_VALUE; + + Random rand = new Random(); + + public WaterArmsSpear(Player player, boolean freeze) { + this.player = player; + this.canFreeze = freeze; + getNightAugments(); + createInstance(); + } + + private void getNightAugments() { + World world = player.getWorld(); + if (WaterMethods.isNight(world)) { + if (GeneralMethods.hasRPG()) { + if (BendingManager.events.get(world).equalsIgnoreCase( + WorldEvents.LunarEclipse.toString())) { + spearRange = spearRangeFullMoon; + spearSphere = spearSphereFullMoon; + spearDuration = spearDurationFullMoon; + } else if (BendingManager.events.get(world).equalsIgnoreCase( + "FullMoon")) { + spearRange = spearRangeFullMoon; + spearSphere = spearSphereFullMoon; + spearDuration = spearDurationFullMoon; + } else { + spearRange = spearRangeNight; + spearSphere = spearSphereNight; + spearDuration = spearDurationNight; + } + } else { + if (WaterMethods.isFullMoon(world)) { + spearRange = spearRangeFullMoon; + spearSphere = spearSphereFullMoon; + spearDuration = spearDurationFullMoon; + } else { + spearRange = spearRangeNight; + spearSphere = spearSphereNight; + spearDuration = spearDurationNight; + } + } + } + } + + private void createInstance() { + if (WaterArms.instances.containsKey(player)) { + waterArms = WaterArms.instances.get(player); + waterArms.switchPreferredArm(); + arm = waterArms.getActiveArm(); + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player + .getName()); + if (arm.equals(Arm.Left)) { + if (waterArms.isLeftArmCooldown() + || bPlayer.isOnCooldown("WaterArms_LEFT") + || !waterArms.displayLeftArm()) { + return; + } else { + if (usageCooldownEnabled) { + bPlayer.addCooldown("WaterArms_LEFT", usageCooldown); + } + waterArms.setLeftArmConsumed(true); + waterArms.setLeftArmCooldown(true); + } + } + if (arm.equals(Arm.Right)) { + if (waterArms.isRightArmCooldown() + || bPlayer.isOnCooldown("WaterArms_RIGHT") + || !waterArms.displayRightArm()) { + return; + } else { + if (usageCooldownEnabled) { + bPlayer.addCooldown("WaterArms_RIGHT", usageCooldown); + } + waterArms.setRightArmConsumed(true); + waterArms.setRightArmCooldown(true); + } + } + Vector dir = player.getLocation().getDirection(); + location = waterArms.getActiveArmEnd().add( + dir.normalize().multiply(1)); + initLocation = location.clone(); + } else { + return; + } + id = ID; + instances.put(id, this); + if (ID == Integer.MAX_VALUE) + ID = Integer.MIN_VALUE; + ID++; + } + + private void progress() { + if (player.isDead() || !player.isOnline()) { + remove(); + return; + } + if (distanceTravelled > spearRange) { + remove(); + return; + } + if (!hitEntity) { + progressSpear(); + } else { + createIceBall(); + } + if (layer >= spearSphere) { + remove(); + return; + } + if (!canPlaceBlock(location.getBlock())) { + if (canFreeze) { + createSpear(); + } + remove(); + return; + } + } + + private void progressSpear() { + for (int i = 0; i < 2; i++) { + for (Entity entity : GeneralMethods.getEntitiesAroundPoint( + location, 2)) { + if (entity instanceof LivingEntity + && entity.getEntityId() != player.getEntityId() + && !(entity instanceof ArmorStand)) { + hitEntity = true; + location = entity.getLocation(); + + if (spearDamageEnabled) { + GeneralMethods + .damageEntity(player, entity, spearDamage); + } + + return; + } + } + new TempBlock(location.getBlock(), Material.STATIONARY_WATER, + (byte) 0); + WaterArms.revert.put(location.getBlock(), + System.currentTimeMillis() + 600L); + Vector direction = GeneralMethods.getDirection( + initLocation, + GeneralMethods.getTargetedLocation(player, spearRange, + new Integer[] { 8, 9, 79, 174 })).normalize(); + location = location.add(direction.clone().multiply(1)); + spearLocations.add(location.clone()); + if (!canPlaceBlock(location.getBlock())) { + return; + } + distanceTravelled++; + } + } + + private void createSpear() { + for (int i = spearLocations.size() - spearLength; i < spearLocations + .size(); i++) { + if (i >= 0) { + Block block = spearLocations.get(i).getBlock(); + if (canPlaceBlock(block)) { + WaterMethods.playIcebendingSound(block.getLocation()); + if (WaterArms.revert.containsKey(block)) { + WaterArms.revert.remove(block); + } + new TempBlock(block, Material.ICE, (byte) 0); + WaterArms.revert.put(block, System.currentTimeMillis() + + spearDuration + (long) (Math.random() * 500)); + } + } + } + } + + private void createIceBall() { + layer++; + for (Block block : GeneralMethods.getBlocksAroundPoint(location, layer)) { + if (EarthMethods.isTransparentToEarthbending(player, block) + && block.getType() != Material.ICE + && !WaterArms.isUnbreakable(block)) { + WaterMethods.playIcebendingSound(block.getLocation()); + new TempBlock(block, Material.ICE, (byte) 0); + WaterArms.revert.put(block, System.currentTimeMillis() + + spearDuration + (long) (Math.random() * 500)); + } + } + } + + private boolean canPlaceBlock(Block block) { + if (!EarthMethods.isTransparentToEarthbending(player, block) + && !((WaterMethods.isWater(block) || WaterMethods + .isIcebendable(block)) && (TempBlock.isTempBlock(block) && !WaterArms.revert + .containsKey(block)))) { + return false; + } + if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", + block.getLocation())) { + return false; + } + if (WaterArms.isUnbreakable(block) && !WaterMethods.isWater(block)) { + return false; + } + return true; + } + + private void remove() { + if (WaterArms.instances.containsKey(player)) { + if (arm.equals(Arm.Left)) { + waterArms.setLeftArmCooldown(false); + } else { + waterArms.setRightArmCooldown(false); + } + waterArms.setMaxUses(waterArms.getMaxUses() - 1); + } + instances.remove(id); + } + + public static void progressAll() { + for (int ID : instances.keySet()) + instances.get(ID).progress(); + } + + public static void removeAll() { + instances.clear(); + } + + public Player getPlayer() { + return player; + } + + public boolean getCanFreeze() { + return canFreeze; + } + + public void setCanFreeze(boolean freeze) { + this.canFreeze = freeze; + } + + public boolean getHasHitEntity() { + return hitEntity; + } + + public void setHitEntity(boolean hit) { + this.hitEntity = hit; + } +} \ No newline at end of file From 27f505c4d291b26252d5cb2bdbed25bdd2028819 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:26:32 +0100 Subject: [PATCH 24/25] Corrected spelling in WaterArms description. --- src/com/projectkorra/ProjectKorra/ConfigManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/projectkorra/ProjectKorra/ConfigManager.java b/src/com/projectkorra/ProjectKorra/ConfigManager.java index 4bba285a..e1e3e214 100644 --- a/src/com/projectkorra/ProjectKorra/ConfigManager.java +++ b/src/com/projectkorra/ProjectKorra/ConfigManager.java @@ -366,7 +366,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.Plantbending.RegrowTime", 180000); config.addDefault("Abilities.Water.WaterArms.Enabled", true); - config.addDefault("Abilities.Water.WaterArms.Description", "One of the most diverse moves in a waterbenders arsenal, this move creates tendrils " + config.addDefault("Abilities.Water.WaterArms.Description", "One of the most diverse moves in a Waterbender's arsenal, this move creates tendrils " + "of water from the players arms to emulate their actual arms. Each water arms mode will be binded to a slot, switch slots to change mode. " + "To deactive the arms, hold Sneak and Double Left-Click." + "\nPull - Use your Arms to pull blocks, items, mobs or even players towards you!" From 22e5158aa7771ce0104ac1ad7fc500737022d2e3 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 31 May 2015 21:26:49 +0100 Subject: [PATCH 25/25] Added WaterArms config options. --- src/config.yml | 1284 +++++++++++++++++++++++++----------------------- 1 file changed, 672 insertions(+), 612 deletions(-) diff --git a/src/config.yml b/src/config.yml index 0f2b15a4..b261cebb 100644 --- a/src/config.yml +++ b/src/config.yml @@ -1,613 +1,673 @@ -Properties: - ImportEnabled: true - GlobalCooldown: 500 - SeaLevel: 62 - CustomItems: - GrapplingHook: - Enable: true - IronUses: 25 - GoldUses: 50 - Chat: - Format: ": " - Enable: true - Prefixes: - Air: "[Airbender]" - Water: "[Waterbender]" - Earth: "[Earthbender]" - Fire: "[Firebender]" - Chi: "[Chiblocker]" - Avatar: "[Avatar]" - Colors: - Avatar: DARK_PURPLE - Air: GRAY - Fire: RED - Water: AQUA - Earth: GREEN - Metalbending: DARK_GREEN - Chi: GOLD - RegionProtection: - AllowHarmlessAbilities: true - RespectWorldGuard: true - RespectGriefPrevention: true - RespectFactions: true - RespectTowny: true - RespectPreciousStones: true - RespectLWC: true - CacheBlockTime: 5000 - Air: - CanBendWithWeapons: false - Particles: smoke - PlaySound: true - Water: - CanBendWithWeapons: false - NightFactor: 1.5 - FullMoonFactor: 3.0 - CanBendPackedIce: true - PlaySound: true - Earth: - RevertEarthbending: true - SafeRevert: true - RevertCheckTime: 300000 - CanBendWithWeapons: true - EarthbendableBlocks: - - STONE - - COAL_ORE - - DIAMOND_ORE - - DIRT - - GOLD_ORE - - GRASS - - GRAVEL - - IRON_ORE - - LAPIS_ORE - - NETHERRACK - - REDSTONE_ORE - - SAND - - SANDSTONE - - MYCEL - MetalBlocks: - - IRON_BLOCK - - GOLD_BLOCK - - QUARTZ_BLOCK - MetalPowerFactor: 1.5 - PlaySound: true - Fire: - CanBendWithWeapons: true - DayFactor: 1.5 - PlaySound: true - Chi: - CanBendWithWeapons: false - DisabledWorlds: - - TestWorld - - TestWorld2 -Abilities: - AvatarState: - Enabled: true - Description: "The signature ability of the Avatar, this is a toggle. Click to activate to become nearly unstoppable. While in the Avatar State, the user takes severely reduced damage from all sources, regenreates health rapidly, and is granted extreme speed. Nearly all abilities are incredibly amplified in this state. Additionally, AirShield and FireJet become toggle-able abilities and last until you deactivate them or the Avatar State. Click again with the Avatar State selected to deactivate it." - Cooldown: 720000 - Duration: 480000 - PowerMultiplier: 5 - PotionEffects: - Regeneration: - Enabled: true - Power: 3 - Speed: - Enabled: true - Power: 3 - DamageResistance: - Enabled: true - Power: 3 - FireResistance: - Enabled: true - Power: 3 - Air: - Passive: - Factor: 0.3 - Speed: 2 - Jump: 3 - AirBlast: - Enabled: true - Description: "AirBlast is the most fundamental bending technique of an airbender. To use, simply left-click in a direction. A gust of wind will be created at your fingertips, launching anything in its path harmlessly back. A gust of air can extinguish fires on the ground or on a player, can cool lava, and can flip levers and activate buttons. Additionally, tapping sneak will change the original of your next AirBlast to your targeted location." - Speed: 25 - Range: 20 - Radius: 2 - Push: 3.5 - AirBubble: - Enabled: true - Description: "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability." - Radius: 7 - AirBurst: - Enabled: true - Description: "AirBurst is one of the most powerful abilities in an airbender's arsenal. To use, press and hold sneak to charge your burst. Once charged, you can either release sneak to launch a cone-shaped burst of air in front of you, or click to release theb urst in a sphere around you. Additionally, having this ability selected when you land on the ground from a large enough fall will create a burst of air around you." - FallThreshold: 10 - PushFactor: 1.5 - ChargeTime: 1750 - Damage: 0 - AirScooter: - Enabled: true - Description: "AirScooter is a fast means of transportation. To use, sprint, jump then click with this ability selected. YOu will hop on a scooter of air and be propelled forward in the direction you're looking (you don't need to press anything). This ability can be used to levitate above liquids, but it cannot go up steep slopes. Any other actions will deactivate this ability." - Speed: 0.675 - AirShield: - Enabled: true - Description: "Air Shield is one of the most powerful defensive techniques in existence. To use, simply sneak (default: shift). This will create a whirlwind of air around the user, with a small pocket of safe space in the center. This wind will deflect all projectiles and will prevent any creature from entering it for as long as its maintained." - Radius: 7 - IsAvatarStateToggle: true - AirSpout: - Enabled: true - Description: "This ability gives the airbender limited sustained levitation. It is a toggle - click to activate and form a whirling spout of air beneath you, lifting you up. You can bend other abilities while using AirSpout. Click again to deactivate this ability." - Height: 20 - AirSuction: - Enabled: true - Description: "To use, simply left-click in a direction. A gust of wind will originate as far as it can in that direction and flow towards you, sucking anything in its path harmlessly with it. Skilled benders can use this technique to pull items from precarious locations. Additionally, tapping sneak will change the origin of your next AirSuction to your targeted location." - Speed: 25 - Range: 20 - Radius: 2 - Push: 3.5 - AirSwipe: - Enabled: true - Description: "To use, simply left-click in a direction. An arc of air will flow from you towards that direction, cutting and pushing back anything in its path. Its damage is minimal, but it still sends the message. This ability will extinguish fires, cool lava, and cut things like grass, mushrooms, and flowers. Additionally, you can charge it by holding sneak. Charging before attacking will increase damage and knockback, up to a maximum." - Damage: 2 - Range: 16 - Radius: 2 - Push: 1 - Arc: 20 - Speed: 25 - Cooldown: 1500 - ChargeFactor: 3 - MaxChargeTime: 3000 - Flight: - Enabled: true - Description: "Jump in the air, crouch (default: shift) and hold with this ability bound and you will glide around in the direction you look. While flying, click to Hover. Click again to disable Hovering." - HoverEnabled: true - Suffocate: - Enabled: true - Description: "This ability is one of the most dangerous abilities an Airbender possesses. To use, simply look at an entity and hold shift. The entity will begin taking damage as you extract the air from their lungs. Any bender caught in this sphere will only be able to use basic moves, such as AirSwipe, WaterManipulation, FireBlast, or EarthBlast. An entity can be knocked out of the sphere by certain bending arts, and your attention will be disrupted if you are hit by bending." - Range: 15 - Damage: 2 - ChargeTime: 1000 - Cooldown: 0 - DamageInitialDelay: 2 - DamageInterval: 1 - SlowPotency: 1 - SlowDelay: 0.5 - SlowInterval: 1.25 - BlindPotentcy: 30 - BlindDelay: 2 - BlindInterval: 1.5 - CanBeUsedOnUndeadMobs: true - RequireConstantAim: true - RequireConstantAimRadius: 5 - AnimationRadius: 2.0 - AnimationParticleAmount: 2 - AnimationSpeed: 1.0 - 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." - Radius: 10 - Height: 25 - Range: 25 - MobPushFactor: 1 - PlayerPushFactor: 1 - AirCombo: - Enabled: true - Twister: - Speed: 0.35 - Range: 16 - Height: 8 - Radius: 3.5 - RemoveDelay: 1500 - Cooldown: 10000 - DegreesPerParticle: 9 - HeightPerParticle: 2.0 - AirStream: - Speed: 0.5 - Range: 40 - EntityDuration: 4000 - EntityHeight: 14 - Cooldown: 6000 - AirSweep: - Speed: 1.4 - Range: 14 - Damage: 4 - Knockback: 3.5 - Cooldown: 5000 - Water: - Passive: - SwimSpeedFactor: 0.7 - Bloodbending: - Enabled: true - Description: "This ability was made illegal for a reason. With this ability selected, sneak while targeting something and you will bloodbend that target. Bloodbent targets cannot move, bend, or attack. You are free to control their actions by looking elsewhere - they will be forced to move in that direction. Additionally, clicking while bloodbending will launch that target off in the direction you're looking. People who are capable of bloodbending are immune to technique, and you are immune to theirs." - CanOnlyBeUsedAtNight: false - CanBeUsedOnUndeadMobs: true - CanOnlyBeUsedDuringFullMoon: false - ThrowFactor: 2 - Range: 10 - HoldTime: 2000 - Cooldown: 4000 - HealingWaters: - Enabled: true - Description: "To use, the bender must be at least partially submerged in water. If the user is not sneaking, this ability will automatically begin working provided the user has it selected. If the user is sneaking, he/she is channeling the healing to their target in front of them. In order for this channel to be successful, the user and the target must be at least partially submerged in water." - Radius: 5 - Interval: 750 - Power: 1 - IceBlast: - Enabled: true - Damage: 3 - Range: 20 - Description: "This ability offers a powerful ice utility for Waterbenders. It can be used to fire an explosive burst of ice at an opponent, spraying ice and snow around it. To use, simply tap sneak (Default: Shift) while targeting a block of ice to select it as a source. From there, you can just left click to send the blast off at your opponent." - IceSpike: - Enabled: true - Description: "This ability has many functions. Clicking while targetting ice, or an entity over some ice, will raise a spike of ice up, damaging and slowing the target. Tapping sneak (default: shift) while selecting a water source will select that source that can be fired with a click. Firing this will launch a spike of ice at your target, dealing a bit of damage and slowing the target. If you sneak (shift) will not selecting a source, many ice spikes will erupt from around you, damaging and slowing those targets." - Cooldown: 2000 - Damage: 2 - Range: 20 - ThrowingMult: 0.7 - Height: 6 - Projectile: - Range: 20 - Damage: 1 - OctopusForm: - Enabled: true - Description: "This ability allows the waterbender to manipulate a large quantity of water into a form resembling that of an octopus. To use, click to select a water source. Then, hold sneak to channel this ability. While channleing, the water will form itself around you and has a chance to block incoming attacks. Additionally, you can click while channeling to attack things near you, dealing damage and knocking the target back. Releasing shift at any time will dissipate the form." - Range: 10 - AttackRange: 2.5 - Damage: 3 - Radius: 3 - FormDelay: 50 - Knockback: 1.75 - PhaseChange: - Enabled: true - Description: "To use, simply left-click. Any water you are looking at within range will instantly freeze over into solid ice. Provided you stay within range of the ice and do not unbind FreezeMelt, that ice will not thaw. If, however, you do either of those things the ice will instantly thaw. If you sneak (default: shift), anything around where you are looking at will instantly melt. Since this is a more favorable state for these things, they will never re-freeze unless they would otherwise by nature or some other bending ability. Additionally, if you tap sneak while targeting water with FreezeMelt, it will evaporate water around that block that is above sea level." - Range: 20 - Radius: 5 - Plantbending: - RegrowTime: 180000 - Surge: - Enabled: true - Description: "This ability has two distinct features. If you sneak to select a source block, you can then click in a direction and a large wave will be launched in that direction. If you sneak again while the wave is en route, the wave will freeze the next target it hits. If, instead, you click to select a source block, you can hold sneak to form a wall of water at your cursor location. Click to shift between a water wall and an ice wall. Release sneak to dissipate it." - Wave: - Radius: 3 - HorizontalPush: 1 - VerticalPush: 0.2 - Range: 20 - Wall: - Range: 5 - Radius: 2 - VerticalPush: 0.2 - Torrent: - Enabled: true - Description: "Torrent is one of the strongest moves in a waterbender's arsenal. To use, first click a source block to select it; then hold shift to begin streaming the water around you. Water flowing around you this way will damage and knock back nearby enemies and projectiles. If you release shift during this, you will create a large wave that expands outwards from you, launching anything in its path back. Instead, if you click you release the water and channel it to flow towards your cursor. Anything caught in the blast will be tossed about violently and take damage. Finally, if you click again when the water is torrenting, it will freeze the area around it when it is obstructed." - Damage: 2 - DeflectDamage: 1 - Range: 25 - Wave: - Radius: 15 - Knockback: 1.5 - Height: 1 - WaterBubble: - Enabled: true - Description: "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability." - Radius: 7 - WaterManipulation: - Enabled: true - Description: "To use, place your cursor over a waterbendable object and tap sneak (default: shift). Smoke will appear where you've selected, indicating the origin of your ability. After you have selected an origin, simply left-click in any direction and you will see your water spout off in that direction, slicing any creature in its path. If you look towards a creature when you use this ability, it will target that creature. A collision from Water Manipulation both knocks the target back and deals some damage. Alternatively, if you have the source selected and tap shift again, you will be able to control the water more directly." - Damage: 3.0 - Range: 20 - Speed: 35 - Push: .3 - Cooldown: 1000 - WaterSpout: - Enabled: true - Description: "This ability provides a Waterbender with a new means of transportation. To use, simply left click while in or over water to spout water up beneath you, experiencing controlled levitation. Left clicking again while the spout is active will cause it to disappear. Alternatively, tapping a Waterbendable block while not in Water will select a water block as a source, from there, you can tap sneak (Default:Shift) to channel the Water around you. Releasing the sneak will create a wave allowing you a quick burst of controlled transportation. While riding the wave you may press sneak to cause the wave to disappear." - Height: 20 - Wave: - Enabled: true - Range: 6 - ChargeTime: 1000 - FlightTime: 2000 - Speed: 1.2 - WaterCombo: - Enabled: true - IceWave: - Damage: 3 - Cooldown: 6000 - IceBullet: - Damage: 1.5 - Radius: 2.5 - Range: 12 - MaxShots: 30 - AnimationSpeed: 1 - ShootTime: 5000 - Cooldown: 10000 - Earth: - Passive: - Duration: 2500 - Catapult: - Enabled: true - Description: "To use, left-click while looking in the direction you want to be launched. A pillar of earth will jut up from under you and launch you in that direction - if and only if there is enough earth behind where you're looking to launch you. Skillful use of this ability takes much time and work, and it does result in the death of certain gung-ho earthbenders. if you plan to use this ability, be sure you've read about your passive ability you innately have as an earthbender." - Length: 7 - Speed: 12 - Push: 5 - Collapse: - Enabled: true - Description: "To use, simply left-click an earthbendable block. That block and the earthbendable blocks above it will be shoved back into the earth below, if they can. This ability does have the capacity to trap something inside of it, although it is incredibly difficult to do so. Additionally, press sneak with this ability to affect an area around your targeted location - all earth that can be moved downwards will be moved downwards. This ability is especially risky or deadly in caves, depending on the earthbender's goal and technique." - Range: 20 - Radius: 7 - Speed: 8 - EarthArmor: - Enabled: true - Description: "This ability encases the earthbender in temporary armor. To use, click on a block that is earthbendable. If there is another block under it that is earthbendable, the block will fly to you and grant you temporary armor and damage reduction. This ability has a long cooldown." - Duration: 10000 - Strength: 2 - Cooldown: 17500 - EarthBlast: - Enabled: true - Description: "To use, place your cursor over an earthbendable object and tap sneak (default: shift). The object will temporarily turn to stone, indicating that you have it focused as the source for your ability. After you have selected an origin (you no longer need to be sneaking), simply left-click in any direction and you will see your object launch off in that direction, smashing into any creature in its path. If you look towards a creature when you use this ability, it will target that creature. A collision from Earth Blast both knocks the target back and deals some damage. You cannot have multiple of these abilities flying at the same time." - CanHitSelf: false - PrepareRange: 7 - Range: 20 - Speed: 35 - Revert: true - Damage: 4 - Push: 0.3 - EarthGrab: - Enabled: true - Description: "To use, simply left-click while targeting a creature within range. This ability will erect a circle of earth to trap the creature in." - Range: 15 - EarthTunnel: - Enabled: true - Description: "Earth Tunnel is a completely utility ability for earthbenders. To use, simply sneak (default: shift) in the direction you want to tunnel. You will slowly begin tunneling in the direction you're facing for as long as you sneak or if the tunnel has been dug long enough. This ability will be interrupted if it hits a block that cannot be earthbent." - MaxRadius: 1 - Range: 10 - Radius: 0.25 - Revert: true - Interval: 30 - Extraction: - Enabled: true - Description: "This ability allows metalbenders to extract the minerals from ore blocks. To use, simply tap sneak while looking at an ore block with metal in it (iron, gold, etc) and the ore will be extracted and drop in front of you. This ability has a small chance of doubling or tripling the loot. This ability has a short cooldown." - Cooldown: 10000 - TripleLootChance: 15 - DoubleLootChance: 40 - MetalClips: - Enabled: true - LavaFlow: - Enabled: true - Description: 'This ability allows an Earthbender to create lava using the Earth - around them. To use, simply hold sneak (Default: Shift) to create a lava moat - that surrounds you, press sneak again to remove the moat. Left click an Earthbendable - block to create a pool of lava after a small delay. Additionally, you can - left click at any time to turn lava back into its original state -- Earth.' - ShiftCooldown: 16000 - ClickLavaCooldown: 10000 - ClickLandCooldown: 500 - ShiftCleanupDelay: 10000 - ClickLavaCleanupDelay: 7000 - ClickLandCleanupDelay: 20000 - ClickRange: 10.0 - ShiftRadius: 8.0 - ClickRadius: 5.0 - ShiftPlatformRadius: 1.5 - ClickLavaCreateSpeed: 0.05 - ClickLandCreateSpeed: 0.1 - ShiftFlowSpeed: 0.1 - ShiftRemoveSpeed: 3.0 - ClickLavaStartDelay: 1500 - ClickLandStartDelay: 0 - UpwardFlow: 2 - DownwardFlow: 4 - AllowNaturalFlow: false - ParticleDensity: 0.33 - EarthSmash: - Enabled: true - Description: 'To raise an EarthSmash hold sneak (default: shift) for approximately - 1.5 seconds, then release while aiming at dirt. To grab the EarthSmash aim - at the center and hold sneak, the EarthSmash will follow your mouse. You can - shoot the EarthSmash by grabbing onto it and left clicking. To ride the EarthSmash - simply hop ontop of it and hold sneak while aiming in the direction that you - wish to go. Another way to ride an EarthSmash is to grab it with sneak and - then right click it. Use EarthSmash as a defensive shield, a powerful attack, - or an advanced means of transportation.' - AllowGrab: true - AllowShooting: true - AllowFlight: true - GrabRange: 10 - ChargeTime: 1200 - Cooldown: 0 - ShotRange: 30 - Damage: 6 - Knockback: 3.5 - Knockup: 0.15 - FlightSpeed: 0.72 - FlightTimer: 3000 - RemoveTimer: 30000 - RaiseEarth: - Enabled: true - Description: "To use, simply left-click on an earthbendable block. A column of earth will shoot upwards from that location. Anything in the way of the column will be brought up with it, leaving talented benders the ability to trap brainless entities up there. Additionally, simply sneak (default shift) looking at an earthbendable block. A wall of earth will shoot upwards from that location. Anything in the way of the wall will be brought up with it." - Column: - Height: 6 - Wall: - Range: 15 - Height: 6 - Width: 6 - Shockwave: - Enabled: true - Description: "This is one of the most powerful moves in the earthbender's arsenal. To use, you must first charge it by holding sneak (default: shift). Once charged, you can release sneak to create an enormous shockwave of earth, disturbing all earth around you and expanding radially outwards. Anything caught in the shockwave will be blasted back and dealt damage. If you instead click while charged, the disruption is focused in a cone in front of you. Lastly, if you fall from a great enough height with this ability selected, you will automatically create a shockwave." - ChargeTime: 2500 - FallThreshold: 10 - Damage: 5 - Knockback: 1.1 - Range: 15 - Tremorsense: - Enabled: true - Description: "This is a pure utility ability for earthbenders. If you are in an area of low-light and are standing on top of an earthbendable block, this ability will automatically turn that block into glowstone, visible *only by you*. If you lose contact with a bendable block, the light will go out as you have lost contact with the earth and cannot 'see' until you can touch earth again. Additionally, if you click with this ability selected, smoke will appear above nearby earth with pockets of air beneath them." - MaxDepth: 10 - Radius: 5 - LightThreshold: 7 - Cooldown: 1000 - Fire: - Blaze: - Enabled: true - Description: "To use, simply click in any direction. An arc of fire will flow from your location, igniting anything in its path. Additionally, tap sneak to engulf the area around you in roaring flames." - ArcOfFire: - Arc: 20 - Range: 9 - RingOfFire: - Range: 7 - Combustion: - Enabled: true - Description: "Combustion is a powerful ability only known by a few skilled Firebenders. It allows the bender to Firebend with their mind, concentrating energy to create a powerful blast. To use, simply tap sneak (Default: Shift) to launch the blast. This technique is highly destructive and very effective, it also comes with a long cooldown." - Cooldown: 15000 - BreakBlocks: false - Power: 1.0 - Damage: 5 - Radius: 4 - Range: 20 - Speed: 25 - FireBlast: - Enabled: true - Description: "FireBlast is the most fundamental technique of a firebender. To use, simply left-click in a direction. A blast of fire will be created at your fingertips. If this blast contacts an enemy, it will dissipate and engulf them in flames, doing additional damage and knocking them back slightly. If the blast hits terrain, it will ignite the nearby area. Additionally, if you hold sneak, you will charge up the fireblast. If you release it when it's charged, it will instead launch a powerful fireball that explodes on contact." - Speed: 15 - Range: 15 - Radius: 2 - Push: 0.3 - Damage: 2 - Cooldown: 1500 - Dissipate: false - Charged: - ChargeTime: 2000 - Damage: 4 - DamageRadius: 6 - Power: 1 - Range: 20 - FireBurst: - Enabled: true - Description: "FireBurst is a very powerful firebending ability. To use, press and hold sneak to charge your burst. Once charged, you can either release sneak to launch a cone-shaped burst of flames in front of you, or click to release the burst in a sphere around you." - ChargeTime: 2500 - Damage: 3 - Range: 15 - FireJet: - Enabled: true - Description: "This ability is used for a limited burst of flight for firebenders. Clicking with this ability selected will launch you in the direction you're looking, granting you controlled flight for a short time. This ability can be used mid-air to prevent falling to your death, but on the ground it can only be used if standing on a block that's ignitable (e.g. not snow or water)." - Speed: 0.7 - Duration: 1500 - Cooldown: 6000 - IsAvatarStateToggle: true - FireShield: - Enabled: true - Description: "FireShield is a basic defensive ability. Clicking with this ability selected will create a small disc of fire in front of you, which will block most attacks and bending. Alternatively, pressing and holding sneak creates a very small shield of fire, blocking most attacks. Creatures that contact this fire are ignited." - Radius: 3 - DiscRadius: 1.5 - Duration: 1000 - HeatControl: - Enabled: true - Description: "While this ability is selected, the firebender becomes impervious to fire damage and cannot be ignited. If the user left-clicks with this ability, the targeted area will be extinguished, although it will leave any creature burning engulfed in flames. This ability can also cool lava. If this ability is used while targeting ice or snow, it will instead melt blocks in that area. Finally, sneaking with this ability will cook any food in your hand." - Extinguish: - Range: 20 - Radius: 7 - Melt: - Range: 15 - Radius: 5 - Illumination: - Enabled: true - Description: "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking will create a torch that follows you around. The torch will only appear on objects that are ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, it will disappear, but will reappear when you get on another ignitable block. Clicking again dismisses this torch." - Range: 5 - Lightning: - Enabled: true - Description: "Hold sneak while selecting this ability to charge up a lightning strike. once charged, release sneak to discharge the lightning to the targeted location." - Damage: 6 - Range: 13.0 - ChargeTime: 3500 - Cooldown: 0 - StunChance: 0.2 - StunDuration: 30.0 - MaxArcAngle: 30 - SubArcChance: 0.025 - ChainArcRange: 6.0 - ChainArcChance: 0.5 - MaxChainArcs: 2 - WaterArcs: 4 - WaterArcRange: 12.0 - SelfHitWater: true - SelfHitClose: true - ArcOnIce: false - WallOfFire: - Enabled: true - Description: "To use this ability, click at a location. A wall of fire will appear at this location, igniting enemies caught in it and blocking projectiles." - Range: 4 - Height: 4 - Width: 4 - Duration: 5000 - Damage: 2 - Cooldown: 7500 - Interval: 500 - FireCombo: - Enabled: true - FireKick: - Range: 7.0 - Damage: 3.0 - Cooldown: 2000 - FireSpin: - Range: 7 - Damage: 3.0 - Knockback: 3.2 - Cooldown: 2000 - FireWheel: - Range: 20.0 - Damage: 4.0 - Speed: 0.55 - Cooldown: 200 - JetBlast: - Speed: 1.2 - Cooldown: 6000 - JetBlaze: - Speed: 1.1 - Damage: 3 - Cooldown: 6000 - Chi: - Passive: - FallReductionFactor: 0.5 - Speed: 1 - Jump: 2 - BlockChi: - Duration: 2500 - DodgeChance: 25 - AcrobatStance: - Enabled: true - Description: "AcrobatStance gives a Chiblocker a higher probability of blocking a Bender's Chi while granting them a Speed and Jump boost. It also increases the rate at which the hunger bar depletes. To use, simply left click. Left clicking again will de-activate the stance." - ChiBlockBoost: 0.1 - HighJump: - Enabled: true - Description: "To use this ability, simply click. You will jump quite high. This ability has a short cooldown." - Cooldown: 10000 - Height: 1 - 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 - RapidPunch: - Enabled: true - Description: "This ability allows the chiblocker to punch rapidly in a short period. To use, simply punch. This has a short cooldown." - Damage: 1 - Distance: 4 - Cooldown: 15000 - Punches: 4 - Smokescreen: - Enabled: true - Description: "Smokescren, if used correctly, can serve as a defensive and offensive ability for Chiblockers. To use, simply left click and you will toss out a Smoke Bomb. When the bomb hits the ground, it will explode and give all players within a small radius of the explosion temporary blindness, allowing you to either get away, or move in for the kill. This ability has a long cooldown." - Cooldown: 50000 - Radius: 4 - Duration: 15 - WarriorStance: - Enabled: true - Description: "WarriorStance gives a Chiblocker increased damage but makes them a tad more vulnerable. To activate, simply left click." - Strength: 1 - Resistance: -1 -Storage: - engine: sqlite - MySQL: - host: localhost - port: 3306 - pass: '' - db: minecraft - user: root +Properties: + ImportEnabled: true + GlobalCooldown: 500 + SeaLevel: 62 + CustomItems: + GrapplingHook: + Enable: true + IronUses: 25 + GoldUses: 50 + Chat: + Format: ": " + Enable: true + Prefixes: + Air: "[Airbender]" + Water: "[Waterbender]" + Earth: "[Earthbender]" + Fire: "[Firebender]" + Chi: "[Chiblocker]" + Avatar: "[Avatar]" + Colors: + Avatar: DARK_PURPLE + Air: GRAY + Fire: RED + Water: AQUA + Earth: GREEN + Metalbending: DARK_GREEN + Chi: GOLD + RegionProtection: + AllowHarmlessAbilities: true + RespectWorldGuard: true + RespectGriefPrevention: true + RespectFactions: true + RespectTowny: true + RespectPreciousStones: true + RespectLWC: true + CacheBlockTime: 5000 + Air: + CanBendWithWeapons: false + Particles: smoke + PlaySound: true + Water: + CanBendWithWeapons: false + NightFactor: 1.5 + FullMoonFactor: 3.0 + CanBendPackedIce: true + PlaySound: true + Earth: + RevertEarthbending: true + SafeRevert: true + RevertCheckTime: 300000 + CanBendWithWeapons: true + EarthbendableBlocks: + - STONE + - COAL_ORE + - DIAMOND_ORE + - DIRT + - GOLD_ORE + - GRASS + - GRAVEL + - IRON_ORE + - LAPIS_ORE + - NETHERRACK + - REDSTONE_ORE + - SAND + - SANDSTONE + - MYCEL + MetalBlocks: + - IRON_BLOCK + - GOLD_BLOCK + - QUARTZ_BLOCK + MetalPowerFactor: 1.5 + PlaySound: true + Fire: + CanBendWithWeapons: true + DayFactor: 1.5 + PlaySound: true + Chi: + CanBendWithWeapons: false + DisabledWorlds: + - TestWorld + - TestWorld2 +Abilities: + AvatarState: + Enabled: true + Description: "The signature ability of the Avatar, this is a toggle. Click to activate to become nearly unstoppable. While in the Avatar State, the user takes severely reduced damage from all sources, regenreates health rapidly, and is granted extreme speed. Nearly all abilities are incredibly amplified in this state. Additionally, AirShield and FireJet become toggle-able abilities and last until you deactivate them or the Avatar State. Click again with the Avatar State selected to deactivate it." + Cooldown: 720000 + Duration: 480000 + PowerMultiplier: 5 + PotionEffects: + Regeneration: + Enabled: true + Power: 3 + Speed: + Enabled: true + Power: 3 + DamageResistance: + Enabled: true + Power: 3 + FireResistance: + Enabled: true + Power: 3 + Air: + Passive: + Factor: 0.3 + Speed: 2 + Jump: 3 + AirBlast: + Enabled: true + Description: "AirBlast is the most fundamental bending technique of an airbender. To use, simply left-click in a direction. A gust of wind will be created at your fingertips, launching anything in its path harmlessly back. A gust of air can extinguish fires on the ground or on a player, can cool lava, and can flip levers and activate buttons. Additionally, tapping sneak will change the original of your next AirBlast to your targeted location." + Speed: 25 + Range: 20 + Radius: 2 + Push: 3.5 + AirBubble: + Enabled: true + Description: "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability." + Radius: 7 + AirBurst: + Enabled: true + Description: "AirBurst is one of the most powerful abilities in an airbender's arsenal. To use, press and hold sneak to charge your burst. Once charged, you can either release sneak to launch a cone-shaped burst of air in front of you, or click to release theb urst in a sphere around you. Additionally, having this ability selected when you land on the ground from a large enough fall will create a burst of air around you." + FallThreshold: 10 + PushFactor: 1.5 + ChargeTime: 1750 + Damage: 0 + AirScooter: + Enabled: true + Description: "AirScooter is a fast means of transportation. To use, sprint, jump then click with this ability selected. YOu will hop on a scooter of air and be propelled forward in the direction you're looking (you don't need to press anything). This ability can be used to levitate above liquids, but it cannot go up steep slopes. Any other actions will deactivate this ability." + Speed: 0.675 + AirShield: + Enabled: true + Description: "Air Shield is one of the most powerful defensive techniques in existence. To use, simply sneak (default: shift). This will create a whirlwind of air around the user, with a small pocket of safe space in the center. This wind will deflect all projectiles and will prevent any creature from entering it for as long as its maintained." + Radius: 7 + IsAvatarStateToggle: true + AirSpout: + Enabled: true + Description: "This ability gives the airbender limited sustained levitation. It is a toggle - click to activate and form a whirling spout of air beneath you, lifting you up. You can bend other abilities while using AirSpout. Click again to deactivate this ability." + Height: 20 + AirSuction: + Enabled: true + Description: "To use, simply left-click in a direction. A gust of wind will originate as far as it can in that direction and flow towards you, sucking anything in its path harmlessly with it. Skilled benders can use this technique to pull items from precarious locations. Additionally, tapping sneak will change the origin of your next AirSuction to your targeted location." + Speed: 25 + Range: 20 + Radius: 2 + Push: 3.5 + AirSwipe: + Enabled: true + Description: "To use, simply left-click in a direction. An arc of air will flow from you towards that direction, cutting and pushing back anything in its path. Its damage is minimal, but it still sends the message. This ability will extinguish fires, cool lava, and cut things like grass, mushrooms, and flowers. Additionally, you can charge it by holding sneak. Charging before attacking will increase damage and knockback, up to a maximum." + Damage: 2 + Range: 16 + Radius: 2 + Push: 1 + Arc: 20 + Speed: 25 + Cooldown: 1500 + ChargeFactor: 3 + MaxChargeTime: 3000 + Flight: + Enabled: true + Description: "Jump in the air, crouch (default: shift) and hold with this ability bound and you will glide around in the direction you look. While flying, click to Hover. Click again to disable Hovering." + HoverEnabled: true + Suffocate: + Enabled: true + Description: "This ability is one of the most dangerous abilities an Airbender possesses. To use, simply look at an entity and hold shift. The entity will begin taking damage as you extract the air from their lungs. Any bender caught in this sphere will only be able to use basic moves, such as AirSwipe, WaterManipulation, FireBlast, or EarthBlast. An entity can be knocked out of the sphere by certain bending arts, and your attention will be disrupted if you are hit by bending." + Range: 15 + Damage: 2 + ChargeTime: 1000 + Cooldown: 0 + DamageInitialDelay: 2 + DamageInterval: 1 + SlowPotency: 1 + SlowDelay: 0.5 + SlowInterval: 1.25 + BlindPotentcy: 30 + BlindDelay: 2 + BlindInterval: 1.5 + CanBeUsedOnUndeadMobs: true + RequireConstantAim: true + RequireConstantAimRadius: 5 + AnimationRadius: 2.0 + AnimationParticleAmount: 2 + AnimationSpeed: 1.0 + 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." + Radius: 10 + Height: 25 + Range: 25 + MobPushFactor: 1 + PlayerPushFactor: 1 + AirCombo: + Enabled: true + Twister: + Speed: 0.35 + Range: 16 + Height: 8 + Radius: 3.5 + RemoveDelay: 1500 + Cooldown: 10000 + DegreesPerParticle: 9 + HeightPerParticle: 2.0 + AirStream: + Speed: 0.5 + Range: 40 + EntityDuration: 4000 + EntityHeight: 14 + Cooldown: 6000 + AirSweep: + Speed: 1.4 + Range: 14 + Damage: 4 + Knockback: 3.5 + Cooldown: 5000 + Water: + Passive: + SwimSpeedFactor: 0.7 + Bloodbending: + Enabled: true + Description: "This ability was made illegal for a reason. With this ability selected, sneak while targeting something and you will bloodbend that target. Bloodbent targets cannot move, bend, or attack. You are free to control their actions by looking elsewhere - they will be forced to move in that direction. Additionally, clicking while bloodbending will launch that target off in the direction you're looking. People who are capable of bloodbending are immune to technique, and you are immune to theirs." + CanOnlyBeUsedAtNight: false + CanBeUsedOnUndeadMobs: true + CanOnlyBeUsedDuringFullMoon: false + ThrowFactor: 2 + Range: 10 + HoldTime: 2000 + Cooldown: 4000 + HealingWaters: + Enabled: true + Description: "To use, the bender must be at least partially submerged in water. If the user is not sneaking, this ability will automatically begin working provided the user has it selected. If the user is sneaking, he/she is channeling the healing to their target in front of them. In order for this channel to be successful, the user and the target must be at least partially submerged in water." + Radius: 5 + Interval: 750 + Power: 1 + IceBlast: + Enabled: true + Damage: 3 + Range: 20 + Description: "This ability offers a powerful ice utility for Waterbenders. It can be used to fire an explosive burst of ice at an opponent, spraying ice and snow around it. To use, simply tap sneak (Default: Shift) while targeting a block of ice to select it as a source. From there, you can just left click to send the blast off at your opponent." + IceSpike: + Enabled: true + Description: "This ability has many functions. Clicking while targetting ice, or an entity over some ice, will raise a spike of ice up, damaging and slowing the target. Tapping sneak (default: shift) while selecting a water source will select that source that can be fired with a click. Firing this will launch a spike of ice at your target, dealing a bit of damage and slowing the target. If you sneak (shift) will not selecting a source, many ice spikes will erupt from around you, damaging and slowing those targets." + Cooldown: 2000 + Damage: 2 + Range: 20 + ThrowingMult: 0.7 + Height: 6 + Projectile: + Range: 20 + Damage: 1 + OctopusForm: + Enabled: true + Description: "This ability allows the waterbender to manipulate a large quantity of water into a form resembling that of an octopus. To use, click to select a water source. Then, hold sneak to channel this ability. While channleing, the water will form itself around you and has a chance to block incoming attacks. Additionally, you can click while channeling to attack things near you, dealing damage and knocking the target back. Releasing shift at any time will dissipate the form." + Range: 10 + AttackRange: 2.5 + Damage: 3 + Radius: 3 + FormDelay: 50 + Knockback: 1.75 + PhaseChange: + Enabled: true + Description: "To use, simply left-click. Any water you are looking at within range will instantly freeze over into solid ice. Provided you stay within range of the ice and do not unbind FreezeMelt, that ice will not thaw. If, however, you do either of those things the ice will instantly thaw. If you sneak (default: shift), anything around where you are looking at will instantly melt. Since this is a more favorable state for these things, they will never re-freeze unless they would otherwise by nature or some other bending ability. Additionally, if you tap sneak while targeting water with FreezeMelt, it will evaporate water around that block that is above sea level." + Range: 20 + Radius: 5 + Plantbending: + RegrowTime: 180000 + Surge: + Enabled: true + Description: "This ability has two distinct features. If you sneak to select a source block, you can then click in a direction and a large wave will be launched in that direction. If you sneak again while the wave is en route, the wave will freeze the next target it hits. If, instead, you click to select a source block, you can hold sneak to form a wall of water at your cursor location. Click to shift between a water wall and an ice wall. Release sneak to dissipate it." + Wave: + Radius: 3 + HorizontalPush: 1 + VerticalPush: 0.2 + Range: 20 + Wall: + Range: 5 + Radius: 2 + VerticalPush: 0.2 + Torrent: + Enabled: true + Description: "Torrent is one of the strongest moves in a waterbender's arsenal. To use, first click a source block to select it; then hold shift to begin streaming the water around you. Water flowing around you this way will damage and knock back nearby enemies and projectiles. If you release shift during this, you will create a large wave that expands outwards from you, launching anything in its path back. Instead, if you click you release the water and channel it to flow towards your cursor. Anything caught in the blast will be tossed about violently and take damage. Finally, if you click again when the water is torrenting, it will freeze the area around it when it is obstructed." + Damage: 2 + DeflectDamage: 1 + Range: 25 + Wave: + Radius: 15 + Knockback: 1.5 + Height: 1 + WaterBubble: + Enabled: true + Description: "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability." + Radius: 7 + WaterManipulation: + Enabled: true + Description: "To use, place your cursor over a waterbendable object and tap sneak (default: shift). Smoke will appear where you've selected, indicating the origin of your ability. After you have selected an origin, simply left-click in any direction and you will see your water spout off in that direction, slicing any creature in its path. If you look towards a creature when you use this ability, it will target that creature. A collision from Water Manipulation both knocks the target back and deals some damage. Alternatively, if you have the source selected and tap shift again, you will be able to control the water more directly." + Damage: 3.0 + Range: 20 + Speed: 35 + Push: .3 + Cooldown: 1000 + WaterSpout: + Enabled: true + Description: "This ability provides a Waterbender with a new means of transportation. To use, simply left click while in or over water to spout water up beneath you, experiencing controlled levitation. Left clicking again while the spout is active will cause it to disappear. Alternatively, tapping a Waterbendable block while not in Water will select a water block as a source, from there, you can tap sneak (Default:Shift) to channel the Water around you. Releasing the sneak will create a wave allowing you a quick burst of controlled transportation. While riding the wave you may press sneak to cause the wave to disappear." + Height: 20 + Wave: + Enabled: true + Range: 6 + ChargeTime: 1000 + FlightTime: 2000 + Speed: 1.2 + WaterCombo: + Enabled: true + IceWave: + Damage: 3 + Cooldown: 6000 + IceBullet: + Damage: 1.5 + Radius: 2.5 + Range: 12 + MaxShots: 30 + AnimationSpeed: 1 + ShootTime: 5000 + Cooldown: 10000 + WaterArms: + Enabled: true + Description: |- + One of the most diverse moves in a Waterbender's arsenal, this move creates tendrils of water from the players arms to emulate their actual arms. Each water arms mode will be binded to a slot, switch slots to change mode. To deactive the arms, hold Sneak and Double Left-Click. + Pull - Use your Arms to pull blocks, items, mobs or even players towards you! + Punch - An offensive attack, harming players or mobs! + Grapple - Scale walls and speed across battlefields, using your Arms as a grappling hook! + Grab - Grab an entity with your arm, and swing them about! + Freeze - Use your Arms to fire small blasts of ice in any direction! + Spear - Throw your Arms in any direction, freezing whatever it hits! + SneakMessage: 'Active Ability:' + Arms: + InitialLength: 4 + SourceGrabRange: 4 + MaxAttacks: 10 + MaxAlternateUsage: 50 + MaxIceShots: 5 + Cooldown: 20000 + AllowPlantSource: true + Lightning: + Enabled: true + Damage: 10.0 + KillUser: false + Cooldowns: + UsageCooldownEnabled: false + UsageCooldown: 200 + AllowSpectatorUse: false + Whip: + MaxLength: 20 + MaxLengthWeak: 12 + NightAugments: + MaxLength: + Normal: 24 + FullMoon: 30 + Punch: + PunchDamage: 3.0 + Grapple: + RespectRegions: false + Grab: + HoldTime: 10000 + Freeze: + Range: 20 + Damage: 2.0 + Spear: + Range: 40 + Damage: 4.0 + DamageEnabled: true + Sphere: 2 + Duration: 6000 + Length: 18 + NightAugments: + Range: + Normal: 45 + FullMoon: 60 + Sphere: + Normal: 3 + FullMoon: 6 + Duration: + Normal: 7000 + FullMoon: 12000 + Earth: + Passive: + Duration: 2500 + Catapult: + Enabled: true + Description: "To use, left-click while looking in the direction you want to be launched. A pillar of earth will jut up from under you and launch you in that direction - if and only if there is enough earth behind where you're looking to launch you. Skillful use of this ability takes much time and work, and it does result in the death of certain gung-ho earthbenders. if you plan to use this ability, be sure you've read about your passive ability you innately have as an earthbender." + Length: 7 + Speed: 12 + Push: 5 + Collapse: + Enabled: true + Description: "To use, simply left-click an earthbendable block. That block and the earthbendable blocks above it will be shoved back into the earth below, if they can. This ability does have the capacity to trap something inside of it, although it is incredibly difficult to do so. Additionally, press sneak with this ability to affect an area around your targeted location - all earth that can be moved downwards will be moved downwards. This ability is especially risky or deadly in caves, depending on the earthbender's goal and technique." + Range: 20 + Radius: 7 + Speed: 8 + EarthArmor: + Enabled: true + Description: "This ability encases the earthbender in temporary armor. To use, click on a block that is earthbendable. If there is another block under it that is earthbendable, the block will fly to you and grant you temporary armor and damage reduction. This ability has a long cooldown." + Duration: 10000 + Strength: 2 + Cooldown: 17500 + EarthBlast: + Enabled: true + Description: "To use, place your cursor over an earthbendable object and tap sneak (default: shift). The object will temporarily turn to stone, indicating that you have it focused as the source for your ability. After you have selected an origin (you no longer need to be sneaking), simply left-click in any direction and you will see your object launch off in that direction, smashing into any creature in its path. If you look towards a creature when you use this ability, it will target that creature. A collision from Earth Blast both knocks the target back and deals some damage. You cannot have multiple of these abilities flying at the same time." + CanHitSelf: false + PrepareRange: 7 + Range: 20 + Speed: 35 + Revert: true + Damage: 4 + Push: 0.3 + EarthGrab: + Enabled: true + Description: "To use, simply left-click while targeting a creature within range. This ability will erect a circle of earth to trap the creature in." + Range: 15 + EarthTunnel: + Enabled: true + Description: "Earth Tunnel is a completely utility ability for earthbenders. To use, simply sneak (default: shift) in the direction you want to tunnel. You will slowly begin tunneling in the direction you're facing for as long as you sneak or if the tunnel has been dug long enough. This ability will be interrupted if it hits a block that cannot be earthbent." + MaxRadius: 1 + Range: 10 + Radius: 0.25 + Revert: true + Interval: 30 + Extraction: + Enabled: true + Description: "This ability allows metalbenders to extract the minerals from ore blocks. To use, simply tap sneak while looking at an ore block with metal in it (iron, gold, etc) and the ore will be extracted and drop in front of you. This ability has a small chance of doubling or tripling the loot. This ability has a short cooldown." + Cooldown: 10000 + TripleLootChance: 15 + DoubleLootChance: 40 + MetalClips: + Enabled: true + LavaFlow: + Enabled: true + Description: 'This ability allows an Earthbender to create lava using the Earth + around them. To use, simply hold sneak (Default: Shift) to create a lava moat + that surrounds you, press sneak again to remove the moat. Left click an Earthbendable + block to create a pool of lava after a small delay. Additionally, you can + left click at any time to turn lava back into its original state -- Earth.' + ShiftCooldown: 16000 + ClickLavaCooldown: 10000 + ClickLandCooldown: 500 + ShiftCleanupDelay: 10000 + ClickLavaCleanupDelay: 7000 + ClickLandCleanupDelay: 20000 + ClickRange: 10.0 + ShiftRadius: 8.0 + ClickRadius: 5.0 + ShiftPlatformRadius: 1.5 + ClickLavaCreateSpeed: 0.05 + ClickLandCreateSpeed: 0.1 + ShiftFlowSpeed: 0.1 + ShiftRemoveSpeed: 3.0 + ClickLavaStartDelay: 1500 + ClickLandStartDelay: 0 + UpwardFlow: 2 + DownwardFlow: 4 + AllowNaturalFlow: false + ParticleDensity: 0.33 + EarthSmash: + Enabled: true + Description: 'To raise an EarthSmash hold sneak (default: shift) for approximately + 1.5 seconds, then release while aiming at dirt. To grab the EarthSmash aim + at the center and hold sneak, the EarthSmash will follow your mouse. You can + shoot the EarthSmash by grabbing onto it and left clicking. To ride the EarthSmash + simply hop ontop of it and hold sneak while aiming in the direction that you + wish to go. Another way to ride an EarthSmash is to grab it with sneak and + then right click it. Use EarthSmash as a defensive shield, a powerful attack, + or an advanced means of transportation.' + AllowGrab: true + AllowShooting: true + AllowFlight: true + GrabRange: 10 + ChargeTime: 1200 + Cooldown: 0 + ShotRange: 30 + Damage: 6 + Knockback: 3.5 + Knockup: 0.15 + FlightSpeed: 0.72 + FlightTimer: 3000 + RemoveTimer: 30000 + RaiseEarth: + Enabled: true + Description: "To use, simply left-click on an earthbendable block. A column of earth will shoot upwards from that location. Anything in the way of the column will be brought up with it, leaving talented benders the ability to trap brainless entities up there. Additionally, simply sneak (default shift) looking at an earthbendable block. A wall of earth will shoot upwards from that location. Anything in the way of the wall will be brought up with it." + Column: + Height: 6 + Wall: + Range: 15 + Height: 6 + Width: 6 + Shockwave: + Enabled: true + Description: "This is one of the most powerful moves in the earthbender's arsenal. To use, you must first charge it by holding sneak (default: shift). Once charged, you can release sneak to create an enormous shockwave of earth, disturbing all earth around you and expanding radially outwards. Anything caught in the shockwave will be blasted back and dealt damage. If you instead click while charged, the disruption is focused in a cone in front of you. Lastly, if you fall from a great enough height with this ability selected, you will automatically create a shockwave." + ChargeTime: 2500 + FallThreshold: 10 + Damage: 5 + Knockback: 1.1 + Range: 15 + Tremorsense: + Enabled: true + Description: "This is a pure utility ability for earthbenders. If you are in an area of low-light and are standing on top of an earthbendable block, this ability will automatically turn that block into glowstone, visible *only by you*. If you lose contact with a bendable block, the light will go out as you have lost contact with the earth and cannot 'see' until you can touch earth again. Additionally, if you click with this ability selected, smoke will appear above nearby earth with pockets of air beneath them." + MaxDepth: 10 + Radius: 5 + LightThreshold: 7 + Cooldown: 1000 + Fire: + Blaze: + Enabled: true + Description: "To use, simply click in any direction. An arc of fire will flow from your location, igniting anything in its path. Additionally, tap sneak to engulf the area around you in roaring flames." + ArcOfFire: + Arc: 20 + Range: 9 + RingOfFire: + Range: 7 + Combustion: + Enabled: true + Description: "Combustion is a powerful ability only known by a few skilled Firebenders. It allows the bender to Firebend with their mind, concentrating energy to create a powerful blast. To use, simply tap sneak (Default: Shift) to launch the blast. This technique is highly destructive and very effective, it also comes with a long cooldown." + Cooldown: 15000 + BreakBlocks: false + Power: 1.0 + Damage: 5 + Radius: 4 + Range: 20 + Speed: 25 + FireBlast: + Enabled: true + Description: "FireBlast is the most fundamental technique of a firebender. To use, simply left-click in a direction. A blast of fire will be created at your fingertips. If this blast contacts an enemy, it will dissipate and engulf them in flames, doing additional damage and knocking them back slightly. If the blast hits terrain, it will ignite the nearby area. Additionally, if you hold sneak, you will charge up the fireblast. If you release it when it's charged, it will instead launch a powerful fireball that explodes on contact." + Speed: 15 + Range: 15 + Radius: 2 + Push: 0.3 + Damage: 2 + Cooldown: 1500 + Dissipate: false + Charged: + ChargeTime: 2000 + Damage: 4 + DamageRadius: 6 + Power: 1 + Range: 20 + FireBurst: + Enabled: true + Description: "FireBurst is a very powerful firebending ability. To use, press and hold sneak to charge your burst. Once charged, you can either release sneak to launch a cone-shaped burst of flames in front of you, or click to release the burst in a sphere around you." + ChargeTime: 2500 + Damage: 3 + Range: 15 + FireJet: + Enabled: true + Description: "This ability is used for a limited burst of flight for firebenders. Clicking with this ability selected will launch you in the direction you're looking, granting you controlled flight for a short time. This ability can be used mid-air to prevent falling to your death, but on the ground it can only be used if standing on a block that's ignitable (e.g. not snow or water)." + Speed: 0.7 + Duration: 1500 + Cooldown: 6000 + IsAvatarStateToggle: true + FireShield: + Enabled: true + Description: "FireShield is a basic defensive ability. Clicking with this ability selected will create a small disc of fire in front of you, which will block most attacks and bending. Alternatively, pressing and holding sneak creates a very small shield of fire, blocking most attacks. Creatures that contact this fire are ignited." + Radius: 3 + DiscRadius: 1.5 + Duration: 1000 + HeatControl: + Enabled: true + Description: "While this ability is selected, the firebender becomes impervious to fire damage and cannot be ignited. If the user left-clicks with this ability, the targeted area will be extinguished, although it will leave any creature burning engulfed in flames. This ability can also cool lava. If this ability is used while targeting ice or snow, it will instead melt blocks in that area. Finally, sneaking with this ability will cook any food in your hand." + Extinguish: + Range: 20 + Radius: 7 + Melt: + Range: 15 + Radius: 5 + Illumination: + Enabled: true + Description: "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking will create a torch that follows you around. The torch will only appear on objects that are ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, it will disappear, but will reappear when you get on another ignitable block. Clicking again dismisses this torch." + Range: 5 + Lightning: + Enabled: true + Description: "Hold sneak while selecting this ability to charge up a lightning strike. once charged, release sneak to discharge the lightning to the targeted location." + Damage: 6 + Range: 13.0 + ChargeTime: 3500 + Cooldown: 0 + StunChance: 0.2 + StunDuration: 30.0 + MaxArcAngle: 30 + SubArcChance: 0.025 + ChainArcRange: 6.0 + ChainArcChance: 0.5 + MaxChainArcs: 2 + WaterArcs: 4 + WaterArcRange: 12.0 + SelfHitWater: true + SelfHitClose: true + ArcOnIce: false + WallOfFire: + Enabled: true + Description: "To use this ability, click at a location. A wall of fire will appear at this location, igniting enemies caught in it and blocking projectiles." + Range: 4 + Height: 4 + Width: 4 + Duration: 5000 + Damage: 2 + Cooldown: 7500 + Interval: 500 + FireCombo: + Enabled: true + FireKick: + Range: 7.0 + Damage: 3.0 + Cooldown: 2000 + FireSpin: + Range: 7 + Damage: 3.0 + Knockback: 3.2 + Cooldown: 2000 + FireWheel: + Range: 20.0 + Damage: 4.0 + Speed: 0.55 + Cooldown: 200 + JetBlast: + Speed: 1.2 + Cooldown: 6000 + JetBlaze: + Speed: 1.1 + Damage: 3 + Cooldown: 6000 + Chi: + Passive: + FallReductionFactor: 0.5 + Speed: 1 + Jump: 2 + BlockChi: + Duration: 2500 + DodgeChance: 25 + AcrobatStance: + Enabled: true + Description: "AcrobatStance gives a Chiblocker a higher probability of blocking a Bender's Chi while granting them a Speed and Jump boost. It also increases the rate at which the hunger bar depletes. To use, simply left click. Left clicking again will de-activate the stance." + ChiBlockBoost: 0.1 + HighJump: + Enabled: true + Description: "To use this ability, simply click. You will jump quite high. This ability has a short cooldown." + Cooldown: 10000 + Height: 1 + 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 + RapidPunch: + Enabled: true + Description: "This ability allows the chiblocker to punch rapidly in a short period. To use, simply punch. This has a short cooldown." + Damage: 1 + Distance: 4 + Cooldown: 15000 + Punches: 4 + Smokescreen: + Enabled: true + Description: "Smokescren, if used correctly, can serve as a defensive and offensive ability for Chiblockers. To use, simply left click and you will toss out a Smoke Bomb. When the bomb hits the ground, it will explode and give all players within a small radius of the explosion temporary blindness, allowing you to either get away, or move in for the kill. This ability has a long cooldown." + Cooldown: 50000 + Radius: 4 + Duration: 15 + WarriorStance: + Enabled: true + Description: "WarriorStance gives a Chiblocker increased damage but makes them a tad more vulnerable. To activate, simply left click." + Strength: 1 + Resistance: -1 +Storage: + engine: sqlite + MySQL: + host: localhost + port: 3306 + pass: '' + db: minecraft + user: root debug: false \ No newline at end of file