diff --git a/.travis.yml b/.travis.yml index 5db461e4..befbc06d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ notifications: slack: rooms: - projectkorra:h9WFZqQ2o6fuCkI69ko28XgF#general - - projectkorra:h9WFZqQ2o6fuCkI69ko28XgF#development + - projectkorra:h9WFZqQ2o6fuCkI69ko28XgF#devs diff --git a/pom.xml b/pom.xml index 7de3d1f5..b5dfeee0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.projectkorra projectkorra - 1.8.4 + 1.8.5 jar ProjectKorra diff --git a/src/com/projectkorra/projectkorra/BendingPlayer.java b/src/com/projectkorra/projectkorra/BendingPlayer.java index 6b220d2a..67657755 100644 --- a/src/com/projectkorra/projectkorra/BendingPlayer.java +++ b/src/com/projectkorra/projectkorra/BendingPlayer.java @@ -21,6 +21,7 @@ import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.ability.WaterAbility; +import com.projectkorra.projectkorra.ability.util.PassiveManager; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.chiblocking.Paralyze; import com.projectkorra.projectkorra.command.Commands; @@ -116,11 +117,11 @@ public class BendingPlayer { this.cooldowns.put(ability, cooldown + System.currentTimeMillis()); Player player = event.getPlayer(); - + if (player == null) { return; } - + String abilityName = event.getAbility(); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); @@ -166,9 +167,11 @@ public class BendingPlayer { if (isAvatarState()) { if (isChiBlocked()) { return true; + } else { + return false; } } - if (canBendIgnoreBindsCooldowns(CoreAbility.getAbility("Bloodbending")) && !isToggled()) { + if (canBendIgnoreBindsCooldowns(CoreAbility.getAbility("Bloodbending")) && isToggled()) { return false; } return true; @@ -194,7 +197,7 @@ public class BendingPlayer { return false; } else if (!ignoreCooldowns && isOnCooldown(ability.getName())) { return false; - } else if (!ignoreBinds && !ability.getName().equals(getBoundAbilityName())) { + } else if (!ignoreBinds && (!ability.getName().equals(getBoundAbilityName()))) { return false; } else if (disabledWorlds != null && disabledWorlds.contains(player.getWorld().getName())) { return false; @@ -211,7 +214,7 @@ public class BendingPlayer { cooldowns.remove(name); } - if (isChiBlocked() || isParalyzed() || isBloodbent() || isControlledByMetalClips()) { + if (isChiBlocked() || isParalyzed() || (isBloodbent() && !ability.getName().equalsIgnoreCase("AvatarState")) || isControlledByMetalClips()) { return false; } else if (GeneralMethods.isRegionProtectedFromBuild(player, ability.getName(), playerLoc)) { return false; @@ -313,6 +316,7 @@ public class BendingPlayer { if (subElement.equals(SpiritElement.DARK) && sPlayer.isLightSpirit()) { return false; } + if (subElement.equals(SpiritElement.LIGHT) && sPlayer.isDarkSpirit()) { return false; } @@ -346,7 +350,6 @@ public class BendingPlayer { /** * Checks to see if a player can LavaBend. * - * @param player The player to check * @return true If player has permission node "bending.earth.lavabending" */ public boolean canLavabend() { @@ -670,7 +673,7 @@ public class BendingPlayer { if (Bukkit.getPlayer(uuid) == null) { return; } - + PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, 0, Result.REMOVED); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -742,6 +745,7 @@ public class BendingPlayer { */ public void toggleBending() { toggled = !toggled; + PassiveManager.registerPassives(player); } public void toggleElement(Element element) { @@ -749,6 +753,7 @@ public class BendingPlayer { return; } toggledElements.put(element, !toggledElements.get(element)); + PassiveManager.registerPassives(player); } /** @@ -818,4 +823,4 @@ public class BendingPlayer { public static Map getPlayers() { return PLAYERS; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index a4f758e1..1f6843d5 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -51,6 +51,7 @@ import org.bukkit.entity.TNTPrimed; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; import org.kingdoms.constants.StructureType; @@ -289,21 +290,23 @@ public class GeneralMethods { * @throws SQLException */ public static void createBendingPlayer(final UUID uuid, final String player) { - // new BukkitRunnable() { - // @Override - // public void run() { - // createBendingPlayerAsynchronously(uuid, player); - // } - // }.runTaskAsynchronously(ProjectKorra.plugin); - createBendingPlayerAsynchronously(uuid, player); // "async" + new BukkitRunnable() { + + @Override + public void run() { + createBendingPlayerAsynchronously(uuid, player); // "async" + } + + }.runTask(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. + DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9) VALUES ('" + + uuid.toString() + "', '" + player + "', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null')"); new BendingPlayer(uuid, player, new ArrayList(), 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. @@ -318,7 +321,7 @@ public class GeneralMethods { String permaremoved = rs2.getString("permaremoved"); boolean p = false; final ArrayList elements = new ArrayList(); - if (element != null) { + if (element != null && !element.equals("NULL")) { boolean hasAddon = element.contains(";"); String[] split = element.split(";"); if (split[0] != null) { // Player has an element. @@ -375,7 +378,7 @@ public class GeneralMethods { } final ArrayList subelements = new ArrayList(); boolean shouldSave = false; - if (subelement != null) { + if (subelement != null && !subelement.equals("NULL")) { boolean hasAddon = subelement.contains(";"); String[] split = subelement.split(";"); if (subelement.equals("-")) { @@ -1616,9 +1619,12 @@ public class GeneralMethods { Preset.loadExternalPresets(); new MultiAbilityManager(); new ComboManager(); + // Stop the previous collision detection task before creating new manager. + ProjectKorra.collisionManager.stopCollisionDetection(); ProjectKorra.collisionManager = new CollisionManager(); ProjectKorra.collisionInitializer = new CollisionInitializer(ProjectKorra.collisionManager); CoreAbility.registerAbilities(); + reloadAddonPlugins(); ProjectKorra.collisionInitializer.initializeDefaultCollisions(); // must be called after abilities have been registered ProjectKorra.collisionManager.startCollisionDetection(); @@ -1641,6 +1647,18 @@ public class GeneralMethods { plugin.updater.checkUpdate(); ProjectKorra.log.info("Reload complete"); } + + public static void reloadAddonPlugins() { + for (int i = CoreAbility.getAddonPlugins().size()-1; i > -1; i--) { + String entry = CoreAbility.getAddonPlugins().get(i); + String[] split = entry.split("::"); + if (Bukkit.getServer().getPluginManager().isPluginEnabled(split[0])) { + CoreAbility.registerPluginAbilities((JavaPlugin)Bukkit.getServer().getPluginManager().getPlugin(split[0]), split[1]); + } else { + CoreAbility.getAddonPlugins().remove(i); + } + } + } public static void removeBlock(Block block) { if (isAdjacentToThreeOrMoreSources(block)) { @@ -1898,8 +1916,12 @@ public class GeneralMethods { elements.append(element.getName() + ","); } } + + if (elements.length() == 0) { + elements.append("NULL"); + } - DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'"); + DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements.toString() + "' WHERE uuid = '" + uuid + "'"); } public static void saveSubElements(BendingPlayer bPlayer) { @@ -1952,8 +1974,12 @@ public class GeneralMethods { subs.append(element.getName() + ","); } } - - DBConnection.sql.modifyQuery("UPDATE pk_players SET subelement = '" + subs + "' WHERE uuid = '" + uuid + "'"); + + if (subs.length() == 0) { + subs.append("NULL"); + } + + DBConnection.sql.modifyQuery("UPDATE pk_players SET subelement = '" + subs.toString() + "' WHERE uuid = '" + uuid + "'"); } public static void savePermaRemoved(BendingPlayer bPlayer) { @@ -2018,8 +2044,13 @@ public class GeneralMethods { } public static void sendBrandingMessage(CommandSender sender, String message) { - ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase()); - color = color == null ? ChatColor.GOLD : color; + ChatColor color; + try { + color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase()); + } catch (IllegalArgumentException exception) { + color = ChatColor.GOLD; + } + String prefix = ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Branding.ChatPrefix.Prefix")) + color + "ProjectKorra" + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Branding.ChatPrefix.Suffix")); if (!(sender instanceof Player)) { sender.sendMessage(prefix + message); diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index 5a93e159..60cb542d 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -129,7 +129,6 @@ import com.projectkorra.projectkorra.earthbending.metal.MetalClips; import com.projectkorra.projectkorra.earthbending.passive.DensityShift; import com.projectkorra.projectkorra.earthbending.passive.EarthPassive; import com.projectkorra.projectkorra.earthbending.passive.FerroControl; -import com.projectkorra.projectkorra.earthbending.sand.SandSpout; import com.projectkorra.projectkorra.event.EntityBendingDeathEvent; import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent; import com.projectkorra.projectkorra.event.PlayerChangeElementEvent; @@ -201,18 +200,23 @@ public class PKListener implements Listener { Block block = event.getBlock(); Player player = event.getPlayer(); - String abil = BendingPlayer.getBendingPlayer(player).getBoundAbilityName(); + BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); + String abil = bPlayer.getBoundAbilityName(); CoreAbility ability = null; - if (abil != null && abil.equalsIgnoreCase("Surge")) { - ability = CoreAbility.getAbility(SurgeWall.class); - } else if (abil != null && abil.equalsIgnoreCase("Torrent")) { - ability = CoreAbility.getAbility(Torrent.class); - } else { - ability = CoreAbility.getAbility(abil); - } - if (ability != null && ability instanceof WaterAbility && !((WaterAbility) ability).allowBreakPlants() && WaterAbility.isPlantbendable(player, block.getType(), false)) { - event.setCancelled(true); - return; + + if (bPlayer.isElementToggled(Element.WATER) && bPlayer.isToggled()) { + if (abil != null && abil.equalsIgnoreCase("Surge")) { + ability = CoreAbility.getAbility(SurgeWall.class); + } else if (abil != null && abil.equalsIgnoreCase("Torrent")) { + ability = CoreAbility.getAbility(Torrent.class); + } else { + ability = CoreAbility.getAbility(abil); + } + + if (ability != null && ability instanceof WaterAbility && !((WaterAbility) ability).allowBreakPlants() && WaterAbility.isPlantbendable(player, block.getType(), false)) { + event.setCancelled(true); + return; + } } EarthBlast blast = EarthBlast.getBlastFromSource(block); @@ -227,7 +231,7 @@ public class PKListener implements Listener { } else if (SurgeWall.getWallBlocks().containsKey(block)) { SurgeWall.thaw(block); event.setCancelled(true); - } else if (Illumination.getBlocks().containsKey(block)) { + } else if (TempBlock.isTempBlock(block) && Illumination.getBlocks().containsKey(TempBlock.get(block))) { event.setCancelled(true); } else if (!SurgeWave.canThaw(block)) { SurgeWave.thaw(block); @@ -257,7 +261,7 @@ public class PKListener implements Listener { event.setCancelled(!WaterManipulation.canFlowFromTo(fromblock, toblock)); } if (!event.isCancelled()) { - if (Illumination.getBlocks().containsKey(toblock)) { + if (TempBlock.isTempBlock(toblock) && Illumination.getBlocks().containsKey(TempBlock.get(toblock))) { toblock.setType(Material.AIR); } } @@ -278,6 +282,24 @@ public class PKListener implements Listener { if (!EarthPassive.canPhysicsChange(event.getBlock())) { event.setCancelled(true); } + if (event.getBlock().getType().toString().equals("CONCRETE_POWDER")) { + BlockFace[] faces = new BlockFace[] {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}; + + boolean marked = true; + for (BlockFace face : faces) { + Block b = event.getBlock().getRelative(face); + if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) { + if (!TempBlock.isTempBlock(b)) { + marked = false; //if there is any normal water around it, prevent it. + break; + } + } + } + + if (marked) { + event.setCancelled(true); + } + } } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @@ -297,7 +319,7 @@ public class PKListener implements Listener { if (block.getType() == Material.FIRE) { return; } - event.setCancelled(Illumination.getBlocks().containsKey(block)); + event.setCancelled(TempBlock.isTempBlock(block) && Illumination.getBlocks().containsKey(TempBlock.get(block))); if (!event.isCancelled()) { event.setCancelled(!WaterManipulation.canPhysicsChange(block)); } @@ -326,7 +348,7 @@ public class PKListener implements Listener { Block block = event.getBlock(); - if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block) || Illumination.getBlocks().containsKey(block) || EarthAbility.getPreventPhysicsBlocks().contains(block)) { + if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block) || (TempBlock.isTempBlock(block) && Illumination.getBlocks().containsKey(TempBlock.get(block))) || EarthAbility.getPreventPhysicsBlocks().contains(block)) { event.setCancelled(true); } @@ -423,7 +445,7 @@ public class PKListener implements Listener { return; if (TempBlock.isTempBlock(block)) { - if (EarthAbility.isEarthbendable(block.getType()) && GeneralMethods.isSolid(block)) { + if (EarthAbility.isEarthbendable(block.getType(), true, true, true) && GeneralMethods.isSolid(block)) { event.setCancelled(true); return; } @@ -472,8 +494,12 @@ public class PKListener implements Listener { TempArmor armor = TempArmor.getTempArmor(event.getEntity()); List newDrops = armor.filterArmor(event.getDrops()); + event.getDrops().clear(); event.getDrops().addAll(newDrops); + if (MetalClips.isControlled(event.getEntity())) { + event.getDrops().add(new ItemStack(Material.IRON_INGOT, MetalClips.getTargetToAbility().get(event.getEntity()).getMetalClipsCount())); + } armor.revert(); } @@ -661,13 +687,21 @@ public class PKListener implements Listener { } Entity entity = event.getEntity(); - if (Paralyze.isParalyzed(entity) || Immobilize.isParalyzed(entity) || Bloodbending.isBloodbent(entity) || Suffocate.isBreathbent(entity)) { + if (Paralyze.isParalyzed(entity) || Immobilize.isParalyzed(entity) || Bloodbending.isBloodbent(entity) || Suffocate.isBreathbent(entity) || MetalClips.isControlled((LivingEntity)entity)) { event.setCancelled(true); } if (entity instanceof LivingEntity && TempArmor.hasTempArmor((LivingEntity) entity)) { TempArmor.getTempArmor((LivingEntity) entity).revert(); } + + if (entity instanceof Player) { + Player player = (Player) entity; + if (CoreAbility.hasAbility(player, EarthArmor.class)) { + EarthArmor abil = CoreAbility.getAbility(player, EarthArmor.class); + abil.remove(); + } + } } @EventHandler @@ -788,7 +822,10 @@ public class PKListener implements Listener { new Shockwave(player, true); } - if (!event.isCancelled() && bPlayer.hasElement(Element.AIR) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.AIR) && bPlayer.canUsePassive(Element.AIR)) { + if (event.isCancelled()) + return; + + if (bPlayer.hasElement(Element.AIR) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.AIR) && bPlayer.canUsePassive(Element.AIR)) { new AirBurst(player, true); if (CoreAbility.getAbility(GracefulDescent.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(GracefulDescent.class))) { event.setDamage(0D); @@ -796,21 +833,21 @@ public class PKListener implements Listener { } } - if (!event.isCancelled() && bPlayer.hasElement(Element.WATER) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.WATER) && bPlayer.canUsePassive(Element.WATER) && CoreAbility.getAbility(Hydrosink.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Hydrosink.class))) { + if (bPlayer.hasElement(Element.WATER) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.WATER) && bPlayer.canUsePassive(Element.WATER) && CoreAbility.getAbility(Hydrosink.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Hydrosink.class))) { if (WaterPassive.applyNoFall(player)) { event.setDamage(0D); event.setCancelled(true); } } - if (!event.isCancelled() && bPlayer.hasElement(Element.EARTH) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.EARTH) && bPlayer.canUsePassive(Element.EARTH) && CoreAbility.getAbility(DensityShift.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(DensityShift.class))) { + if (bPlayer.hasElement(Element.EARTH) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.EARTH) && bPlayer.canUsePassive(Element.EARTH) && CoreAbility.getAbility(DensityShift.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(DensityShift.class))) { if (EarthPassive.softenLanding(player)) { event.setDamage(0D); event.setCancelled(true); } } - if (!event.isCancelled() && bPlayer.hasElement(Element.CHI) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.CHI) && bPlayer.canUsePassive(Element.CHI) && CoreAbility.getAbility(Acrobatics.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Acrobatics.class))) { + if (bPlayer.hasElement(Element.CHI) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.CHI) && bPlayer.canUsePassive(Element.CHI) && CoreAbility.getAbility(Acrobatics.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Acrobatics.class))) { double initdamage = event.getDamage(); double newdamage = event.getDamage() * ChiPassive.getFallReductionFactor(); double finaldamage = initdamage - newdamage; @@ -819,7 +856,7 @@ public class PKListener implements Listener { event.setCancelled(true); } - if (!event.isCancelled() && event.getCause() == DamageCause.FALL) { + if (event.getCause() == DamageCause.FALL) { Player source = Flight.getLaunchedBy(player); if (source == player) { event.setCancelled(true); @@ -835,7 +872,7 @@ public class PKListener implements Listener { event.setCancelled(true); } - if (!event.isCancelled() && CoreAbility.getAbility(player, EarthArmor.class) != null) { + if (CoreAbility.getAbility(player, EarthArmor.class) != null) { EarthArmor eartharmor = CoreAbility.getAbility(player, EarthArmor.class); eartharmor.updateAbsorbtion(); } @@ -866,12 +903,11 @@ public class PKListener implements Listener { if (entity instanceof Player) { Suffocate.remove((Player) entity); } - - Entity en = e.getEntity(); - if (en instanceof Player) { - if (e.getDamager() instanceof Player) { // This is the player hitting someone. - Player sourcePlayer = (Player) e.getDamager(); - Player targetPlayer = (Player) e.getEntity(); + + if (entity instanceof Player) { + if (source instanceof Player) { // This is the player hitting someone. + Player sourcePlayer = (Player) source; + Player targetPlayer = (Player) entity; BendingPlayer sourceBPlayer = BendingPlayer.getBendingPlayer(sourcePlayer); if (sourceBPlayer == null) { return; @@ -1110,8 +1146,13 @@ public class PKListener implements Listener { event.setCancelled(true); return; } + + else if (Lightning.isParalyzed(player)) { + event.setCancelled(true); + return; + } - else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class) || CoreAbility.hasAbility(player, SandSpout.class)) { + else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class) ) { Vector vel = new Vector(); vel.setX(event.getTo().getX() - event.getFrom().getX()); vel.setZ(event.getTo().getZ() - event.getFrom().getZ()); @@ -1127,20 +1168,31 @@ public class PKListener implements Listener { } else if (Bloodbending.isBloodbent(player)) { + BendingPlayer bender = Bloodbending.getBloodbender(player); + if (bender.isAvatarState()) { + event.setCancelled(true); + return; + } double distance1 = 0; double distance2 = 0; Location loc = Bloodbending.getBloodbendingLocation(player); - if (event.getPlayer().getWorld().equals(loc.getWorld())) { - distance1 = event.getFrom().distance(loc); - distance2 = event.getTo().distance(loc); + if (player.getWorld().equals(loc.getWorld())) { + distance1 = event.getFrom().distanceSquared(loc); + distance2 = event.getTo().distanceSquared(loc); } - if (distance2 > distance1) { - player.setVelocity(new Vector(0, 0, 0)); + + if (distance1 == 0 && distance2 == 0) { + return; + } else if (distance1 > distance2 || distance1 < distance2) { + if (!player.getVelocity().equals(Bloodbending.getBloodbendingVector(player))) { + player.setVelocity(Bloodbending.getBloodbendingVector(player)); + return; + } } } - else if (AirFlight.isFlying(event.getPlayer())) { - if (AirFlight.isHovering(event.getPlayer())) { + else if (AirFlight.isFlying(player)) { + if (AirFlight.isHovering(player)) { Location loc = event.getFrom(); Location toLoc = event.getTo(); @@ -1232,11 +1284,6 @@ public class PKListener implements Listener { return; } - if (CoreAbility.hasAbility(event.getPlayer(), AirScooter.class)) { - event.setCancelled(true); - return; - } - if (bPlayer.canCurrentlyBendWithWeapons()) { if (player.isSneaking()) { ComboManager.addComboAbility(player, ClickType.SHIFT_UP); @@ -1263,7 +1310,7 @@ public class PKListener implements Listener { BlockSource.update(player, ClickType.SHIFT_DOWN); } - if (CoreAbility.getAbility(FerroControl.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(FerroControl.class)) && !bPlayer.isOnCooldown("Hodor")) { + if (CoreAbility.getAbility(FerroControl.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(FerroControl.class)) && !bPlayer.isOnCooldown("FerroControl")) { if (event.isSneaking()) { Block block = player.getTargetBlock((HashSet) null, 5); if (block != null) { @@ -1278,7 +1325,7 @@ public class PKListener implements Listener { block.setData((byte) (block.getData() - 4)); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 10, 1); } - bPlayer.addCooldown("Hodor", 200); + bPlayer.addCooldown("FerroControl", 200); } } @@ -1393,10 +1440,10 @@ public class PKListener implements Listener { } else { clips.setControlling(true); } + } else { + new MetalClips(player, 1); } - } else { - new MetalClips(player, 1); - } + } } } @@ -1472,7 +1519,7 @@ public class PKListener implements Listener { if (Suffocate.isBreathbent(player)) { event.setCancelled(true); return; - } else if (Bloodbending.isBloodbent(player) || Paralyze.isParalyzed(player) || Immobilize.isParalyzed(player)) { + } else if ((Bloodbending.isBloodbent(player) && !bPlayer.getBoundAbilityName().equalsIgnoreCase("AvatarState")) || Paralyze.isParalyzed(player) || Immobilize.isParalyzed(player)) { event.setCancelled(true); return; } else if (bPlayer.isChiBlocked()) { @@ -1598,8 +1645,6 @@ public class PKListener implements Listener { new LavaFlow(player, AbilityType.CLICK); } else if (abil.equalsIgnoreCase("EarthSmash")) { new EarthSmash(player, ClickType.LEFT_CLICK); - } else if (abil.equalsIgnoreCase("SandSpout")) { - new SandSpout(player); } } } @@ -1665,7 +1710,6 @@ public class PKListener implements Listener { abil = MultiAbilityManager.getBoundMultiAbility(player); if (abil.equalsIgnoreCase("WaterArms")) { new WaterArms(player); - } } } @@ -1711,4 +1755,4 @@ public class PKListener implements Listener { public static Map getJumpStatistics() { return JUMPS; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/ProjectKorra.java b/src/com/projectkorra/projectkorra/ProjectKorra.java index 51df2ac2..eaaadea6 100644 --- a/src/com/projectkorra/projectkorra/ProjectKorra.java +++ b/src/com/projectkorra/projectkorra/ProjectKorra.java @@ -28,14 +28,13 @@ import com.projectkorra.projectkorra.util.Metrics; import com.projectkorra.projectkorra.util.RevertChecker; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.Updater; -import com.projectkorra.projectkorra.util.logging.PKLogHandler; import com.projectkorra.projectkorra.waterbending.util.WaterbendingManager; public class ProjectKorra extends JavaPlugin { public static ProjectKorra plugin; public static Logger log; - public static PKLogHandler handler; + //public static PKLogHandler handler; public static CollisionManager collisionManager; public static CollisionInitializer collisionInitializer; public static long time_step = 1; @@ -56,7 +55,7 @@ public class ProjectKorra extends JavaPlugin { new ConfigManager(); new GeneralMethods(this); - updater = new Updater(this, "http://projectkorra.com/forums/dev-builds.16/index.rss"); + updater = new Updater(this, "http://projectkorra.com/forum/forums/dev-builds.16/index.rss"); new Commands(this); new MultiAbilityManager(); new ComboManager(); @@ -173,8 +172,6 @@ public class ProjectKorra extends JavaPlugin { if (DBConnection.isOpen != false) { DBConnection.sql.close(); } - - handler.close(); } public static CollisionManager getCollisionManager() { diff --git a/src/com/projectkorra/projectkorra/ability/AirAbility.java b/src/com/projectkorra/projectkorra/ability/AirAbility.java index 2b0dbd86..1234c2ce 100644 --- a/src/com/projectkorra/projectkorra/ability/AirAbility.java +++ b/src/com/projectkorra/projectkorra/ability/AirAbility.java @@ -136,7 +136,10 @@ public abstract class AirAbility extends ElementalAbility { */ public static void playAirbendingSound(Location loc) { if (getConfig().getBoolean("Properties.Air.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Air.Sound")), 1, 10); + float volume = (float) getConfig().getDouble("Properties.Air.Sound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Air.Sound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Air.Sound.Sound")), volume, pitch); } } @@ -169,4 +172,4 @@ public abstract class AirAbility extends ElementalAbility { removeAirSpouts(loc, 1.5, source); } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/ability/AvatarAbility.java b/src/com/projectkorra/projectkorra/ability/AvatarAbility.java index 2a57beef..90581a1d 100644 --- a/src/com/projectkorra/projectkorra/ability/AvatarAbility.java +++ b/src/com/projectkorra/projectkorra/ability/AvatarAbility.java @@ -28,7 +28,12 @@ public abstract class AvatarAbility extends ElementalAbility { } public static void playAvatarSound(Location loc) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Abilities.Avatar.AvatarState.Sound")), 1, 10); + if (getConfig().getBoolean("Abilities.Avatar.AvatarState.PlaySound")) { + float volume = (float) getConfig().getDouble("Abilities.Avatar.AvatarState.Sound.Volume"); + float pitch = (float) getConfig().getDouble("Abilities.Avatar.AvatarState.Sound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Abilities.Avatar.AvatarState.Sound.Sound")), volume, pitch); + } } /** @@ -40,4 +45,4 @@ public abstract class AvatarAbility extends ElementalAbility { return true; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/ability/CoreAbility.java b/src/com/projectkorra/projectkorra/ability/CoreAbility.java index f4d218fa..5b43cc7b 100644 --- a/src/com/projectkorra/projectkorra/ability/CoreAbility.java +++ b/src/com/projectkorra/projectkorra/ability/CoreAbility.java @@ -68,6 +68,7 @@ public abstract class CoreAbility implements Ability { private static final Map ABILITIES_BY_NAME = new ConcurrentSkipListMap<>(); // preserves ordering private static final Map, CoreAbility> ABILITIES_BY_CLASS = new ConcurrentHashMap<>(); private static final double DEFAULT_COLLISION_RADIUS = 0.3; + private static final List ADDON_PLUGINS = new ArrayList<>(); private static int idCounter; @@ -222,8 +223,17 @@ public abstract class CoreAbility implements Ability { continue; } } - abil.progress(); - Bukkit.getServer().getPluginManager().callEvent(new AbilityProgressEvent(abil)); + try { + abil.progress(); + Bukkit.getServer().getPluginManager().callEvent(new AbilityProgressEvent(abil)); + } catch (Exception e) { + e.printStackTrace(); + try { + abil.remove(); + } catch (Exception re) { + re.printStackTrace(); + } + } } } } @@ -366,6 +376,16 @@ public abstract class CoreAbility implements Ability { } return abilities; } + + /** + * CoreAbility keeps track of plugins that have registered abilities + * to use for bending reload purposes + *
This isn't a simple list, external use isn't recommended + * @return a list of entrys with the plugin name and path abilities can be found at + */ + public static List getAddonPlugins() { + return ADDON_PLUGINS; + } /** * Returns true if the player has an active CoreAbility instance of type T. @@ -376,6 +396,25 @@ public abstract class CoreAbility implements Ability { public static boolean hasAbility(Player player, Class clazz) { return getAbility(player, clazz) != null; } + + /** + * Unloads the ability + * @param clazz Ability class to unload + */ + public static void unloadAbility(Class clazz) { + if (!ABILITIES_BY_CLASS.containsKey(clazz)) { + return; + } + String name = ABILITIES_BY_CLASS.get(clazz).getName(); + for (CoreAbility abil : INSTANCES) { + if (abil.getName() == name) { + abil.remove(); + } + } + ABILITIES_BY_CLASS.remove(clazz); + ABILITIES_BY_NAME.remove(name); + ProjectKorra.log.info("Unloaded ability: " + name); + } /** * Returns a Set of all of the players that currently have an active @@ -484,13 +523,6 @@ public abstract class CoreAbility implements Ability { if (ability instanceof PassiveAbility) { ability.setHiddenAbility(true); PassiveManager.getPassives().put(name, ability); - if (!PassiveManager.getPassivesByElement().containsKey(ability.getElement())) { - PassiveManager.getPassivesByElement().put(ability.getElement(), new HashSet()); - } - PassiveManager.getPassivesByElement().get(ability.getElement()).add(name); - if (ability.getElement() instanceof SubElement) { - PassiveManager.getPassivesByElement().get(((SubElement) ability.getElement()).getParentElement()).add(name); - } } if (ability instanceof AddonAbility) { @@ -521,9 +553,9 @@ public abstract class CoreAbility implements Ability { * @see #getAbility(String) */ public static void registerPluginAbilities(JavaPlugin plugin, String packageBase) { - AbilityLoader abilityLoader = new AbilityLoader(plugin, packageBase); List loadedAbilities = abilityLoader.load(CoreAbility.class, CoreAbility.class); + ADDON_PLUGINS.add(plugin.getName() + "::" + packageBase); for (CoreAbility coreAbil : loadedAbilities) { if (!coreAbil.isEnabled()) { @@ -559,13 +591,10 @@ public abstract class CoreAbility implements Ability { if (coreAbil instanceof PassiveAbility) { coreAbil.setHiddenAbility(true); PassiveManager.getPassives().put(name, coreAbil); - if (!PassiveManager.getPassivesByElement().containsKey(coreAbil.getElement())) { - PassiveManager.getPassivesByElement().put(coreAbil.getElement(), new HashSet()); - } - PassiveManager.getPassivesByElement().get(coreAbil.getElement()).add(name); - if (coreAbil.getElement() instanceof SubElement) { - PassiveManager.getPassivesByElement().get(((SubElement) coreAbil.getElement()).getParentElement()).add(name); + if (!PassiveManager.getPassiveClasses().containsKey((PassiveAbility)coreAbil)) { + PassiveManager.getPassiveClasses().put((PassiveAbility) coreAbil, coreAbil.getClass()); } + PassiveManager.getPassiveClasses().put((PassiveAbility) coreAbil, coreAbil.getClass()); } } catch (Exception | Error e) { @@ -631,12 +660,8 @@ public abstract class CoreAbility implements Ability { if (coreAbil instanceof PassiveAbility) { coreAbil.setHiddenAbility(true); PassiveManager.getPassives().put(name, coreAbil); - if (!PassiveManager.getPassivesByElement().containsKey(coreAbil.getElement())) { - PassiveManager.getPassivesByElement().put(coreAbil.getElement(), new HashSet()); - } - PassiveManager.getPassivesByElement().get(coreAbil.getElement()).add(name); - if (coreAbil.getElement() instanceof SubElement) { - PassiveManager.getPassivesByElement().get(((SubElement) coreAbil.getElement()).getParentElement()).add(name); + if (!PassiveManager.getPassiveClasses().containsKey((PassiveAbility)coreAbil)) { + PassiveManager.getPassiveClasses().put((PassiveAbility) coreAbil, coreAbil.getClass()); } } } @@ -899,4 +924,4 @@ public abstract class CoreAbility implements Ability { return DEFAULT_COLLISION_RADIUS; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/ability/EarthAbility.java b/src/com/projectkorra/projectkorra/ability/EarthAbility.java index cce54313..8b05d269 100644 --- a/src/com/projectkorra/projectkorra/ability/EarthAbility.java +++ b/src/com/projectkorra/projectkorra/ability/EarthAbility.java @@ -25,7 +25,6 @@ import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.earthbending.RaiseEarth; import com.projectkorra.projectkorra.earthbending.lava.LavaFlow; import com.projectkorra.projectkorra.earthbending.passive.EarthPassive; -import com.projectkorra.projectkorra.earthbending.sand.SandSpout; import com.projectkorra.projectkorra.firebending.Illumination; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.Information; @@ -92,8 +91,8 @@ public abstract class EarthAbility extends ElementalAbility { } } - public static boolean isEarthbendable(Material material) { - return isEarth(material) || isMetal(material) || isSand(material) || isLava(material); + public static boolean isEarthbendable(Material material, boolean metal, boolean sand, boolean lava) { + return isEarth(material) || (metal && isMetal(material)) || (sand && isSand(material)) || (lava && isLava(material)); } public boolean isEarthbendable(Block block) { @@ -304,7 +303,7 @@ public abstract class EarthAbility extends ElementalAbility { Block testBlock = player.getTargetBlock(getTransparentMaterialSet(), (int) range); if (bPlayer == null) { return null; - } else if (isEarthbendable(testBlock.getType())) { + } else if (isEarthbendable(testBlock.getType(), true, true, true)) { return testBlock; } else if (!isTransparent(player, testBlock)) { return null; @@ -390,7 +389,7 @@ public abstract class EarthAbility extends ElementalAbility { Location searchLoc = loc.clone().add(tracer); Block block = GeneralMethods.getTopBlock(searchLoc, maxVertical); - if (block != null && isEarthbendable(block.getType())) { + if (block != null && isEarthbendable(block.getType(), true, true, true)) { return block; } tracer = GeneralMethods.rotateXZ(tracer, rotation); @@ -422,7 +421,7 @@ public abstract class EarthAbility extends ElementalAbility { public static boolean isEarthbendable(Player player, String abilityName, Block block) { BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - if (bPlayer == null || !isEarthbendable(block.getType()) || PREVENT_EARTHBENDING.contains(block) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) { + if (bPlayer == null || !isEarthbendable(block.getType(), true, true, true) || PREVENT_EARTHBENDING.contains(block) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) { return false; } else if (isMetal(block) && !bPlayer.canMetalbend()) { return false; @@ -497,19 +496,36 @@ public abstract class EarthAbility extends ElementalAbility { public static void playEarthbendingSound(Location loc) { if (getConfig().getBoolean("Properties.Earth.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Earth.EarthSound")), 0, 10); + float volume = (float) getConfig().getDouble("Properties.Earth.EarthSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Earth.EarthSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Earth.EarthSound.Sound")), volume, pitch); } } public static void playMetalbendingSound(Location loc) { if (getConfig().getBoolean("Properties.Earth.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Earth.MetalSound")), 1, 10); + float volume = (float) getConfig().getDouble("Properties.Earth.MetalSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Earth.MetalSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Earth.MetalSound.Sound")), volume, pitch); } } - public static void playSandBendingSound(Location loc) { + public static void playSandbendingSound(Location loc) { if (getConfig().getBoolean("Properties.Earth.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Earth.SandSound")), 1.5f, 5); + float volume = (float) getConfig().getDouble("Properties.Earth.SandSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Earth.SandSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Earth.SandSound.Sound")), volume, pitch); + } + } + public static void playLavabendingSound(Location loc) { + if (getConfig().getBoolean("Properties.Earth.PlaySound")) { + float volume = (float) getConfig().getDouble("Properties.Earth.LavaSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Earth.LavaSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Earth.LavaSound.Sound")), volume, pitch); } } @@ -627,12 +643,4 @@ public abstract class EarthAbility extends ElementalAbility { removeAllEarthbendedBlocks(); } } - - public static void removeSandSpouts(Location loc, double radius, Player source) { - SandSpout.removeSpouts(loc, radius, source); - } - - public static void removeSandSpouts(Location loc, Player source) { - removeSandSpouts(loc, 1.5, source); - } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/ability/FireAbility.java b/src/com/projectkorra/projectkorra/ability/FireAbility.java index ad138e86..b7935e85 100644 --- a/src/com/projectkorra/projectkorra/ability/FireAbility.java +++ b/src/com/projectkorra/projectkorra/ability/FireAbility.java @@ -157,7 +157,10 @@ public abstract class FireAbility extends ElementalAbility { public static void playCombustionSound(Location loc) { if (getConfig().getBoolean("Properties.Fire.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Fire.CombustionSound")), 1, -1); + float volume = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Fire.CombustionSound.Sound")), volume, pitch); } } @@ -167,7 +170,10 @@ public abstract class FireAbility extends ElementalAbility { public static void playFirebendingSound(Location loc) { if (getConfig().getBoolean("Properties.Fire.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Fire.FireSound")), 1, 10); + float volume = (float) getConfig().getDouble("Properties.Fire.FireSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Fire.FireSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Fire.FireSound.Sound")), volume, pitch); } } @@ -181,6 +187,15 @@ public abstract class FireAbility extends ElementalAbility { loc.setZ(loc.getZ() + Math.random() * (zOffset / 2 - -(zOffset / 2))); GeneralMethods.displayColoredParticle(loc, "#01E1FF"); } + + public static void playLightningbendingSound(Location loc) { + if (getConfig().getBoolean("Properties.Fire.PlaySound")) { + float volume = (float) getConfig().getDouble("Properties.Fire.LightningSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Fire.LightningSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Fire.LightningSound.Sound")), volume, pitch); + } + } /** Removes all temp fire that no longer needs to be there */ public static void removeFire() { @@ -226,4 +241,4 @@ public abstract class FireAbility extends ElementalAbility { } } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/ability/WaterAbility.java b/src/com/projectkorra/projectkorra/ability/WaterAbility.java index 900f93a1..0e91ec36 100644 --- a/src/com/projectkorra/projectkorra/ability/WaterAbility.java +++ b/src/com/projectkorra/projectkorra/ability/WaterAbility.java @@ -301,19 +301,28 @@ public abstract class WaterAbility extends ElementalAbility { public static void playIcebendingSound(Location loc) { if (getConfig().getBoolean("Properties.Water.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Water.IceSound")), 2, 10); + float volume = (float) getConfig().getDouble("Properties.Water.IceSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Water.IceSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Water.IceSound.Sound")), volume, pitch); } } public static void playPlantbendingSound(Location loc) { if (getConfig().getBoolean("Properties.Water.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Water.PlantSound")), 1, 10); + float volume = (float) getConfig().getDouble("Properties.Water.PlantSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Water.PlantSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Water.PlantSound.Sound")), volume, pitch); } } public static void playWaterbendingSound(Location loc) { if (getConfig().getBoolean("Properties.Water.PlaySound")) { - loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Water.WaterSound")), 1, 10); + float volume = (float) getConfig().getDouble("Properties.Water.WaterSound.Volume"); + float pitch = (float) getConfig().getDouble("Properties.Water.WaterSound.Pitch"); + + loc.getWorld().playSound(loc, Sound.valueOf(getConfig().getString("Properties.Water.WaterSound.Sound")), volume, pitch); } } @@ -351,4 +360,4 @@ public abstract class WaterAbility extends ElementalAbility { SurgeWave.removeAllCleanup(); WaterArms.removeAllCleanup(); } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/ability/util/CollisionInitializer.java b/src/com/projectkorra/projectkorra/ability/util/CollisionInitializer.java index 026b7eea..bed404af 100644 --- a/src/com/projectkorra/projectkorra/ability/util/CollisionInitializer.java +++ b/src/com/projectkorra/projectkorra/ability/util/CollisionInitializer.java @@ -24,7 +24,6 @@ import com.projectkorra.projectkorra.earthbending.EarthTunnel; import com.projectkorra.projectkorra.earthbending.RaiseEarth; import com.projectkorra.projectkorra.earthbending.Ripple; import com.projectkorra.projectkorra.earthbending.lava.LavaFlow; -import com.projectkorra.projectkorra.earthbending.sand.SandSpout; import com.projectkorra.projectkorra.firebending.BlazeArc; import com.projectkorra.projectkorra.firebending.FireBlast; import com.projectkorra.projectkorra.firebending.FireBlastCharged; @@ -101,7 +100,6 @@ public class CollisionInitializer { CoreAbility lavaFlow = CoreAbility.getAbility(LavaFlow.class); CoreAbility raiseEarth = CoreAbility.getAbility(RaiseEarth.class); CoreAbility ripple = CoreAbility.getAbility(Ripple.class); - CoreAbility sandSpout = CoreAbility.getAbility(SandSpout.class); CoreAbility blazeArc = CoreAbility.getAbility(BlazeArc.class); CoreAbility combustion = CoreAbility.getAbility(Combustion.class); @@ -246,7 +244,6 @@ public class CollisionInitializer { removeSpoutAbilities.add(ability); collisionManager.addCollision(new Collision(ability, CoreAbility.getAbility(AirSpout.class), false, true)); collisionManager.addCollision(new Collision(ability, CoreAbility.getAbility(WaterSpout.class), false, true)); - collisionManager.addCollision(new Collision(ability, CoreAbility.getAbility(SandSpout.class), false, true)); } public CollisionManager getCollisionManager() { diff --git a/src/com/projectkorra/projectkorra/ability/util/CollisionManager.java b/src/com/projectkorra/projectkorra/ability/util/CollisionManager.java index f8b10bf2..ac3cb413 100644 --- a/src/com/projectkorra/projectkorra/ability/util/CollisionManager.java +++ b/src/com/projectkorra/projectkorra/ability/util/CollisionManager.java @@ -67,15 +67,20 @@ public class CollisionManager { } private void detectCollisions() { - List instances = new ArrayList<>(); + int activeInstanceCount = 0; + for (CoreAbility ability : CoreAbility.getAbilitiesByInstances()) { if (!(ability instanceof PassiveAbility)) { - instances.add(ability); + if (++activeInstanceCount > 1) { + break; + } } } - if (instances.size() <= 1) { + + if (activeInstanceCount <= 1) { return; } + HashMap> locationsCache = new HashMap<>(); for (Collision collision : collisions) { @@ -137,7 +142,7 @@ public class CollisionManager { } if (locationFirst.getWorld() != locationSecond.getWorld()) { - return; + continue; } double distSquared = locationFirst.distanceSquared(locationSecond); if (distSquared <= requiredDistSquared) { @@ -252,4 +257,4 @@ public class CollisionManager { this.detectionRunnable = detectionRunnable; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/ability/util/PassiveManager.java b/src/com/projectkorra/projectkorra/ability/util/PassiveManager.java index ca6399a5..b5ac6e87 100644 --- a/src/com/projectkorra/projectkorra/ability/util/PassiveManager.java +++ b/src/com/projectkorra/projectkorra/ability/util/PassiveManager.java @@ -18,7 +18,7 @@ import com.projectkorra.projectkorra.ability.PassiveAbility; public class PassiveManager { private static final Map PASSIVES = new HashMap<>(); - private static final Map> PASSIVES_BY_ELEMENT = new HashMap<>(); // Parent elements INCLUDE subelement passives. + private static final Map> PASSIVE_CLASSES = new HashMap<>(); public static void registerPassives(Player player) { BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); @@ -40,28 +40,15 @@ public class PassiveManager { } else if (!((PassiveAbility) ability).isInstantiable()) { continue; } - Class clazz = null; try { - clazz = Class.forName(ability.getClass().getName()); + Class clazz = PASSIVE_CLASSES.get((PassiveAbility) ability); + Constructor constructor = clazz.getConstructor(Player.class); + Object object = constructor.newInstance(new Object[] { player }); + ((CoreAbility) object).start(); } - catch (ClassNotFoundException e) { + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); } - Constructor constructor = null; - try { - constructor = clazz.getConstructor(Player.class); - } - catch (NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } - Object object = null; - try { - object = constructor.newInstance(new Object[] { player }); - } - catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } - ((CoreAbility) object).start(); } } } @@ -94,18 +81,26 @@ public class PassiveManager { } public static Set getPassivesForElement(Element element) { - if (PASSIVES_BY_ELEMENT.get(element) == null) { - return new HashSet<>(); + Set passives = new HashSet<>(); + for (CoreAbility passive : PASSIVES.values()) { + if (passive.getElement() == element) { + passives.add(passive.getName()); + } else if (passive.getElement() instanceof SubElement) { + Element check = ((SubElement)passive.getElement()).getParentElement(); + if (check == element) { + passives.add(passive.getName()); + } + } } - return PASSIVES_BY_ELEMENT.get(element); + return passives; } public static Map getPassives() { return PASSIVES; } - public static Map> getPassivesByElement() { - return PASSIVES_BY_ELEMENT; + public static Map> getPassiveClasses() { + return PASSIVE_CLASSES; } } diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java index 7f711fa1..74d534ab 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java @@ -32,6 +32,7 @@ import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.Flight; +import com.projectkorra.projectkorra.util.TempBlock; public class AirBlast extends AirAbility { @@ -400,9 +401,9 @@ public class AirBlast extends AirAbility { if ((GeneralMethods.isSolid(block) || block.isLiquid()) && !affectedLevers.contains(block) && canCoolLava) { if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) { if (block.getData() == 0x0) { - block.setType(Material.OBSIDIAN); + new TempBlock(block, Material.OBSIDIAN, (byte) 0); } else { - block.setType(Material.COBBLESTONE); + new TempBlock(block, Material.COBBLESTONE, (byte)0); } } remove(); diff --git a/src/com/projectkorra/projectkorra/airbending/AirScooter.java b/src/com/projectkorra/projectkorra/airbending/AirScooter.java index 7e6b1a85..8027febe 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirScooter.java +++ b/src/com/projectkorra/projectkorra/airbending/AirScooter.java @@ -112,6 +112,12 @@ public class AirScooter extends AirAbility { return; } + if (player.isSneaking()) { + bPlayer.addCooldown(this); + remove(); + return; + } + Vector velocity = player.getEyeLocation().getDirection().clone().normalize(); velocity = velocity.clone().normalize().multiply(speed); /* @@ -131,9 +137,9 @@ public class AirScooter extends AirAbility { double distance = player.getLocation().getY() - (double) floorblock.getY(); double dx = Math.abs(distance - 2.4); if (distance > 2.75) { - velocity.setY(-.40 * dx * dx); + velocity.setY(-.25 * dx * dx); } else if (distance < 2) { - velocity.setY(.40 * dx * dx); + velocity.setY(.25 * dx * dx); } else { velocity.setY(0); } @@ -143,7 +149,7 @@ public class AirScooter extends AirAbility { if (!GeneralMethods.isSolid(b) && !b.isLiquid()) { velocity.add(new Vector(0, -0.6, 0)); } else if (GeneralMethods.isSolid(b.getRelative(BlockFace.UP)) || b.getRelative(BlockFace.UP).isLiquid()) { - velocity.add(new Vector(0, 0.6, 0)); + velocity.add(new Vector(0, 1.0, 0)); } Location loc = player.getLocation(); diff --git a/src/com/projectkorra/projectkorra/airbending/AirShield.java b/src/com/projectkorra/projectkorra/airbending/AirShield.java index 03e90784..4c7e23d5 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirShield.java +++ b/src/com/projectkorra/projectkorra/airbending/AirShield.java @@ -29,16 +29,18 @@ public class AirShield extends AirAbility { @Attribute(Attribute.SPEED) private double speed; private int streams; + private long cooldown; private int particles; private Random random; private HashMap angles; public AirShield(Player player) { super(player); - + this.maxRadius = getConfig().getDouble("Abilities.Air.AirShield.Radius"); this.isToggledByAvatarState = getConfig().getBoolean("Abilities.Avatar.AvatarState.Air.AirShield.IsAvatarStateToggle"); this.radius = this.maxRadius; + this.cooldown = getConfig().getLong("Abilities.Air.AirShield.Cooldown"); this.speed = getConfig().getDouble("Abilities.Air.AirShield.Speed"); this.streams = getConfig().getInt("Abilities.Air.AirShield.Streams"); this.particles = getConfig().getInt("Abilities.Air.AirShield.Particles"); @@ -59,7 +61,7 @@ public class AirShield extends AirAbility { angle = 0; } } - + start(); } @@ -87,6 +89,7 @@ public class AirShield extends AirAbility { return; } else if (!bPlayer.isAvatarState() || !isToggledByAvatarState) { if (!player.isSneaking() || !bPlayer.canBend(this)) { + bPlayer.addCooldown(this); remove(); return; } @@ -187,7 +190,7 @@ public class AirShield extends AirAbility { @Override public long getCooldown() { - return 0; + return cooldown; } @Override diff --git a/src/com/projectkorra/projectkorra/airbending/AirSpout.java b/src/com/projectkorra/projectkorra/airbending/AirSpout.java index e5e8c326..70fd50db 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSpout.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSpout.java @@ -42,7 +42,7 @@ public class AirSpout extends AirAbility { } this.angle = 0; - this.cooldown = 0; + this.cooldown = getConfig().getLong("Abilities.Air.AirSpout.Cooldown"); this.animTime = System.currentTimeMillis(); this.interval = getConfig().getLong("Abilities.Air.AirSpout.Interval"); this.height = getConfig().getDouble("Abilities.Air.AirSpout.Height"); @@ -59,7 +59,6 @@ public class AirSpout extends AirAbility { } start(); - bPlayer.addCooldown(this); } /** @@ -118,7 +117,7 @@ public class AirSpout extends AirAbility { @Override public void progress() { - if (player.isDead() || !player.isOnline() || !bPlayer.canBendIgnoreBindsCooldowns(this) || !bPlayer.canBind(this)) { + if (player.isDead() || !player.isOnline() || !bPlayer.canBendIgnoreBinds(this) || !bPlayer.canBind(this)) { remove(); return; } @@ -129,10 +128,6 @@ public class AirSpout extends AirAbility { return; } - if (!bPlayer.canBind(this)) { - remove(); - return; - } Block eyeBlock = player.getEyeLocation().getBlock(); if (eyeBlock.isLiquid() || GeneralMethods.isSolid(eyeBlock)) { @@ -155,7 +150,7 @@ public class AirSpout extends AirAbility { allowFlight(); } rotateAirColumn(block); - } else { + } else { remove(); } } @@ -163,6 +158,7 @@ public class AirSpout extends AirAbility { public void remove() { super.remove(); removeFlight(); + bPlayer.addCooldown(this); } private void removeFlight() { diff --git a/src/com/projectkorra/projectkorra/airbending/Tornado.java b/src/com/projectkorra/projectkorra/airbending/Tornado.java index ee605440..a89c084f 100644 --- a/src/com/projectkorra/projectkorra/airbending/Tornado.java +++ b/src/com/projectkorra/projectkorra/airbending/Tornado.java @@ -18,7 +18,8 @@ import java.util.Random; import java.util.concurrent.ConcurrentHashMap; public class Tornado extends AirAbility { - + + private long cooldown; private int numberOfStreams; private int particleCount; @Attribute(Attribute.SPEED) @@ -42,7 +43,8 @@ public class Tornado extends AirAbility { public Tornado(Player player) { super(player); - + + this.cooldown = getConfig().getLong("Abilities.Air.Tornado.Cooldown"); this.range = getConfig().getDouble("Abilities.Air.Tornado.Range"); this.origin = player.getTargetBlock((HashSet) null, (int) range).getLocation(); this.origin.setY(origin.getY() - 1.0 / 10.0 * currentHeight); @@ -66,6 +68,7 @@ public class Tornado extends AirAbility { } } + this.flight = new Flight(player); this.couldFly = player.getAllowFlight(); player.setAllowFlight(true); @@ -75,6 +78,7 @@ public class Tornado extends AirAbility { @Override public void progress() { if (player.getEyeLocation().getBlock().isLiquid() || !player.isSneaking() || !bPlayer.canBendIgnoreCooldowns(this)) { + bPlayer.addCooldown(this); remove(); return; } else if (GeneralMethods.isRegionProtectedFromBuild(this, origin)) { @@ -203,7 +207,7 @@ public class Tornado extends AirAbility { @Override public long getCooldown() { - return 0; + return cooldown; } @Override diff --git a/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java b/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java index 7c72b269..d1930509 100644 --- a/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java +++ b/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java @@ -14,7 +14,6 @@ import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; -import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.util.Flight; @@ -50,17 +49,17 @@ public class AirStream extends AirAbility implements ComboAbility { return; } - this.range = getConfig().getDouble("Abilities.Air.AirCombo.AirStream.Range"); - this.speed = getConfig().getDouble("Abilities.Air.AirCombo.AirStream.Speed"); - this.cooldown = getConfig().getLong("Abilities.Air.AirCombo.AirStream.Cooldown"); - this.airStreamMaxEntityHeight = getConfig().getDouble("Abilities.Air.AirCombo.AirStream.EntityHeight"); - this.airStreamEntityCarryDuration = getConfig().getLong("Abilities.Air.AirCombo.AirStream.EntityDuration"); + this.range = getConfig().getDouble("Abilities.Air.AirStream.Range"); + this.speed = getConfig().getDouble("Abilities.Air.AirStream.Speed"); + this.cooldown = getConfig().getLong("Abilities.Air.AirStream.Cooldown"); + this.airStreamMaxEntityHeight = getConfig().getDouble("Abilities.Air.AirStream.EntityHeight"); + this.airStreamEntityCarryDuration = getConfig().getLong("Abilities.Air.AirStream.EntityDuration"); if (bPlayer.isAvatarState()) { this.cooldown = 0; - this.range = AvatarState.getValue(range); - this.airStreamMaxEntityHeight = AvatarState.getValue(airStreamMaxEntityHeight); - this.airStreamEntityCarryDuration = AvatarState.getValue(airStreamEntityCarryDuration); + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.Range"); + this.airStreamMaxEntityHeight = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.EntityHeight"); + this.airStreamEntityCarryDuration = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.EntityDuration"); } bPlayer.addCooldown(this); @@ -302,4 +301,4 @@ public class AirStream extends AirAbility implements ComboAbility { public void setCooldown(long cooldown) { this.cooldown = cooldown; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java b/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java index f9e3ade0..fbddbaf0 100644 --- a/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java +++ b/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java @@ -17,7 +17,6 @@ import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; -import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.firebending.combo.FireComboStream; import com.projectkorra.projectkorra.util.DamageHandler; @@ -55,17 +54,17 @@ public class AirSweep extends AirAbility implements ComboAbility { return; } - this.damage = getConfig().getDouble("Abilities.Air.AirCombo.AirSweep.Damage"); - this.range = getConfig().getDouble("Abilities.Air.AirCombo.AirSweep.Range"); - this.speed = getConfig().getDouble("Abilities.Air.AirCombo.AirSweep.Speed"); - this.knockback = getConfig().getDouble("Abilities.Air.AirCombo.AirSweep.Knockback"); - this.cooldown = getConfig().getLong("Abilities.Air.AirCombo.AirSweep.Cooldown"); + this.damage = getConfig().getDouble("Abilities.Air.AirSweep.Damage"); + this.range = getConfig().getDouble("Abilities.Air.AirSweep.Range"); + this.speed = getConfig().getDouble("Abilities.Air.AirSweep.Speed"); + this.knockback = getConfig().getDouble("Abilities.Air.AirSweep.Knockback"); + this.cooldown = getConfig().getLong("Abilities.Air.AirSweep.Cooldown"); if (bPlayer.isAvatarState()) { this.cooldown = 0; - this.damage = AvatarState.getValue(damage); - this.range = AvatarState.getValue(range); - this.knockback = knockback * 1.4; + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Damage"); + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Range"); + this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Knockback"); } bPlayer.addCooldown(this); @@ -329,4 +328,4 @@ public class AirSweep extends AirAbility implements ComboAbility { public void setTasks(ArrayList tasks) { this.tasks = tasks; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/airbending/combo/Twister.java b/src/com/projectkorra/projectkorra/airbending/combo/Twister.java index d1d04557..79291bba 100644 --- a/src/com/projectkorra/projectkorra/airbending/combo/Twister.java +++ b/src/com/projectkorra/projectkorra/airbending/combo/Twister.java @@ -13,7 +13,6 @@ import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; -import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.command.Commands; public class Twister extends AirAbility implements ComboAbility { @@ -30,10 +29,6 @@ public class Twister extends AirAbility implements ComboAbility { private double speed; @Attribute(Attribute.RANGE) private double range; - @Attribute(Attribute.POWER) - private double knockback; - private double airStreamMaxEntityHeight; - private double airStreamEntityCarryDuration; @Attribute(Attribute.HEIGHT) private double twisterHeight; @Attribute(Attribute.RADIUS) @@ -61,22 +56,19 @@ public class Twister extends AirAbility implements ComboAbility { return; } - this.range = getConfig().getDouble("Abilities.Air.AirCombo.Twister.Range"); - this.speed = getConfig().getDouble("Abilities.Air.AirCombo.Twister.Speed"); - this.cooldown = getConfig().getLong("Abilities.Air.AirCombo.Twister.Cooldown"); - this.twisterHeight = getConfig().getDouble("Abilities.Air.AirCombo.Twister.Height"); - this.twisterRadius = getConfig().getDouble("Abilities.Air.AirCombo.Twister.Radius"); - this.twisterDegreeParticles = getConfig().getDouble("Abilities.Air.AirCombo.Twister.DegreesPerParticle"); - this.twisterHeightParticles = getConfig().getDouble("Abilities.Air.AirCombo.Twister.HeightPerParticle"); - this.twisterRemoveDelay = getConfig().getLong("Abilities.Air.AirCombo.Twister.RemoveDelay"); + this.range = getConfig().getDouble("Abilities.Air.Twister.Range"); + this.speed = getConfig().getDouble("Abilities.Air.Twister.Speed"); + this.cooldown = getConfig().getLong("Abilities.Air.Twister.Cooldown"); + this.twisterHeight = getConfig().getDouble("Abilities.Air.Twister.Height"); + this.twisterRadius = getConfig().getDouble("Abilities.Air.Twister.Radius"); + this.twisterDegreeParticles = getConfig().getDouble("Abilities.Air.Twister.DegreesPerParticle"); + this.twisterHeightParticles = getConfig().getDouble("Abilities.Air.Twister.HeightPerParticle"); + this.twisterRemoveDelay = getConfig().getLong("Abilities.Air.Twister.RemoveDelay"); if (bPlayer.isAvatarState()) { this.cooldown = 0; - this.damage = AvatarState.getValue(damage); - this.range = AvatarState.getValue(range); - this.knockback = knockback * 1.4; - this.airStreamMaxEntityHeight = AvatarState.getValue(airStreamMaxEntityHeight); - this.airStreamEntityCarryDuration = AvatarState.getValue(airStreamEntityCarryDuration); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Twister.Damage"); + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Twister.Range"); } bPlayer.addCooldown(this); @@ -195,4 +187,4 @@ public class Twister extends AirAbility implements ComboAbility { public ArrayList getCombination() { return null; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/airbending/flight/AirFlight.java b/src/com/projectkorra/projectkorra/airbending/flight/AirFlight.java index 5dce2d28..07a07c57 100644 --- a/src/com/projectkorra/projectkorra/airbending/flight/AirFlight.java +++ b/src/com/projectkorra/projectkorra/airbending/flight/AirFlight.java @@ -109,9 +109,13 @@ public class AirFlight extends FlightAbility { remove(); return; } else if (!player.isSneaking() && !isHovering && !firstProgressIteration) { + bPlayer.addCooldown(this); remove(); return; - } else if (player.getLocation().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR) { + } else if (player.getLocation().subtract(0, 0.4, 0).getBlock().getType() != Material.AIR) { + if (!firstProgressIteration) { + bPlayer.addCooldown(this); + } remove(); return; } else if (System.currentTimeMillis() - getStartTime() > maxDuration && maxDuration > 0) { diff --git a/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java b/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java index 710cc966..54266f52 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java +++ b/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java @@ -12,6 +12,7 @@ import com.projectkorra.projectkorra.ability.ChiAbility; public class AcrobatStance extends ChiAbility { + private long cooldown; private int speed; private int jump; private double chiBlockBoost; @@ -22,7 +23,7 @@ public class AcrobatStance extends ChiAbility { if (!bPlayer.canBend(this)) { return; } - + this.cooldown = getConfig().getLong("Abilities.Chi.AcrobatStance.Cooldown"); this.speed = getConfig().getInt("Abilities.Chi.AcrobatStance.Speed") + 1; this.jump = getConfig().getInt("Abilities.Chi.AcrobatStance.Jump") + 1; this.chiBlockBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ChiBlockBoost"); @@ -46,7 +47,7 @@ public class AcrobatStance extends ChiAbility { @Override public void progress() { - if (!bPlayer.canBendIgnoreBindsCooldowns(this) || !bPlayer.hasElement(Element.CHI)) { + if (!bPlayer.canBendIgnoreBinds(this) || !bPlayer.hasElement(Element.CHI)) { remove(); return; } @@ -62,6 +63,7 @@ public class AcrobatStance extends ChiAbility { @Override public void remove() { super.remove(); + bPlayer.addCooldown(this); bPlayer.setStance(null); GeneralMethods.displayMovePreview(player); player.playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_SHOOT, 0.5F, 2F); @@ -81,7 +83,7 @@ public class AcrobatStance extends ChiAbility { @Override public long getCooldown() { - return 0; + return cooldown; } @Override diff --git a/src/com/projectkorra/projectkorra/chiblocking/RapidPunch.java b/src/com/projectkorra/projectkorra/chiblocking/RapidPunch.java index 07e358a8..8581fe53 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/RapidPunch.java +++ b/src/com/projectkorra/projectkorra/chiblocking/RapidPunch.java @@ -40,6 +40,7 @@ public class RapidPunch extends ChiAbility { @Override public void progress() { if (numPunches >= punches || target == null || !(target instanceof LivingEntity)) { + bPlayer.addCooldown(this); remove(); return; } @@ -57,7 +58,6 @@ public class RapidPunch extends ChiAbility { } lt.setNoDamageTicks(0); - bPlayer.addCooldown(this); numPunches++; } diff --git a/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java b/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java index a729cd96..76c01676 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java +++ b/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java @@ -12,6 +12,7 @@ import com.projectkorra.projectkorra.ability.ChiAbility; public class WarriorStance extends ChiAbility { + private long cooldown; private int strength; private int resistance; @@ -20,6 +21,7 @@ public class WarriorStance extends ChiAbility { if (!bPlayer.canBend(this)) { return; } + this.cooldown = getConfig().getLong("Abilities.Chi.WarriorStance.Cooldown"); this.strength = getConfig().getInt("Abilities.Chi.WarriorStance.Strength") - 1; this.resistance = getConfig().getInt("Abilities.Chi.WarriorStance.Resistance"); @@ -41,7 +43,7 @@ public class WarriorStance extends ChiAbility { @Override public void progress() { - if (!bPlayer.canBendIgnoreBindsCooldowns(this) || !bPlayer.hasElement(Element.CHI)) { + if (!bPlayer.canBendIgnoreBinds(this) || !bPlayer.hasElement(Element.CHI)) { remove(); return; } @@ -57,6 +59,7 @@ public class WarriorStance extends ChiAbility { @Override public void remove() { super.remove(); + bPlayer.addCooldown(this); bPlayer.setStance(null); GeneralMethods.displayMovePreview(player); player.playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_SHOOT, 0.5F, 2F); @@ -76,7 +79,7 @@ public class WarriorStance extends ChiAbility { @Override public long getCooldown() { - return 0; + return cooldown; } @Override diff --git a/src/com/projectkorra/projectkorra/command/AddCommand.java b/src/com/projectkorra/projectkorra/command/AddCommand.java index 4b301e7b..ea0a22d5 100644 --- a/src/com/projectkorra/projectkorra/command/AddCommand.java +++ b/src/com/projectkorra/projectkorra/command/AddCommand.java @@ -107,8 +107,8 @@ public class AddCommand extends PKCommand { bPlayer.addElement(e); if (elements.length() > 1) - elements.append(","); - elements.append(e.getName()); + elements.append(ChatColor.YELLOW + ", "); + elements.append(e.getColor() + e.getName()); bPlayer.getSubElements().clear(); for (SubElement sub : Element.getAllSubElements()) { @@ -146,6 +146,14 @@ public class AddCommand extends PKCommand { e = SubElement.fromString(element); } + if (e == Element.AVATAR) { + add(sender, target, Element.AIR.getName()); + add(sender, target, Element.EARTH.getName()); + add(sender, target, Element.FIRE.getName()); + add(sender, target, Element.WATER.getName()); + return; + } + //if it's an element: if (Arrays.asList(Element.getAllElements()).contains(e)) { if (bPlayer.hasElement(e)) { // if already had, determine who to send the error message to @@ -267,4 +275,4 @@ public class AddCommand extends PKCommand { } return l; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/command/BindCommand.java b/src/com/projectkorra/projectkorra/command/BindCommand.java index 82284b6b..cddd8aff 100644 --- a/src/com/projectkorra/projectkorra/command/BindCommand.java +++ b/src/com/projectkorra/projectkorra/command/BindCommand.java @@ -52,10 +52,10 @@ public class BindCommand extends PKCommand { } CoreAbility coreAbil = CoreAbility.getAbility(args.get(0)); - if (coreAbil == null || coreAbil.isHiddenAbility() || !coreAbil.isEnabled()) { + if (coreAbil == null || !coreAbil.isEnabled()) { GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + abilityDoesntExist.replace("{ability}", args.get(0))); return; - } else if (coreAbil instanceof PassiveAbility || coreAbil instanceof ComboAbility) { + } else if (coreAbil instanceof PassiveAbility || coreAbil instanceof ComboAbility || coreAbil.isHiddenAbility()) { GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + unbindable.replace("{ability}", args.get(0))); return; } @@ -123,7 +123,7 @@ public class BindCommand extends PKCommand { if (args.size() == 0) { if (bPlayer != null) { for (CoreAbility coreAbil : CoreAbility.getAbilities()) { - if (!coreAbil.isHiddenAbility() && bPlayer.canBind(coreAbil)) { + if (!coreAbil.isHiddenAbility() && bPlayer.canBind(coreAbil) && !(coreAbil instanceof PassiveAbility && coreAbil instanceof ComboAbility) && !abilities.contains(coreAbil.getName())) { abilities.add(coreAbil.getName()); } } @@ -135,4 +135,4 @@ public class BindCommand extends PKCommand { Collections.sort(abilities); return abilities; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/command/DisplayCommand.java b/src/com/projectkorra/projectkorra/command/DisplayCommand.java index bd59acf9..b595da00 100644 --- a/src/com/projectkorra/projectkorra/command/DisplayCommand.java +++ b/src/com/projectkorra/projectkorra/command/DisplayCommand.java @@ -14,6 +14,8 @@ import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element.SubElement; import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ability.AddonAbility; +import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.SubAbility; import com.projectkorra.projectkorra.ability.util.ComboManager; @@ -80,10 +82,12 @@ public class DisplayCommand extends PKCommand { //combos if (elementName.contains("combo")) { if (element == null) { + sender.sendMessage(ChatColor.BOLD + "Combos"); + for (Element e : Element.getAllElements()) { ChatColor color = e != null ? e.getColor() : null; ArrayList combos = ComboManager.getCombosForElement(e); - + for (String comboAbil : combos) { ChatColor comboColor = color; if (!sender.hasPermission("bending.ability." + comboAbil)) { @@ -94,7 +98,13 @@ public class DisplayCommand extends PKCommand { if (coreAbil != null) { comboColor = coreAbil.getElement().getColor(); } - sender.sendMessage(comboColor + comboAbil); + String message = (comboColor + comboAbil); + + if (coreAbil instanceof AddonAbility) { + message += ChatColor.WHITE + (ChatColor.BOLD + "*"); + } + + sender.sendMessage(message); } } return; @@ -106,6 +116,9 @@ public class DisplayCommand extends PKCommand { GeneralMethods.sendBrandingMessage(sender, color + noCombosAvailable.replace("{element}", element.getName())); return; } + + sender.sendMessage(element.getColor() + (ChatColor.BOLD + element.getName()) + element.getType().getBending() + ChatColor.WHITE + (ChatColor.BOLD + " Combos")); + for (String comboMove : combos) { ChatColor comboColor = color; if (!sender.hasPermission("bending.ability." + comboMove)) { @@ -116,17 +129,26 @@ public class DisplayCommand extends PKCommand { if (coreAbil != null) { comboColor = coreAbil.getElement().getColor(); } - sender.sendMessage(comboColor + comboMove); + + String message = (comboColor + comboMove); + + if (coreAbil instanceof AddonAbility) { + message += ChatColor.WHITE + (ChatColor.BOLD + "*"); + } + + sender.sendMessage(message); } return; } //passives } else if (elementName.contains("passive")) { if (element == null) { + sender.sendMessage(ChatColor.BOLD + "Passives"); + for (Element e : Element.getAllElements()) { ChatColor color = e != null ? e.getColor() : null; Set passives = PassiveManager.getPassivesForElement(e); - + for (String passiveAbil : passives) { ChatColor passiveColor = color; if (!sender.hasPermission("bending.ability." + passiveAbil)) { @@ -137,7 +159,13 @@ public class DisplayCommand extends PKCommand { if (coreAbil != null) { passiveColor = coreAbil.getElement().getColor(); } - sender.sendMessage(passiveColor + passiveAbil); + String message = (passiveColor + passiveAbil); + + if (coreAbil instanceof AddonAbility) { + message += ChatColor.WHITE + (ChatColor.BOLD + "*"); + } + + sender.sendMessage(message); } } return; @@ -149,6 +177,9 @@ public class DisplayCommand extends PKCommand { GeneralMethods.sendBrandingMessage(sender, color + noPassivesAvailable.replace("{element}", element.getName())); return; } + + sender.sendMessage(element.getColor() + (ChatColor.BOLD + element.getName()) + element.getType().getBending() + ChatColor.WHITE + (ChatColor.BOLD + " Passives")); + for (String passiveAbil : passives) { ChatColor passiveColor = color; if (!sender.hasPermission("bending.ability." + passiveAbil)) { @@ -163,14 +194,10 @@ public class DisplayCommand extends PKCommand { } return; } else if (element != null) { - if (!element.equals(Element.AVATAR)) { - if (!(element instanceof SubElement)) { - displayElement(sender, element); - } else { - displaySubElement(sender, (SubElement) element); - } + if (!(element instanceof SubElement)) { + displayElement(sender, element); } else { - displayAvatar(sender); + displaySubElement(sender, (SubElement) element); } } @@ -200,29 +227,6 @@ public class DisplayCommand extends PKCommand { } } - private void displayAvatar(CommandSender sender) { - List abilities = CoreAbility.getAbilitiesByElement(Element.AVATAR); - if (abilities.isEmpty()) { - sender.sendMessage(ChatColor.YELLOW + noAbilitiesAvailable.replace("{element}", Element.AVATAR.getColor() + "Avatar" + ChatColor.YELLOW)); - return; - } - HashSet abilitiesSent = new HashSet(); //Some abilities have the same name. This prevents this from showing anything. - for (CoreAbility ability : abilities) { - if (ability.isHiddenAbility() || abilitiesSent.contains(ability.getName())) { - continue; - } - if (sender instanceof Player) { - if (GeneralMethods.canView((Player) sender, ability.getName())) { - sender.sendMessage(ability.getElement().getColor() + ability.getName()); - abilitiesSent.add(ability.getName()); - } - } else { - sender.sendMessage(ability.getElement().getColor() + ability.getName()); - abilitiesSent.add(ability.getName()); - } - } - } - /** * Displays the enabled moves for the given element to the CommandSender. * @@ -233,19 +237,25 @@ public class DisplayCommand extends PKCommand { List abilities = CoreAbility.getAbilitiesByElement(element); if (abilities.isEmpty()) { - sender.sendMessage(ChatColor.RED + invalidArgument); - return; - } else if (abilities.isEmpty()) { sender.sendMessage(ChatColor.YELLOW + noAbilitiesAvailable.replace("{element}", element.getColor() + element.getName() + ChatColor.YELLOW)); + return; } + sender.sendMessage(element.getColor() + (ChatColor.BOLD + element.getName()) + element.getType().getBending()); + HashSet abilitiesSent = new HashSet(); //Some abilities have the same name. This prevents this from showing anything. for (CoreAbility ability : abilities) { - if (ability instanceof SubAbility || ability.isHiddenAbility() || abilitiesSent.contains(ability.getName())) { + if (ability instanceof SubAbility || ability instanceof ComboAbility || ability.isHiddenAbility() || abilitiesSent.contains(ability.getName())) { continue; } + if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability.getName())) { - sender.sendMessage(ability.getElement().getColor() + ability.getName()); + String message = ability.getElement().getColor()+ ability.getName(); + if (ability instanceof AddonAbility) { + message += ChatColor.WHITE + (ChatColor.BOLD + "*"); + } + + sender.sendMessage(message); abilitiesSent.add(ability.getName()); } } @@ -278,12 +288,19 @@ public class DisplayCommand extends PKCommand { return; } + sender.sendMessage(element.getColor() + (ChatColor.BOLD + element.getName()) + element.getType().getBending()); + HashSet abilitiesSent = new HashSet(); for (CoreAbility ability : abilities) { if (ability.isHiddenAbility() || abilitiesSent.contains(ability.getName())) { continue; } else if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability.getName())) { - sender.sendMessage(element.getColor() + ability.getName()); + String message = element.getColor() + ability.getName(); + if (ability instanceof AddonAbility) { + message += ChatColor.WHITE + (ChatColor.BOLD + "*"); + } + + sender.sendMessage(message); abilitiesSent.add(ability.getName()); } } @@ -308,11 +325,20 @@ public class DisplayCommand extends PKCommand { return; } + sender.sendMessage(ChatColor.WHITE + (ChatColor.BOLD + "Abilities")); + for (int i = 1; i <= 9; i++) { String ability = abilities.get(i); CoreAbility coreAbil = CoreAbility.getAbility(ability); - if (coreAbil != null && !ability.equalsIgnoreCase("null")) - sender.sendMessage(i + " - " + coreAbil.getElement().getColor() + ability); + if (coreAbil != null && !ability.equalsIgnoreCase("null")) { + String message = i + ". " + coreAbil.getElement().getColor() + ability; + + if (coreAbil instanceof AddonAbility) { + message += ChatColor.WHITE + (ChatColor.BOLD + "*"); + } + + sender.sendMessage(message); + } } } diff --git a/src/com/projectkorra/projectkorra/command/HelpCommand.java b/src/com/projectkorra/projectkorra/command/HelpCommand.java index d83cc5ba..f9021ac4 100644 --- a/src/com/projectkorra/projectkorra/command/HelpCommand.java +++ b/src/com/projectkorra/projectkorra/command/HelpCommand.java @@ -10,9 +10,9 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.projectkorra.items.command.PKICommand; -import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ability.AddonAbility; import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.PassiveAbility; @@ -55,6 +55,8 @@ public class HelpCommand extends PKCommand { @Override public void execute(CommandSender sender, List args) { + boolean firstMessage = true; + if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 1)) return; else if (args.size() == 0) { @@ -83,13 +85,20 @@ public class HelpCommand extends PKCommand { Collections.reverse(strings); strings.add(instances.get("help").getProperUse()); Collections.reverse(strings); + for (String s : getPage(strings, ChatColor.GOLD + "Commands: <" + required + "> [" + optional + "]", 1, false)) { - sender.sendMessage(ChatColor.YELLOW + s); + if (firstMessage) { + GeneralMethods.sendBrandingMessage(sender, s); + firstMessage = false; + } else { + sender.sendMessage(ChatColor.YELLOW + s); + } } return; } String arg = args.get(0).toLowerCase(); + if (isNumeric(arg)) { List strings = new ArrayList(); for (PKCommand command : instances.values()) { @@ -111,9 +120,14 @@ public class HelpCommand extends PKCommand { //spirits commands being added (if needed) } for (String s : getPage(strings, ChatColor.GOLD + "Commands: <" + required + "> [" + optional + "]", Integer.valueOf(arg), true)) { - sender.sendMessage(ChatColor.YELLOW + s); + if (firstMessage) { + GeneralMethods.sendBrandingMessage(sender, s); + firstMessage = false; + } else { + sender.sendMessage(ChatColor.YELLOW + s); + } } - } else if (instances.keySet().contains(arg.toLowerCase())) {//bending help command + } else if (instances.keySet().contains(arg)) {//bending help command instances.get(arg).help(sender, true); } else if (Arrays.asList(Commands.comboaliases).contains(arg)) { //bending help elementcombo sender.sendMessage(ChatColor.GOLD + properUsage.replace("{command1}", ChatColor.RED + "/bending display " + arg + ChatColor.GOLD).replace("{command2}", ChatColor.RED + "/bending help " + ChatColor.GOLD)); @@ -122,57 +136,100 @@ public class HelpCommand extends PKCommand { } else if (CoreAbility.getAbility(arg) != null && !(CoreAbility.getAbility(arg) instanceof ComboAbility) && CoreAbility.getAbility(arg).isEnabled() && !CoreAbility.getAbility(arg).isHiddenAbility() || CoreAbility.getAbility(arg) instanceof PassiveAbility) { //bending help ability CoreAbility ability = CoreAbility.getAbility(arg); ChatColor color = ability.getElement().getColor(); - sender.sendMessage(color + ability.getName() + " - "); - sender.sendMessage(color + ability.getDescription()); - if (!ability.getInstructions().isEmpty()) { - sender.sendMessage(ChatColor.GOLD + usage + ability.getInstructions()); + + if (ability instanceof AddonAbility) { + if (ability instanceof PassiveAbility) { + sender.sendMessage(color + (ChatColor.BOLD + ability.getName()) + ChatColor.WHITE + " (Addon Passive)"); + } else { + sender.sendMessage(color + (ChatColor.BOLD + ability.getName()) + ChatColor.WHITE + " (Addon)"); + } + + sender.sendMessage(color + ability.getDescription()); + + if (!ability.getInstructions().isEmpty()) { + sender.sendMessage(ChatColor.GOLD + usage + ability.getInstructions()); + } + + AddonAbility abil = (AddonAbility) CoreAbility.getAbility(arg); + sender.sendMessage(color + "- By: " + ChatColor.WHITE + abil.getAuthor()); + sender.sendMessage(color + "- Version: " + ChatColor.WHITE + abil.getVersion()); + } else { + if (ability instanceof PassiveAbility) { + sender.sendMessage(color + (ChatColor.BOLD + ability.getName()) + ChatColor.WHITE + " (Passive)"); + } else { + sender.sendMessage(color + (ChatColor.BOLD + ability.getName())); + } + + sender.sendMessage(color + ability.getDescription()); + + if (!ability.getInstructions().isEmpty()) { + sender.sendMessage(ChatColor.GOLD + usage + ability.getInstructions()); + } } - } else if (Arrays.asList(Commands.airaliases).contains(args.get(0))) { + } else if (Arrays.asList(Commands.airaliases).contains(arg)) { sender.sendMessage(Element.AIR.getColor() + air.replace("/b help AirCombos", Element.AIR.getSubColor() + "/b help AirCombos" + Element.AIR.getColor())); - sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://tinyurl.com/qffg9m3"); - } else if (Arrays.asList(Commands.wateraliases).contains(args.get(0))) { + sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://projectkorra.com/"); + } else if (Arrays.asList(Commands.wateraliases).contains(arg)) { sender.sendMessage(Element.WATER.getColor() + water.replace("/b help WaterCombos", Element.WATER.getSubColor() + "/b h WaterCombos" + Element.WATER.getColor())); - sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://tinyurl.com/lod3plv"); - } else if (Arrays.asList(Commands.earthaliases).contains(args.get(0))) { + sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://projectkorra.com/"); + } else if (Arrays.asList(Commands.earthaliases).contains(arg)) { sender.sendMessage(Element.EARTH.getColor() + earth); - sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://tinyurl.com/qaudl42"); - } else if (Arrays.asList(Commands.firealiases).contains(args.get(0))) { + sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://projectkorra.com/"); + } else if (Arrays.asList(Commands.firealiases).contains(arg)) { sender.sendMessage(Element.FIRE.getColor() + fire.replace("/b h FireCombos", Element.FIRE.getSubColor() + "/b h FireCombos" + Element.FIRE.getColor())); - sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://tinyurl.com/k4fkjhb"); - } else if (Arrays.asList(Commands.chialiases).contains(args.get(0))) { + sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://projectkorra.com/"); + } else if (Arrays.asList(Commands.chialiases).contains(arg)) { sender.sendMessage(Element.CHI.getColor() + chi.replace("/b h ChiCombos", Element.CHI.getSubColor() + "/b h ChiCombos" + Element.CHI.getColor())); - sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://tinyurl.com/mkp9n6y"); + sender.sendMessage(ChatColor.YELLOW + learnMore + ChatColor.DARK_AQUA + "http://projectkorra.com/"); } else { //combos - handled differently because they're stored in CamelCase in ComboManager for (String combo : ComboManager.getDescriptions().keySet()) { - if (combo.equalsIgnoreCase(arg)) { - CoreAbility coreAbility = CoreAbility.getAbility(combo); - ChatColor color = coreAbility != null ? coreAbility.getElement().getColor() : null; - sender.sendMessage(color + combo + " (Combo) - "); - sender.sendMessage(color + ComboManager.getDescriptions().get(combo)); - sender.sendMessage(ChatColor.GOLD + usage + ComboManager.getInstructions().get(combo)); + if (combo.equalsIgnoreCase(arg)) { + CoreAbility ability = CoreAbility.getAbility(combo); + ChatColor color = ability != null ? ability.getElement().getColor() : null; + + if (ability instanceof AddonAbility) { + sender.sendMessage(color + (ChatColor.BOLD + ability.getName()) + ChatColor.WHITE + " (Addon Combo)"); + sender.sendMessage(color + ability.getDescription()); + + if (!ability.getInstructions().isEmpty()) { + sender.sendMessage(ChatColor.GOLD + usage + ability.getInstructions()); + } + + AddonAbility abil = (AddonAbility) CoreAbility.getAbility(arg); + sender.sendMessage(color + "- By: " + ChatColor.WHITE + abil.getAuthor()); + sender.sendMessage(color + "- Version: " + ChatColor.WHITE + abil.getVersion()); + } else { + sender.sendMessage(color + (ChatColor.BOLD + ability.getName()) + ChatColor.WHITE + " (Combo)"); + sender.sendMessage(color + ComboManager.getDescriptions().get(combo)); + sender.sendMessage(ChatColor.GOLD + usage + ComboManager.getInstructions().get(combo)); + } + return; } } + sender.sendMessage(ChatColor.RED + invalidTopic); } } @Override protected List getTabCompletion(CommandSender sender, List args) { - if (args.size() >= 1 || !sender.hasPermission("bending.command.help")) + if (args.size() >= 1 || !sender.hasPermission("bending.command.help")) { return new ArrayList(); + } + List list = new ArrayList(); for (Element e : Element.getAllElements()) { list.add(e.getName()); } + List abils = new ArrayList(); for (CoreAbility coreAbil : CoreAbility.getAbilities()) { - if (!(sender instanceof Player) && (!coreAbil.isHiddenAbility() || coreAbil instanceof ComboAbility) && coreAbil.isEnabled()) { + if (!(sender instanceof Player) && (!coreAbil.isHiddenAbility()) && coreAbil.isEnabled() && !abils.contains(coreAbil.getName())) { abils.add(coreAbil.getName()); } else if (sender instanceof Player) { - BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName()); - if (bPlayer.canBind(coreAbil) || ((coreAbil instanceof ComboAbility) && bPlayer.hasElement(coreAbil.getElement()))) { + if ((!coreAbil.isHiddenAbility()) && coreAbil.isEnabled() && !abils.contains(coreAbil.getName())) { abils.add(coreAbil.getName()); } } diff --git a/src/com/projectkorra/projectkorra/command/PKCommand.java b/src/com/projectkorra/projectkorra/command/PKCommand.java index 81282bb6..ec856449 100644 --- a/src/com/projectkorra/projectkorra/command/PKCommand.java +++ b/src/com/projectkorra/projectkorra/command/PKCommand.java @@ -234,7 +234,7 @@ public abstract class PKCommand implements SubCommand { page = 1; } } - strings.add(ChatColor.GOLD + "ProjectKorra " + ChatColor.DARK_GRAY + "- [" + ChatColor.GRAY + page + "/" + (int) Math.ceil((entries.size() + .0) / (8 + .0)) + ChatColor.DARK_GRAY + "]"); + strings.add(ChatColor.DARK_GRAY + "- [" + ChatColor.GRAY + page + "/" + (int) Math.ceil((entries.size() + .0) / (8 + .0)) + ChatColor.DARK_GRAY + "]"); strings.add(title); if (entries.size() > ((page * 8) - 8)) { for (int i = ((page * 8) - 8); i < entries.size(); i++) { diff --git a/src/com/projectkorra/projectkorra/command/RemoveCommand.java b/src/com/projectkorra/projectkorra/command/RemoveCommand.java index ff5f01d6..c44aaea1 100644 --- a/src/com/projectkorra/projectkorra/command/RemoveCommand.java +++ b/src/com/projectkorra/projectkorra/command/RemoveCommand.java @@ -73,6 +73,7 @@ public class RemoveCommand extends PKCommand { senderBPlayer.getSubElements().remove(sub); } GeneralMethods.saveElements(senderBPlayer); + GeneralMethods.saveSubElements(senderBPlayer); GeneralMethods.removeUnusableAbilities(sender.getName()); GeneralMethods.sendBrandingMessage(sender, e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending())); @@ -115,7 +116,11 @@ public class RemoveCommand extends PKCommand { GeneralMethods.saveSubElements(bPlayer); } else { bPlayer.getElements().remove(e); + for (SubElement sub : SubElement.getSubElements(e)) { + bPlayer.getSubElements().remove(sub); + } GeneralMethods.saveElements(bPlayer); + GeneralMethods.saveSubElements(bPlayer); } GeneralMethods.removeUnusableAbilities(player.getName()); diff --git a/src/com/projectkorra/projectkorra/command/ToggleCommand.java b/src/com/projectkorra/projectkorra/command/ToggleCommand.java index 04ef1da8..38a12497 100644 --- a/src/com/projectkorra/projectkorra/command/ToggleCommand.java +++ b/src/com/projectkorra/projectkorra/command/ToggleCommand.java @@ -1,11 +1,8 @@ package com.projectkorra.projectkorra.command; -import com.projectkorra.projectkorra.BendingPlayer; -import com.projectkorra.projectkorra.Element; -import com.projectkorra.projectkorra.Element.SubElement; -import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.util.PassiveManager; -import com.projectkorra.projectkorra.configuration.ConfigManager; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -13,9 +10,11 @@ import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import com.projectkorra.projectkorra.BendingPlayer; +import com.projectkorra.projectkorra.Element; +import com.projectkorra.projectkorra.Element.SubElement; +import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.configuration.ConfigManager; /** * Executor for /bending toggle. Extends {@link PKCommand}. @@ -83,11 +82,10 @@ public class ToggleCommand extends PKCommand { Commands.isToggledForAll = false; for (Player player : Bukkit.getOnlinePlayers()) { GeneralMethods.sendBrandingMessage(player, ChatColor.GREEN + toggleOnAll); - PassiveManager.registerPassives(player); // TODO: This is a temporary fix. Passives currently need to be re-registered in multiple places. } if (!(sender instanceof Player)) GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + toggleOnAll); - + } else { Commands.isToggledForAll = true; for (Player player : Bukkit.getOnlinePlayers()) { @@ -114,7 +112,7 @@ public class ToggleCommand extends PKCommand { } else { help(sender, false); } - + } else if (sender instanceof Player && args.size() == 2 && Element.fromString(args.get(0)) != null && !(Element.fromString(args.get(0)) instanceof SubElement)) { Player target = Bukkit.getPlayer(args.get(1)); if (!hasAdminPermission(sender)) @@ -172,4 +170,4 @@ public class ToggleCommand extends PKCommand { } return l; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/command/VersionCommand.java b/src/com/projectkorra/projectkorra/command/VersionCommand.java index 8101a905..bae277c2 100644 --- a/src/com/projectkorra/projectkorra/command/VersionCommand.java +++ b/src/com/projectkorra/projectkorra/command/VersionCommand.java @@ -24,7 +24,7 @@ public class VersionCommand extends PKCommand { return; } - sender.sendMessage(ChatColor.GREEN + "Core Version: " + ChatColor.RED + ProjectKorra.plugin.getDescription().getVersion() + " (MC 1.10)"); + sender.sendMessage(ChatColor.GREEN + "Core Version: " + ChatColor.RED + ProjectKorra.plugin.getDescription().getVersion()); if (GeneralMethods.hasRPG()) { sender.sendMessage(ChatColor.GREEN + "RPG Version: " + ChatColor.RED + GeneralMethods.getRPG().getDescription().getVersion()); } diff --git a/src/com/projectkorra/projectkorra/command/WhoCommand.java b/src/com/projectkorra/projectkorra/command/WhoCommand.java index 5c75ce70..a4259172 100644 --- a/src/com/projectkorra/projectkorra/command/WhoCommand.java +++ b/src/com/projectkorra/projectkorra/command/WhoCommand.java @@ -130,8 +130,15 @@ public class WhoCommand extends PKCommand { if (players.isEmpty()) { GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + noPlayersOnline); } else { + boolean firstMessage = true; + for (String s : getPage(players, ChatColor.GOLD + "Players:", page, true)) { - sender.sendMessage(s); + if (firstMessage) { + GeneralMethods.sendBrandingMessage(sender, s); + firstMessage = false; + } else { + sender.sendMessage(s); + } } } } @@ -189,7 +196,7 @@ public class WhoCommand extends PKCommand { bPlayer = BendingPlayer.getBendingPlayer(player); if (bPlayer != null) { - sender.sendMessage(player.getName() + (!player.isOnline() ? ChatColor.RESET + " (Offline)" : "") + " - "); + sender.sendMessage(player.getName() + (!player.isOnline() ? ChatColor.RESET + " (Offline)" : "")); if (bPlayer.hasElement(Element.AIR)) { if (bPlayer.isElementToggled(Element.AIR)) { sender.sendMessage(Element.AIR.getColor() + "- Airbender"); @@ -211,6 +218,7 @@ public class WhoCommand extends PKCommand { } } } + if (bPlayer.hasElement(Element.WATER)) { if (bPlayer.isElementToggled(Element.WATER)) { sender.sendMessage(Element.WATER.getColor() + "- Waterbender"); @@ -242,6 +250,7 @@ public class WhoCommand extends PKCommand { } } } + if (bPlayer.hasElement(Element.EARTH)) { if (bPlayer.isElementToggled(Element.EARTH)) { sender.sendMessage(Element.EARTH.getColor() + "- Earthbender"); @@ -266,6 +275,7 @@ public class WhoCommand extends PKCommand { } } } + if (bPlayer.hasElement(Element.FIRE)) { if (bPlayer.isElementToggled(Element.FIRE)) { sender.sendMessage(Element.FIRE.getColor() + "- Firebender"); @@ -287,6 +297,7 @@ public class WhoCommand extends PKCommand { } } } + if (bPlayer.hasElement(Element.CHI)) { if (bPlayer.isElementToggled(Element.CHI)) { sender.sendMessage(Element.CHI.getColor() + "- Chiblocker"); @@ -294,6 +305,7 @@ public class WhoCommand extends PKCommand { sender.sendMessage(Element.CHI.getColor() + "" + ChatColor.STRIKETHROUGH + "- Chiblocker"); } } + for (Element element : Element.getAddonElements()) { if (bPlayer.hasElement(element)) { sender.sendMessage(element.getColor() + "" + (bPlayer.isElementToggled(element) ? "" : ChatColor.STRIKETHROUGH) + "- " + element.getName() + (element.getType() != null ? element.getType().getBender() : "")); @@ -344,6 +356,11 @@ public class WhoCommand extends PKCommand { if (staff.containsKey(uuid.toString())) { sender.sendMessage(staff.get(uuid.toString())); } + + if (player_.hasPermission("bending.donor")) { + // Requires Servers to define `server-name` in their server.properties file. Example: server-name=My Server + sender.sendMessage(Element.AVATAR.getColor() + ProjectKorra.plugin.getServer().getServerName() + " Donor"); + } } } diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index a03a1a31..7c6b7fdb 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -163,7 +163,7 @@ public class ConfigManager { config.addDefault("Commands.Help.Required", "Required"); config.addDefault("Commands.Help.Optional", "Optional"); config.addDefault("Commands.Help.ProperUsage", "Proper Usage: {command1} or {command2}"); - config.addDefault("Commands.Help.Elements.LearnMore", "Learn more: "); + config.addDefault("Commands.Help.Elements.LearnMore", "Learn more at our website! "); config.addDefault("Commands.Help.InvalidTopic", "That isn't a valid help topic. Use /bending help for more information."); config.addDefault("Commands.Help.Usage", "Usage: "); @@ -347,8 +347,6 @@ public class ConfigManager { config.addDefault("Abilities.Earth.Shockwave.Description", "Shockwave is one of the most powerful earthbending abilities. It allows the earthbender to deal mass damage to everyone around them and knock them back. It's extremely useful when fighting more than one target or if you're surrounded by mobs."); config.addDefault("Abilities.Earth.Shockwave.Instructions", "Hold sneak until you see particles and then release sneak to send a wave of earth outwards, damaging and knocking entities back that it collides with. Additionally, instead of releasing sneak you can send a cone of earth forwards by left clicking. If you are on the Shockwave slot and you fall from a great height, your Shockwave will automatically activate."); config.addDefault("Abilities.Earth.Shockwave.DeathMessage", "{victim} was blown away by {attacker}'s {ability}"); - config.addDefault("Abilities.Earth.SandSpout.Description", "SandSpout is a core move for travelling, evasion, and mobility for sandbenders. It's extremely useful to gain a height advantage."); - config.addDefault("Abilities.Earth.Sandspout.Instructions", "This ability will only work while you are on a sand block. Simply left click to create a sand spout underneath you. Then, hold spacebar to raise yourself upwards or hold sneak to go downwards. Left click again to disable this ability."); 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.Instructions", "Simply left click while on an earthbendable block."); config.addDefault("Abilities.Earth.Passive.DensityShift.Description", "DensityShift is a passive ability which allows earthbenders to make a firm landing negating all fall damage on any earthbendable surface."); @@ -444,6 +442,9 @@ public class ConfigManager { earthBlocks.add("GRASS_PATH"); ArrayList metalBlocks = new ArrayList(); + metalBlocks.add("IRON_ORE"); + metalBlocks.add("GOLD_ORE"); + metalBlocks.add("QUARTZ_ORE"); metalBlocks.add("IRON_BLOCK"); metalBlocks.add("GOLD_BLOCK"); metalBlocks.add("QUARTZ_BLOCK"); @@ -514,7 +515,9 @@ public class ConfigManager { config.addDefault("Properties.Air.CanBendWithWeapons", false); config.addDefault("Properties.Air.Particles", "spell"); config.addDefault("Properties.Air.PlaySound", true); - config.addDefault("Properties.Air.Sound", "ENTITY_CREEPER_HURT"); + config.addDefault("Properties.Air.Sound.Sound", "ENTITY_CREEPER_HURT"); + config.addDefault("Properties.Air.Sound.Volume", 1); + config.addDefault("Properties.Air.Sound.Pitch", 2); config.addDefault("Properties.Water.CanBendWithWeapons", true); config.addDefault("Properties.Water.IceBlocks", iceBlocks); @@ -523,9 +526,15 @@ public class ConfigManager { config.addDefault("Properties.Water.NightFactor", 1.5); config.addDefault("Properties.Water.FullMoonFactor", 1.75); config.addDefault("Properties.Water.PlaySound", true); - config.addDefault("Properties.Water.WaterSound", "BLOCK_WATER_AMBIENT"); - config.addDefault("Properties.Water.IceSound", "ITEM_FLINTANDSTEEL_USE"); - config.addDefault("Properties.Water.PlantSound", "BLOCK_GRASS_STEP"); + config.addDefault("Properties.Water.WaterSound.Sound", "BLOCK_WATER_AMBIENT"); + config.addDefault("Properties.Water.WaterSound.Volume", 1); + config.addDefault("Properties.Water.WaterSound.Pitch", 1); + config.addDefault("Properties.Water.IceSound.Sound", "ITEM_FLINTANDSTEEL_USE"); + config.addDefault("Properties.Water.IceSound.Volume", 1); + config.addDefault("Properties.Water.IceSound.Pitch", 1); + config.addDefault("Properties.Water.PlantSound.Sound", "BLOCK_GRASS_STEP"); + config.addDefault("Properties.Water.IceSound.Volume", 1); + config.addDefault("Properties.Water.IceSound.Pitch", 1); config.addDefault("Properties.Earth.RevertEarthbending", true); config.addDefault("Properties.Earth.SafeRevert", true); @@ -536,18 +545,34 @@ public class ConfigManager { config.addDefault("Properties.Earth.SandBlocks", sandBlocks); config.addDefault("Properties.Earth.MetalPowerFactor", 1.5); config.addDefault("Properties.Earth.PlaySound", true); - config.addDefault("Properties.Earth.EarthSound", "ENTITY_GHAST_SHOOT"); - config.addDefault("Properties.Earth.MetalSound", "ENTITY_IRONGOLEM_HURT"); - config.addDefault("Properties.Earth.SandSound", "BLOCK_SAND_BREAK"); + config.addDefault("Properties.Earth.EarthSound.Sound", "ENTITY_GHAST_SHOOT"); + config.addDefault("Properties.Earth.EarthSound.Volume", 1); + config.addDefault("Properties.Earth.EarthSound.Pitch", 1); + config.addDefault("Properties.Earth.MetalSound.Sound", "ENTITY_IRONGOLEM_HURT"); + config.addDefault("Properties.Earth.MetalSound.Volume", 1); + config.addDefault("Properties.Earth.MetalSound.Pitch", 1.25); + config.addDefault("Properties.Earth.SandSound.Sound", "BLOCK_SAND_BREAK"); + config.addDefault("Properties.Earth.SandSound.Volume", 1); + config.addDefault("Properties.Earth.SandSound.Pitch", 1); + config.addDefault("Properties.Earth.LavaSound.Sound", "LIQUID_LAVA"); + config.addDefault("Properties.Earth.LavaSound.Volume", 1); + config.addDefault("Properties.Earth.LavaSound.Pitch", 1); config.addDefault("Properties.Fire.CanBendWithWeapons", true); config.addDefault("Properties.Fire.DayFactor", 1.25); config.addDefault("Properties.Fire.PlaySound", true); config.addDefault("Properties.Fire.FireGriefing", false); config.addDefault("Properties.Fire.RevertTicks", 12000L); - config.addDefault("Properties.Fire.FireSound", "BLOCK_FIRE_AMBIENT"); - config.addDefault("Properties.Fire.CombustionSound", "ENTITY_FIREWORK_BLAST"); - + config.addDefault("Properties.Fire.FireSound.Sound", "BLOCK_FIRE_AMBIENT"); + config.addDefault("Properties.Fire.FireSound.Volume", 1); + config.addDefault("Properties.Fire.FireSound.Pitch", 1); + config.addDefault("Properties.Fire.CombustionSound.Sound", "ENTITY_FIREWORK_BLAST"); + config.addDefault("Properties.Fire.CombustionSound.Volume", 1); + config.addDefault("Properties.Fire.CombustionSound.Pitch", 0); + config.addDefault("Properties.Fire.LightningSound.Sound", "ENTITY_CREEPER_HURT"); + config.addDefault("Properties.Fire.LightningSound.Volume", 1); + config.addDefault("Properties.Fire.LightningSound.Pitch", 0); + config.addDefault("Properties.Chi.CanBendWithWeapons", true); ArrayList disabledWorlds = new ArrayList(); @@ -567,7 +592,10 @@ public class ConfigManager { config.addDefault("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Enabled", true); config.addDefault("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Power", 3); config.addDefault("Abilities.Avatar.AvatarState.PowerMultiplier", 2); - config.addDefault("Abilities.Avatar.AvatarState.Sound", "BLOCK_ANVIL_LAND"); + config.addDefault("Abilities.Avatar.AvatarState.PlaySound", true); + config.addDefault("Abilities.Avatar.AvatarState.Sound.Sound", "BLOCK_ANVIL_LAND"); + config.addDefault("Abilities.Avatar.AvatarState.Sound.Volume", 1); + config.addDefault("Abilities.Avatar.AvatarState.Sound.Pitch", 1.5); config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities", 4.5); config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self", 4.0); @@ -583,6 +611,14 @@ public class ConfigManager { config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.ChargeTime", 1000); config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.Damage", 3); config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.Range", 16); + config.addDefault("Abilities.Avatar.AvatarState.Air.AirStream.Range", 60); + config.addDefault("Abilities.Avatar.AvatarState.Air.AirStream.EntityHeight", 21); + config.addDefault("Abilities.Avatar.AvatarState.Air.AirStream.EntityDuration", 6000); + config.addDefault("Abilities.Avatar.AvatarState.Air.AirSweep.Damage", 6); + config.addDefault("Abilities.Avatar.AvatarState.Air.AirSweep.Range", 21); + config.addDefault("Abilities.Avatar.AvatarState.Air.AirSweep.Knockback", 4); + config.addDefault("Abilities.Avatar.AvatarState.Air.Twister.Range", 24); + config.addDefault("Abilities.Avatar.AvatarState.Air.Twister.Height", 12); config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.MaxDistance", 80); config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown", 0); @@ -595,17 +631,18 @@ public class ConfigManager { config.addDefault("Abilities.Avatar.AvatarState.Earth.MetalClips.Cooldown", 2000); config.addDefault("Abilities.Avatar.AvatarState.Earth.MetalClips.Range", 20); config.addDefault("Abilities.Avatar.AvatarState.Earth.MetalClips.CrushDamage", 3); - config.addDefault("Abilities.Avatar.AvatarState.Earth.RaiseEarth.Column.Height", 20); - config.addDefault("Abilities.Avatar.AvatarState.Earth.RaiseEarth.Wall.Height", 16); - config.addDefault("Abilities.Avatar.AvatarState.Earth.RaiseEarth.Wall.Width", 16); - config.addDefault("Abilities.Avatar.AvatarState.Earth.Collapse.Column.Height", 20); - config.addDefault("Abilities.Avatar.AvatarState.Earth.Collapse.Wall.Height", 20); + config.addDefault("Abilities.Avatar.AvatarState.Earth.RaiseEarth.Column.Height", 8); + config.addDefault("Abilities.Avatar.AvatarState.Earth.RaiseEarth.Wall.Height", 8); + config.addDefault("Abilities.Avatar.AvatarState.Earth.RaiseEarth.Wall.Width", 8); + config.addDefault("Abilities.Avatar.AvatarState.Earth.Collapse.Column.Height", 12); + config.addDefault("Abilities.Avatar.AvatarState.Earth.Collapse.Wall.Height", 12); config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthArmor.Cooldown", 2000); config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthArmor.GoldHearts", 6); config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthBlast.Cooldown", 500); config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthBlast.Damage", 5); config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthGrab.Cooldown", 0); - config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthGrab.Height", 10); + config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthGrab.Height", 6); + config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthGrab.Radius", 6); config.addDefault("Abilities.Avatar.AvatarState.Earth.Shockwave.Range", 20); config.addDefault("Abilities.Avatar.AvatarState.Earth.Shockwave.Cooldown", 0); config.addDefault("Abilities.Avatar.AvatarState.Earth.Shockwave.ChargeTime", 1500); @@ -632,10 +669,56 @@ public class ConfigManager { config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBurst.Cooldown", 0); config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBlast.Charged.ChargeTime", 1500); config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBlast.Charged.Damage", 5); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireKick.Damage", 5); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireKick.Range", 9); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireSpin.Damage", 5); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireSpin.Range", 9); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireSpin.Knockback", 3); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireWheel.Damage", 5); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireWheel.Range", 13); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireWheel.Height", 3); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireWheel.Speed", 0.75); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireWheel.FireTicks", 4); + config.addDefault("Abilities.Avatar.AvatarState.Fire.FireWheel.Radius", 1.5); + config.addDefault("Abilities.Avatar.AvatarState.Fire.WallOfFire.Height", 6); + config.addDefault("Abilities.Avatar.AvatarState.Fire.WallOfFire.Width", 6); + config.addDefault("Abilities.Avatar.AvatarState.Fire.WallOfFire.Duration", 8000); + config.addDefault("Abilities.Avatar.AvatarState.Fire.WallOfFire.Damage", 2); + config.addDefault("Abilities.Avatar.AvatarState.Fire.WallOfFire.FireTicks", 2); + config.addDefault("Abilities.Avatar.AvatarState.Water.OctopusForm.AttackRange", 3); + config.addDefault("Abilities.Avatar.AvatarState.Water.OctopusForm.Radius", 4); + config.addDefault("Abilities.Avatar.AvatarState.Water.OctopusForm.Damage", 4); + config.addDefault("Abilities.Avatar.AvatarState.Water.OctopusForm.Knockback", 2); config.addDefault("Abilities.Avatar.AvatarState.Water.Surge.Wall.Radius", 4); config.addDefault("Abilities.Avatar.AvatarState.Water.Surge.Wave.Radius", 20); + config.addDefault("Abilities.Avatar.AvatarState.Water.Torrent.InitialDamage", 4); + config.addDefault("Abilities.Avatar.AvatarState.Water.Torrent.SuccessiveDamage", 1.5); + config.addDefault("Abilities.Avatar.AvatarState.Water.Torrent.MaxHits", 3); + config.addDefault("Abilities.Avatar.AvatarState.Water.Torrent.Push", 1.5); config.addDefault("Abilities.Avatar.AvatarState.Water.WaterManipulation.Damage", 5); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceBlast.Damage", 4); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceBlast.Range", 30); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Damage", 4); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Range", 30); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Push", 0.9); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Height", 7); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.SlowPower", 3); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.SlowDuration", 90); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Field.Damage", 3); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Field.Radius", 8); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Field.Push", 1.2); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.Range", 30); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.Damage", 3); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.SlowPower", 3); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.SlowDuration", 90); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceBullet.Damage", 4); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceBullet.Range", 16); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceBullet.MaxShots", 45); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceBullet.ShootTime", 12000); + config.addDefault("Abilities.Avatar.AvatarState.Water.IceWave.Damage", 4); + config.addDefault("Abilities.Avatar.AvatarState.Water.WaterSpout.Height", 20); + config.addDefault("Abilities.Avatar.AvatarState.Water.WaterSpout.Wave.FlightTime", 5000); config.addDefault("Abilities.Air.Passive.Factor", 0.3); config.addDefault("Abilities.Air.Passive.AirAgility.Enabled", true); @@ -677,12 +760,14 @@ public class ConfigManager { config.addDefault("Abilities.Air.AirScooter.MaxHeightFromGround", 7); config.addDefault("Abilities.Air.AirShield.Enabled", true); + config.addDefault("Abilities.Air.AirShield.Cooldown", 0); config.addDefault("Abilities.Air.AirShield.Radius", 7); config.addDefault("Abilities.Air.AirShield.Streams", 5); config.addDefault("Abilities.Air.AirShield.Speed", 10); config.addDefault("Abilities.Air.AirShield.Particles", 5); config.addDefault("Abilities.Air.AirSpout.Enabled", true); + config.addDefault("Abilities.Air.AirSpout.Cooldown", 0); config.addDefault("Abilities.Air.AirSpout.Height", 16); config.addDefault("Abilities.Air.AirSpout.Interval", 100); @@ -737,6 +822,7 @@ public class ConfigManager { config.addDefault("Abilities.Air.Suffocate.AnimationSpeed", 1.0); config.addDefault("Abilities.Air.Tornado.Enabled", true); + config.addDefault("Abilities.Air.Tornado.Cooldown", 0); config.addDefault("Abilities.Air.Tornado.Radius", 10); config.addDefault("Abilities.Air.Tornado.Height", 20); config.addDefault("Abilities.Air.Tornado.Range", 25); @@ -744,29 +830,32 @@ public class ConfigManager { config.addDefault("Abilities.Air.Tornado.NpcPushFactor", 1); config.addDefault("Abilities.Air.Tornado.PlayerPushFactor", 1); - config.addDefault("Abilities.Air.AirCombo.Twister.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.Enabled", true); - 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", 7000); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Enabled", true); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Speed", 1.4); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Range", 14); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Damage", 3); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Knockback", 3.5); - config.addDefault("Abilities.Air.AirCombo.AirSweep.Cooldown", 6000); + config.addDefault("Abilities.Air.Twister.Enabled", true); + config.addDefault("Abilities.Air.Twister.Speed", 0.35); + config.addDefault("Abilities.Air.Twister.Range", 16); + config.addDefault("Abilities.Air.Twister.Height", 8); + config.addDefault("Abilities.Air.Twister.Radius", 3.5); + config.addDefault("Abilities.Air.Twister.RemoveDelay", 1500); + config.addDefault("Abilities.Air.Twister.Cooldown", 10000); + config.addDefault("Abilities.Air.Twister.DegreesPerParticle", 7); + config.addDefault("Abilities.Air.Twister.HeightPerParticle", 1.25); + + config.addDefault("Abilities.Air.AirStream.Enabled", true); + config.addDefault("Abilities.Air.AirStream.Speed", 0.5); + config.addDefault("Abilities.Air.AirStream.Range", 40); + config.addDefault("Abilities.Air.AirStream.EntityDuration", 4000); + config.addDefault("Abilities.Air.AirStream.EntityHeight", 14); + config.addDefault("Abilities.Air.AirStream.Cooldown", 7000); + + config.addDefault("Abilities.Air.AirSweep.Enabled", true); + config.addDefault("Abilities.Air.AirSweep.Speed", 1.4); + config.addDefault("Abilities.Air.AirSweep.Range", 14); + config.addDefault("Abilities.Air.AirSweep.Damage", 3); + config.addDefault("Abilities.Air.AirSweep.Knockback", 3.5); + config.addDefault("Abilities.Air.AirSweep.Cooldown", 6000); config.addDefault("Abilities.Water.Passive.FastSwim.Enabled", true); + config.addDefault("Abilities.Water.Passive.FastSwim.Cooldown", 0); config.addDefault("Abilities.Water.Passive.FastSwim.SpeedFactor", 0.7); config.addDefault("Abilities.Water.Passive.Hydrosink.Enabled", true); @@ -825,7 +914,7 @@ public class ConfigManager { 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", 4); + config.addDefault("Abilities.Water.OctopusForm.Damage", 2); config.addDefault("Abilities.Water.OctopusForm.Knockback", 1.75); config.addDefault("Abilities.Water.OctopusForm.FormDelay", 40); config.addDefault("Abilities.Water.OctopusForm.Cooldown", 0); @@ -898,7 +987,7 @@ 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.Whip.MaxLength", 12); config.addDefault("Abilities.Water.WaterArms.Whip.MaxLengthWeak", 8); @@ -934,6 +1023,8 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Duration.FullMoon", 12000); config.addDefault("Abilities.Water.WaterBubble.Enabled", true); + config.addDefault("Abilities.Water.WaterBubble.Cooldown.Shift", 0); + config.addDefault("Abilities.Water.WaterBubble.Cooldown.Click", 0); config.addDefault("Abilities.Water.WaterBubble.Radius", 4.0); config.addDefault("Abilities.Water.WaterBubble.Speed", 0.5); config.addDefault("Abilities.Water.WaterBubble.ClickDuration", 2000L); @@ -950,6 +1041,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterManipulation.Cooldown", 1000); config.addDefault("Abilities.Water.WaterSpout.Enabled", true); + config.addDefault("Abilities.Water.WaterSpout.Cooldown", 0); config.addDefault("Abilities.Water.WaterSpout.Height", 16); config.addDefault("Abilities.Water.WaterSpout.Interval", 50); config.addDefault("Abilities.Water.WaterSpout.BlockSpiral", true); @@ -966,20 +1058,21 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterSpout.Wave.Speed", 1.3); config.addDefault("Abilities.Water.WaterSpout.Wave.Cooldown", 6000); - config.addDefault("Abilities.Water.WaterCombo.IceWave.Enabled", true); - config.addDefault("Abilities.Water.WaterCombo.IceWave.Damage", 3); - config.addDefault("Abilities.Water.WaterCombo.IceWave.Cooldown", 6000); - config.addDefault("Abilities.Water.WaterCombo.IceWave.ThawRadius", 10); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.Enabled", true); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.Damage", 2); - 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", 10000); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.Cooldown", 10000); - config.addDefault("Abilities.Water.WaterCombo.IceWave.RevertSphere", true); - config.addDefault("Abilities.Water.WaterCombo.IceWave.RevertSphereTime", 30000L); + config.addDefault("Abilities.Water.IceWave.Enabled", true); + config.addDefault("Abilities.Water.IceWave.Damage", 3); + config.addDefault("Abilities.Water.IceWave.Cooldown", 6000); + config.addDefault("Abilities.Water.IceWave.ThawRadius", 10); + config.addDefault("Abilities.Water.IceWave.RevertSphere", true); + config.addDefault("Abilities.Water.IceWave.RevertSphereTime", 30000L); + + config.addDefault("Abilities.Water.IceBullet.Enabled", true); + config.addDefault("Abilities.Water.IceBullet.Damage", 2); + config.addDefault("Abilities.Water.IceBullet.Radius", 2.5); + config.addDefault("Abilities.Water.IceBullet.Range", 12); + config.addDefault("Abilities.Water.IceBullet.MaxShots", 30); + config.addDefault("Abilities.Water.IceBullet.AnimationSpeed", 1); + config.addDefault("Abilities.Water.IceBullet.ShootTime", 10000); + config.addDefault("Abilities.Water.IceBullet.Cooldown", 10000); config.addDefault("Abilities.Earth.Passive.Duration", 2500); config.addDefault("Abilities.Earth.Passive.DensityShift.Enabled", true); @@ -1003,8 +1096,8 @@ public class ConfigManager { config.addDefault("Abilities.Earth.EarthArmor.Enabled", true); config.addDefault("Abilities.Earth.EarthArmor.SelectRange", 10); config.addDefault("Abilities.Earth.EarthArmor.GoldHearts", 4); - config.addDefault("Abilities.Earth.EarthArmor.Cooldown", 17500); - config.addDefault("Abilities.Earth.EarthArmor.MaxDuration", 20000); + config.addDefault("Abilities.Earth.EarthArmor.Cooldown", 7500); + config.addDefault("Abilities.Earth.EarthArmor.MaxDuration", 17500); config.addDefault("Abilities.Earth.EarthBlast.Enabled", true); config.addDefault("Abilities.Earth.EarthBlast.CanHitSelf", false); @@ -1020,10 +1113,12 @@ public class ConfigManager { config.addDefault("Abilities.Earth.EarthGrab.Enabled", true); config.addDefault("Abilities.Earth.EarthGrab.SelectRange", 20); - config.addDefault("Abilities.Earth.EarthGrab.Height", 6); + config.addDefault("Abilities.Earth.EarthGrab.Height", 4); config.addDefault("Abilities.Earth.EarthGrab.Cooldown", 2000); + config.addDefault("Abilities.Earth.EarthGrab.Radius", 4); config.addDefault("Abilities.Earth.EarthTunnel.Enabled", true); + config.addDefault("Abilities.Earth.EarthTunnel.Cooldown", 0); config.addDefault("Abilities.Earth.EarthTunnel.MaxRadius", 1); config.addDefault("Abilities.Earth.EarthTunnel.Range", 10); config.addDefault("Abilities.Earth.EarthTunnel.Radius", 0.25); @@ -1090,7 +1185,7 @@ public class ConfigManager { config.addDefault("Abilities.Earth.MetalClips.MagnetPower", 0.6); config.addDefault("Abilities.Earth.MetalClips.Cooldown", 6000); config.addDefault("Abilities.Earth.MetalClips.CrushCooldown", 2000); - config.addDefault("Abilities.Earth.MetalClips.ShootCooldown", 0); + config.addDefault("Abilities.Earth.MetalClips.MagnetCooldown", 1000); config.addDefault("Abilities.Earth.MetalClips.Duration", 10000); config.addDefault("Abilities.Earth.MetalClips.ThrowEnabled", true); @@ -1113,13 +1208,6 @@ public class ConfigManager { config.addDefault("Abilities.Earth.Shockwave.Range", 15); config.addDefault("Abilities.Earth.Shockwave.Angle", 40); - config.addDefault("Abilities.Earth.SandSpout.Enabled", true); - config.addDefault("Abilities.Earth.SandSpout.Height", 10); - config.addDefault("Abilities.Earth.SandSpout.BlindnessTime", 10); - config.addDefault("Abilities.Earth.SandSpout.SpoutDamage", 1); - config.addDefault("Abilities.Earth.SandSpout.Spiral", false); - config.addDefault("Abilities.Earth.SandSpout.Interval", 100); - config.addDefault("Abilities.Earth.Tremorsense.Enabled", true); config.addDefault("Abilities.Earth.Tremorsense.MaxDepth", 10); config.addDefault("Abilities.Earth.Tremorsense.Radius", 5); @@ -1246,35 +1334,39 @@ public class ConfigManager { config.addDefault("Abilities.Fire.WallOfFire.FireTicks", 0); config.addDefault("Abilities.Fire.WallOfFire.MaxAngle", 50); - config.addDefault("Abilities.Fire.FireCombo.FireKick.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", 6000); - config.addDefault("Abilities.Fire.FireCombo.FireKick.Speed", 1); - config.addDefault("Abilities.Fire.FireCombo.FireSpin.Enabled", true); - 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.0); - config.addDefault("Abilities.Fire.FireCombo.FireSpin.Cooldown", 5000); - config.addDefault("Abilities.Fire.FireCombo.FireSpin.Speed", 0.3); - config.addDefault("Abilities.Fire.FireCombo.FireWheel.Enabled", true); - 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", 6000); - config.addDefault("Abilities.Fire.FireCombo.FireWheel.FireTicks", 2.5); - config.addDefault("Abilities.Fire.FireCombo.FireWheel.Height", 2); - config.addDefault("Abilities.Fire.FireCombo.FireWheel.Radius", 1.0); - config.addDefault("Abilities.Fire.FireCombo.JetBlast.Enabled", true); - config.addDefault("Abilities.Fire.FireCombo.JetBlast.Speed", 1.2); - config.addDefault("Abilities.Fire.FireCombo.JetBlast.Cooldown", 6000); - config.addDefault("Abilities.Fire.FireCombo.JetBlast.Duration", 5000); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Enabled", true); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Speed", 1.1); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Damage", 4); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Cooldown", 6000); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.FireTicks", 2.5); - config.addDefault("Abilities.Fire.FireCombo.JetBlaze.Duration", 5000); + config.addDefault("Abilities.Fire.FireKick.Enabled", true); + config.addDefault("Abilities.Fire.FireKick.Range", 7.0); + config.addDefault("Abilities.Fire.FireKick.Damage", 3.0); + config.addDefault("Abilities.Fire.FireKick.Cooldown", 6000); + config.addDefault("Abilities.Fire.FireKick.Speed", 1); + + config.addDefault("Abilities.Fire.FireSpin.Enabled", true); + config.addDefault("Abilities.Fire.FireSpin.Range", 7); + config.addDefault("Abilities.Fire.FireSpin.Damage", 3.0); + config.addDefault("Abilities.Fire.FireSpin.Knockback", 3.0); + config.addDefault("Abilities.Fire.FireSpin.Cooldown", 5000); + config.addDefault("Abilities.Fire.FireSpin.Speed", 0.3); + + config.addDefault("Abilities.Fire.FireWheel.Enabled", true); + config.addDefault("Abilities.Fire.FireWheel.Range", 20.0); + config.addDefault("Abilities.Fire.FireWheel.Damage", 4.0); + config.addDefault("Abilities.Fire.FireWheel.Speed", 0.55); + config.addDefault("Abilities.Fire.FireWheel.Cooldown", 6000); + config.addDefault("Abilities.Fire.FireWheel.FireTicks", 2.5); + config.addDefault("Abilities.Fire.FireWheel.Height", 2); + config.addDefault("Abilities.Fire.FireWheel.Radius", 1.0); + + config.addDefault("Abilities.Fire.JetBlast.Enabled", true); + config.addDefault("Abilities.Fire.JetBlast.Speed", 1.2); + config.addDefault("Abilities.Fire.JetBlast.Cooldown", 6000); + config.addDefault("Abilities.Fire.JetBlast.Duration", 5000); + + config.addDefault("Abilities.Fire.JetBlaze.Enabled", true); + config.addDefault("Abilities.Fire.JetBlaze.Speed", 1.1); + config.addDefault("Abilities.Fire.JetBlaze.Damage", 4); + config.addDefault("Abilities.Fire.JetBlaze.Cooldown", 6000); + config.addDefault("Abilities.Fire.JetBlaze.FireTicks", 2.5); + config.addDefault("Abilities.Fire.JetBlaze.Duration", 5000); config.addDefault("Abilities.Chi.Passive.Acrobatics.Enabled", true); config.addDefault("Abilities.Chi.Passive.Acrobatics.FallReductionFactor", 0.5); @@ -1287,11 +1379,12 @@ public class ConfigManager { config.addDefault("Abilities.Chi.Passive.BlockChi.Chance", 25); config.addDefault("Abilities.Chi.Passive.BlockChi.Duration", 1000); - config.addDefault("Abilities.Chi.ChiCombo.Immobilize.Enabled", true); - config.addDefault("Abilities.Chi.ChiCombo.Immobilize.ParalyzeDuration", 3500); - config.addDefault("Abilities.Chi.ChiCombo.Immobilize.Cooldown", 15000); + config.addDefault("Abilities.Chi.Immobilize.Enabled", true); + config.addDefault("Abilities.Chi.Immobilize.ParalyzeDuration", 3500); + config.addDefault("Abilities.Chi.Immobilize.Cooldown", 15000); config.addDefault("Abilities.Chi.AcrobatStance.Enabled", true); + config.addDefault("Abilities.Chi.AcrobatStance.Cooldown", 0); config.addDefault("Abilities.Chi.AcrobatStance.ChiBlockBoost", 3); config.addDefault("Abilities.Chi.AcrobatStance.Speed", 1); config.addDefault("Abilities.Chi.AcrobatStance.Jump", 1); @@ -1316,6 +1409,7 @@ public class ConfigManager { config.addDefault("Abilities.Chi.Smokescreen.Duration", 12); config.addDefault("Abilities.Chi.WarriorStance.Enabled", true); + config.addDefault("Abilities.Chi.WarriorStance.Cooldown", 0); config.addDefault("Abilities.Chi.WarriorStance.Strength", 1); config.addDefault("Abilities.Chi.WarriorStance.Resistance", -1); @@ -1346,4 +1440,4 @@ public class ConfigManager { public static FileConfiguration getConfig() { return ConfigManager.defaultConfig.get(); } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/earthbending/Catapult.java b/src/com/projectkorra/projectkorra/earthbending/Catapult.java index 47e6a007..a52d5fff 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Catapult.java +++ b/src/com/projectkorra/projectkorra/earthbending/Catapult.java @@ -147,7 +147,7 @@ public class Catapult extends EarthAbility { @Override public boolean isSneakAbility() { - return false; + return true; } @Override diff --git a/src/com/projectkorra/projectkorra/earthbending/Collapse.java b/src/com/projectkorra/projectkorra/earthbending/Collapse.java index 32c1d9d5..0be8d43e 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Collapse.java +++ b/src/com/projectkorra/projectkorra/earthbending/Collapse.java @@ -77,7 +77,7 @@ public class Collapse extends EarthAbility { } private void setFields() { - this.height = getConfig().getInt("Abilities.Earth.Collapse.Column.Height"); + this.height = bPlayer.isAvatarState() ? getConfig().getInt("Abilities.Avatar.AvatarState.Earth.Collapse.Column.Height") : getConfig().getInt("Abilities.Earth.Collapse.Column.Height"); this.selectRange = getConfig().getInt("Abilities.Earth.Collapse.SelectRange"); this.speed = getConfig().getDouble("Abilities.Earth.Collapse.Speed"); this.cooldown = getConfig().getLong("Abilities.Earth.Collapse.Column.Cooldown"); diff --git a/src/com/projectkorra/projectkorra/earthbending/CollapseWall.java b/src/com/projectkorra/projectkorra/earthbending/CollapseWall.java index fdc718c3..891b0239 100644 --- a/src/com/projectkorra/projectkorra/earthbending/CollapseWall.java +++ b/src/com/projectkorra/projectkorra/earthbending/CollapseWall.java @@ -41,6 +41,7 @@ public class CollapseWall extends EarthAbility { if (bPlayer.isAvatarState()) { this.height = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.Collapse.Wall.Height"); } + Block sblock = BlockSource.getEarthSourceBlock(player, selectRange, ClickType.SHIFT_DOWN); if (sblock == null) { location = getTargetEarthBlock(selectRange).getLocation(); diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java b/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java index 6ed1de58..8ab16f66 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java @@ -87,8 +87,6 @@ public class EarthArmor extends EarthAbility { } playEarthbendingSound(headBlock.getLocation()); - bPlayer.addCooldown(this, getCooldown() / 2); //Prevents spamming of the move to remove blocks - start(); } } @@ -238,7 +236,6 @@ public class EarthArmor extends EarthAbility { bPlayer.addCooldown(this); remove(); - remove(); return; } @@ -431,6 +428,9 @@ public class EarthArmor extends EarthAbility { if (!player.isOnline() || player.isDead()) { return false; + + } else if (bPlayer.isOnCooldown("EarthArmor")){ + return false; } else if (!bPlayer.canBind(this)) { return false; } else if (this.getPlayer() != null && this.getLocation() != null && !this.getLocation().getWorld().equals(player.getWorld())) { @@ -467,7 +467,7 @@ public class EarthArmor extends EarthAbility { @Override public boolean isSneakAbility() { - return false; + return player != null; } @Override @@ -567,4 +567,4 @@ public class EarthArmor extends EarthAbility { this.maxGoldHearts = maxGoldHearts; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java b/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java index ebf5e87a..57fa4fe8 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java @@ -21,7 +21,8 @@ public class EarthGrab extends EarthAbility { private long cooldown; private double lowestDistance; private double selectRange; - private double height; + private int height; + private int radius; private Location origin; private Vector direction; private Entity closestEntity; @@ -37,8 +38,9 @@ public class EarthGrab extends EarthAbility { super(player); this.selectRange = getConfig().getDouble("Abilities.Earth.EarthGrab.SelectRange"); - this.height = getConfig().getDouble("Abilities.Earth.EarthGrab.Height"); + this.height = getConfig().getInt("Abilities.Earth.EarthGrab.Height"); this.cooldown = getConfig().getLong("Abilities.Earth.EarthGrab.Cooldown"); + this.radius = getConfig().getInt("Abilities.Earth.EarthGrab.Radius"); this.origin = player.getEyeLocation(); this.direction = origin.getDirection(); this.lowestDistance = selectRange + 1; @@ -56,7 +58,8 @@ public class EarthGrab extends EarthAbility { if (bPlayer.isAvatarState()) { this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthGrab.Cooldown"); - this.height = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthGrab.Height"); + this.height = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.EarthGrab.Height"); + this.radius = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.EarthGrab.Radius"); } if (player.isSneaking()) { @@ -74,39 +77,28 @@ public class EarthGrab extends EarthAbility { public void formDome() { if (closestEntity != null) { ArrayList blocks = new ArrayList(); - Location location = closestEntity.getLocation(); - Location loc1 = location.clone(); - Location loc2 = location.clone(); - Location testLoc, testloc2; - double factor = 3; - double factor2 = 4; - int height1 = (int) height / 2; - int height2 = (int) height / 3; - - for (double angle = 0; angle <= 360; angle += 20) { - testLoc = loc1.clone().add(factor * Math.cos(Math.toRadians(angle)), 1, factor * Math.sin(Math.toRadians(angle))); - testloc2 = loc2.clone().add(factor2 * Math.cos(Math.toRadians(angle)), 1, factor2 * Math.sin(Math.toRadians(angle))); - - for (int y = 0; y < height - height1; y++) { - testLoc = testLoc.clone().add(0, -1, 0); - if (isEarthbendable(testLoc.getBlock())) { - if (!blocks.contains(testLoc.getBlock())) { - new RaiseEarth(player, testLoc, height1 + y - 1); - } - blocks.add(testLoc.getBlock()); - break; - } + Location location = closestEntity.getLocation().clone().subtract(0, 1, 0); + location.setPitch(0); + for (float theta = -180; theta < 180; theta += 1) { + Location loc = location.clone(); + loc.setYaw(theta); + Vector dir = loc.getDirection(); + Block a = GeneralMethods.getTopBlock(loc.add(dir.clone().multiply(radius)), height/2); + while (!GeneralMethods.isSolid(a) && !isEarthbendable(a.getType(), true, true, false) && a.getY() > 0 && a.getY() < 256) { + a = a.getRelative(BlockFace.DOWN); } - - for (int y = 0; y < height - height2; y++) { - testloc2 = testloc2.clone().add(0, -1, 0); - if (isEarthbendable(testloc2.getBlock())) { - if (!blocks.contains(testloc2.getBlock())) { - new RaiseEarth(player, testloc2, height2 + y - 1); - } - blocks.add(testloc2.getBlock()); - break; - } + if (!blocks.contains(a)) { + blocks.add(a); + new RaiseEarth(player, a.getLocation(), (int) height); + } + + Block b = GeneralMethods.getTopBlock(loc.add(dir.clone().multiply(1)), height/2); + while (!GeneralMethods.isSolid(b) && !isEarthbendable(b.getType(), true, true, false) && b.getY() > 0 && b.getY() < 256) { + b = b.getRelative(BlockFace.DOWN); + } + if (!blocks.contains(b)) { + blocks.add(b); + new RaiseEarth(player, b.getLocation(), (int) height/2); } } @@ -118,46 +110,7 @@ public class EarthGrab extends EarthAbility { closestEntity = player; getGround(); ParticleEffect.BLOCK_CRACK.display((ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, blockByte), 1F, 1F, 1F, 0.1F, 100, player.getLocation(), 500); - if (closestEntity != null) { - ArrayList blocks = new ArrayList(); - Location location = closestEntity.getLocation(); - Location loc1 = location.clone(); - Location loc2 = location.clone(); - Location testLoc, testLoc2; - double factor = 3; - double factor2 = 4; - int height1 = (int) height / 2; - int height2 = (int) height / 3; - - for (double angle = 0; angle <= 360; angle += 20) { - testLoc = loc1.clone().add(factor * Math.cos(Math.toRadians(angle)), 1, factor * Math.sin(Math.toRadians(angle))); - testLoc2 = loc2.clone().add(factor2 * Math.cos(Math.toRadians(angle)), 1, factor2 * Math.sin(Math.toRadians(angle))); - - for (int y = 0; y < height - height1; y++) { - testLoc = testLoc.clone().add(0, -1, 0); - if (isEarthbendable(testLoc.getBlock())) { - if (!blocks.contains(testLoc.getBlock())) { - new RaiseEarth(player, testLoc, height1 + y - 1); - } - blocks.add(testLoc.getBlock()); - break; - } - } - - for (int y = 0; y < height - height2; y++) { - testLoc2 = testLoc2.clone().add(0, -1, 0); - if (isEarthbendable(testLoc2.getBlock())) { - if (!blocks.contains(testLoc2.getBlock())) { - new RaiseEarth(player, testLoc2, height2 + y - 1); - } - blocks.add(testLoc2.getBlock()); - break; - } - } - } - - bPlayer.addCooldown(this); - } + formDome(); } @Override @@ -180,6 +133,8 @@ public class EarthGrab extends EarthAbility { } } if (isEarthbendable(b)) { + blockType = b.getType(); + blockByte = b.getData(); return b; } } @@ -275,11 +230,11 @@ public class EarthGrab extends EarthAbility { this.selectRange = range; } - public double getHeight() { + public int getHeight() { return height; } - public void setHeight(double height) { + public void setHeight(int height) { this.height = height; } @@ -311,4 +266,4 @@ public class EarthGrab extends EarthAbility { this.cooldown = cooldown; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java b/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java index 68691571..99e063f3 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java @@ -494,7 +494,7 @@ public class EarthSmash extends EarthAbility { public Material selectMaterialForRepresenter(Material mat) { Material tempMat = selectMaterial(mat); Random rand = new Random(); - if (!isEarthbendable(tempMat) && !isMetalbendable(tempMat)) { + if (!isEarthbendable(tempMat, true, true, true) && !isMetalbendable(tempMat)) { if (currentBlocks.size() < 1) { return Material.DIRT; } else { diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java b/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java index 02bf3a34..2cbec7c3 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java @@ -23,6 +23,7 @@ public class EarthTunnel extends EarthAbility { private long interval; private long time; private double depth; + private long cooldown; private double radius; private double angle; private double maxRadius; @@ -40,6 +41,7 @@ public class EarthTunnel extends EarthAbility { public EarthTunnel(Player player) { super(player); + this.cooldown = getConfig().getLong("Abilities.Earth.EarthTunnel.Cooldown"); this.maxRadius = getConfig().getDouble("Abilities.Earth.EarthTunnel.MaxRadius"); this.range = getConfig().getDouble("Abilities.Earth.EarthTunnel.Range"); this.radius = getConfig().getDouble("Abilities.Earth.EarthTunnel.Radius"); @@ -59,7 +61,7 @@ public class EarthTunnel extends EarthAbility { } this.angle = 0; - if (!bPlayer.canBend(this)) { + if (!bPlayer.canBend(this) || !EarthAbility.isEarthbendable(player, block)) { return; } if (bPlayer.isAvatarState()) { @@ -73,7 +75,8 @@ public class EarthTunnel extends EarthAbility { @Override public void progress() { - if (!bPlayer.canBendIgnoreCooldowns(this)) { + if (!bPlayer.canBend(this)) { + bPlayer.addCooldown(this); remove(); return; } @@ -81,6 +84,7 @@ public class EarthTunnel extends EarthAbility { if (System.currentTimeMillis() - time >= interval) { time = System.currentTimeMillis(); if (Math.abs(Math.toDegrees(player.getEyeLocation().getDirection().angle(direction))) > 20 || !player.isSneaking()) { + bPlayer.addCooldown(this); remove(); return; } else { @@ -95,6 +99,7 @@ public class EarthTunnel extends EarthAbility { if (radius >= maxRadius) { radius = radiusIncrement; if (depth >= range) { + bPlayer.addCooldown(this); remove(); return; } else { @@ -150,7 +155,7 @@ public class EarthTunnel extends EarthAbility { @Override public long getCooldown() { - return 0; + return cooldown; } @Override diff --git a/src/com/projectkorra/projectkorra/earthbending/lava/LavaFlow.java b/src/com/projectkorra/projectkorra/earthbending/lava/LavaFlow.java index 4c3bb10c..c0ad5f6a 100644 --- a/src/com/projectkorra/projectkorra/earthbending/lava/LavaFlow.java +++ b/src/com/projectkorra/projectkorra/earthbending/lava/LavaFlow.java @@ -315,14 +315,7 @@ public class LavaFlow extends LavaAbility { for (double x = -radius; x <= radius; x++) { for (double z = -radius; z <= radius; z++) { Location loc = origin.clone().add(x, 0, z); - Block tempBlock_t = GeneralMethods.getTopBlock(loc, upwardFlow, downwardFlow); - Block tempBlock_b = GeneralMethods.getBottomBlock(loc, upwardFlow, downwardFlow); - Block tempBlock = tempBlock_t; - if (tempBlock_t.getLocation().distance(player.getLocation()) > tempBlock_b.getLocation().distance(player.getLocation())) - tempBlock = tempBlock_b; - if (tempBlock == null) { - continue; - } + Block tempBlock = GeneralMethods.getTopBlock(loc, upwardFlow, downwardFlow); double dSquared = distanceSquaredXZ(tempBlock.getLocation(), origin); if (dSquared < Math.pow(radius, 2) && !GeneralMethods.isRegionProtectedFromBuild(this, loc)) { diff --git a/src/com/projectkorra/projectkorra/earthbending/metal/Extraction.java b/src/com/projectkorra/projectkorra/earthbending/metal/Extraction.java index f193c4c5..cb4381ef 100644 --- a/src/com/projectkorra/projectkorra/earthbending/metal/Extraction.java +++ b/src/com/projectkorra/projectkorra/earthbending/metal/Extraction.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ability.EarthAbility; import com.projectkorra.projectkorra.ability.MetalAbility; public class Extraction extends MetalAbility { @@ -36,11 +37,14 @@ public class Extraction extends MetalAbility { if (originBlock == null) { return; } + + Material material = originBlock.getType(); + if (!GeneralMethods.isRegionProtectedFromBuild(this, originBlock.getLocation())) { - if (bPlayer.canMetalbend() && bPlayer.canBend(this)) { + if (EarthAbility.isMetalbendable(player, material)) { Material type = null; - switch (originBlock.getType()) { + switch (material) { case IRON_ORE: originBlock.setType(Material.STONE); player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.IRON_INGOT, getAmount())); diff --git a/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java b/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java index ddec3037..e9b8d906 100644 --- a/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java +++ b/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java @@ -44,6 +44,7 @@ public class MetalClips extends MetalAbility { private long cooldown; private long shootCooldown; private long crushCooldown; + private long magnetCooldown; private double magnetPower; private double range; private double crushDamage; @@ -64,8 +65,9 @@ public class MetalClips extends MetalAbility { this.armorTime = getConfig().getInt("Abilities.Earth.MetalClips.Duration"); this.range = getConfig().getDouble("Abilities.Earth.MetalClips.Range"); this.cooldown = getConfig().getLong("Abilities.Earth.MetalClips.Cooldown"); - this.shootCooldown = getConfig().getLong("Abilities.Earth.MetalClips.ShootCooldown"); + this.shootCooldown = 600; this.crushCooldown = getConfig().getLong("Abilities.Earth.MetalClips.CrushCooldown"); + this.magnetCooldown = getConfig().getLong("Abilities.Earth.MetalClips.MagnetCooldown"); this.magnetRange = getConfig().getInt("Abilities.Earth.MetalClips.MagnetRange"); this.magnetPower = getConfig().getDouble("Abilities.Earth.MetalClips.MagnetPower"); this.crushDamage = getConfig().getDouble("Abilities.Earth.MetalClips.CrushDamage"); @@ -73,20 +75,24 @@ public class MetalClips extends MetalAbility { this.canThrow = (getConfig().getBoolean("Abilities.Earth.MetalClips.ThrowEnabled") && player.hasPermission("bending.ability.metalclips.throw")); this.trackedIngots = new ArrayList<>(); - if (!bPlayer.canBend(this)) { - return; - } - if (bPlayer.isAvatarState()) { cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.MetalClips.Cooldown"); - ; range = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.MetalClips.Range"); crushDamage = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.MetalClips.CrushDamage"); } if (abilityType == 0) { + if (!bPlayer.canBend(this)) { + return; + } + if (!player.getInventory().containsAtLeast(new ItemStack(Material.IRON_INGOT), 1)) { + return; + } shootMetal(); } else if (abilityType == 1) { + if (bPlayer.isOnCooldown("MetalClips Magnet")) { + return; + } isMagnetized = true; } @@ -123,7 +129,6 @@ public class MetalClips extends MetalAbility { ItemStack is = new ItemStack(Material.IRON_INGOT, 1); if (!player.getInventory().containsAtLeast(is, 1)) { - remove(); return; } @@ -190,15 +195,17 @@ public class MetalClips extends MetalAbility { } public void resetArmor() { + if (!isMagnetized) { + bPlayer.addCooldown(this); + } if (targetEntity == null || !TempArmor.hasTempArmor(targetEntity) || targetEntity.isDead()) { return; } TempArmor.getTempArmor(targetEntity).revert(); - player.getWorld().dropItem(targetEntity.getLocation(), new ItemStack(Material.IRON_INGOT, metalClipsCount)); + dropIngots(targetEntity.getLocation()); isBeingWorn = false; - bPlayer.addCooldown(this); } public void launch() { @@ -249,6 +256,11 @@ public class MetalClips extends MetalAbility { } if (!player.isSneaking()) { + if (isMagnetized) { + bPlayer.addCooldown("MetalClips Magnet", magnetCooldown); + remove(); + return; + } isControlling = false; isMagnetized = false; if (metalClipsCount < 4 && hasSnuck && abilityType == 0) { @@ -265,7 +277,7 @@ public class MetalClips extends MetalAbility { Vector vector = GeneralMethods.getDirection(entity.getLocation(), player.getLocation()); ItemStack itemInHand = player.getInventory().getItemInMainHand(); - if (entity instanceof Player && canLoot && itemInHand.getType() == Material.IRON_INGOT && itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase("Magnet")) { + if (entity instanceof Player && canLoot && itemInHand.getType() == Material.IRON_INGOT && (itemInHand.hasItemMeta() && itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase("Magnet"))) { Player targetPlayer = (Player) entity; if (targetPlayer.getEntityId() == player.getEntityId()) { @@ -395,7 +407,7 @@ public class MetalClips extends MetalAbility { } } - for (int i = 0; i < trackedIngots.size(); i++) { + for (int i = trackedIngots.size() - 1; i >= 0; i--) { Item ii = trackedIngots.get(i); if (ii.isOnGround()) { trackedIngots.remove(i); @@ -418,12 +430,12 @@ public class MetalClips extends MetalAbility { } else if (targetEntity == e) { formArmor(); } else { + dropIngots(e.getLocation()); TARGET_TO_ABILITY.get(targetEntity).remove(); - player.getWorld().dropItemNaturally(e.getLocation(), new ItemStack(Material.IRON_INGOT, 1)); } } else { DamageHandler.damageEntity(e, player, damage, this); - ii.getWorld().dropItem(ii.getLocation(), ii.getItemStack()); + dropIngots(e.getLocation()); remove(); } @@ -436,6 +448,11 @@ public class MetalClips extends MetalAbility { removeDeadIngots(); } + + public void dropIngots(Location loc) { + Item i = player.getWorld().dropItem(loc, new ItemStack(Material.IRON_INGOT, metalClipsCount == 0 ? 1 : metalClipsCount)); + i.setPickupDelay(61); + } public void removeDeadIngots() { for (int i = 0; i < trackedIngots.size(); i++) { diff --git a/src/com/projectkorra/projectkorra/earthbending/passive/EarthPassive.java b/src/com/projectkorra/projectkorra/earthbending/passive/EarthPassive.java index 9124d8cd..6df82ba1 100644 --- a/src/com/projectkorra/projectkorra/earthbending/passive/EarthPassive.java +++ b/src/com/projectkorra/projectkorra/earthbending/passive/EarthPassive.java @@ -77,7 +77,7 @@ public class EarthPassive { return true; } - return (TempBlock.isTempBlock(block) && EarthAbility.isEarth(TempBlock.get(block).getBlock().getType())) || EarthAbility.isEarth(block) || EarthAbility.isTransparent(player, block); + return (TempBlock.isTempBlock(block) && EarthAbility.isEarthbendable(TempBlock.get(block).getBlock().getType(), true, true, false)) || EarthAbility.isEarthbendable(block.getType(), true, true, false) || EarthAbility.isTransparent(player, block); } public static boolean isPassiveSand(Block block) { @@ -100,19 +100,16 @@ public class EarthPassive { public static void handleMetalPassives() { for (Player player : Bukkit.getOnlinePlayers()) { BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - if (bPlayer != null && bPlayer.canBendPassive(Element.EARTH) && bPlayer.canMetalbend()) { if (player.isSneaking() && !bPlayer.isOnCooldown("MetalPassive")) { Block block = player.getTargetBlock((HashSet) null, 5); if (block == null) { continue; } - if (block.getType() == Material.IRON_DOOR_BLOCK && !GeneralMethods.isRegionProtectedFromBuild(player, block.getLocation())) { if (block.getData() >= 8) { block = block.getRelative(BlockFace.DOWN); } - if (block.getData() < 4) { block.setData((byte) (block.getData() + 4)); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_IRON_DOOR_CLOSE, 10, 1); @@ -120,7 +117,6 @@ public class EarthPassive { block.setData((byte) (block.getData() - 4)); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_IRON_DOOR_OPEN, 10, 1); } - bPlayer.addCooldown("MetalPassive", 200); } } @@ -182,7 +178,4 @@ public class EarthPassive { return ConfigManager.getConfig().getLong("Abilities.Earth.Passive.Duration"); } - public static int getSandRunSpeed() { - return ConfigManager.getConfig().getInt("Abilities.Earth.Passive.SandRunSpeed"); - } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/earthbending/sand/SandSpout.java b/src/com/projectkorra/projectkorra/earthbending/sand/SandSpout.java deleted file mode 100644 index acb134bb..00000000 --- a/src/com/projectkorra/projectkorra/earthbending/sand/SandSpout.java +++ /dev/null @@ -1,344 +0,0 @@ -package com.projectkorra.projectkorra.earthbending.sand; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Random; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.SandAbility; -import com.projectkorra.projectkorra.earthbending.passive.EarthPassive; -import com.projectkorra.projectkorra.util.DamageHandler; -import com.projectkorra.projectkorra.util.Flight; - -public class SandSpout extends SandAbility { - - private boolean canSpiral; - private int angle; - private int blindnessTime; - private long time; - private long interval; - private double damage; - private double height; - private double currentHeight; - private boolean couldFly; - private boolean wasFlying; - private Flight flight; - - public SandSpout(Player player) { - super(player); - - this.currentHeight = 0; - this.angle = 0; - this.interval = getConfig().getLong("Abilities.Earth.SandSpout.Interval"); - this.canSpiral = getConfig().getBoolean("Abilities.Earth.SandSpout.Spiral"); - this.height = getConfig().getDouble("Abilities.Earth.SandSpout.Height"); - this.blindnessTime = getConfig().getInt("Abilities.Earth.SandSpout.BlindnessTime"); - this.damage = getConfig().getInt("Abilities.Earth.SandSpout.SpoutDamage"); - - this.couldFly = player.getAllowFlight(); - this.wasFlying = player.isFlying(); - - SandSpout oldSandSpout = getAbility(player, SandSpout.class); - if (oldSandSpout != null) { - oldSandSpout.remove(); - return; - } - - if (!bPlayer.canBend(this)) { - return; - } - - time = System.currentTimeMillis(); - Block topBlock = GeneralMethods.getTopBlock(player.getLocation(), 0, -50); - if (topBlock == null) { - topBlock = player.getLocation().getBlock(); - } - - Material mat = topBlock.getType(); - if (mat != Material.SAND && mat != Material.SANDSTONE && mat != Material.RED_SANDSTONE) { - return; - } - - if (EarthPassive.isPassiveSand(topBlock)) { - return; - } - - flight = new Flight(player); - start(); - bPlayer.addCooldown(this); - } - - @Override - public void progress() { - Block eyeBlock = player.getEyeLocation().getBlock(); - if (!bPlayer.canBendIgnoreBindsCooldowns(this) || eyeBlock.isLiquid() || GeneralMethods.isSolid(eyeBlock)) { - remove(); - return; - } - - player.setFallDistance(0); - player.setSprinting(false); - if ((new Random()).nextInt(2) == 0) { - playSandBendingSound(player.getLocation()); - } - - Block block = getGround(); - - if (EarthPassive.isPassiveSand(block)) { - remove(); - return; - } - - if (block != null && (block.getType() == Material.SAND || block.getType() == Material.SANDSTONE || block.getType() == Material.RED_SANDSTONE)) { - double dy = player.getLocation().getY() - block.getY(); - if (dy > height) { - removeFlight(); - } else { - allowFlight(); - } - rotateSandColumn(block); - } else { - remove(); - } - } - - private void allowFlight() { - player.setAllowFlight(true); - player.setFlying(true); - player.setFlySpeed(.05f); - } - - private void removeFlight() { - player.setAllowFlight(couldFly); - player.setFlying(wasFlying); - } - - private Block getGround() { - Block standingblock = player.getLocation().getBlock(); - for (int i = 0; i <= height + 5; i++) { - Block block = standingblock.getRelative(BlockFace.DOWN, i); - if (GeneralMethods.isSolid(block) || block.isLiquid()) { - return block; - } - } - return null; - } - - @SuppressWarnings("deprecation") - private void rotateSandColumn(Block block) { - if (System.currentTimeMillis() >= time + interval) { - time = System.currentTimeMillis(); - - Location location = block.getLocation(); - Location playerLoc = player.getLocation(); - location = new Location(location.getWorld(), playerLoc.getX(), location.getY(), playerLoc.getZ()); - - double dy = playerLoc.getY() - block.getY(); - if (dy > height) { - dy = height; - } - - Integer[] directions = { 0, 1, 2, 3, 5, 6, 7, 8 }; - int index = angle; - - angle++; - if (angle >= directions.length) { - angle = 0; - } - for (int i = 1; i <= dy; i++) { - index += 1; - if (index >= directions.length) { - index = 0; - } - - Location effectloc2 = new Location(location.getWorld(), location.getX(), block.getY() + i, location.getZ()); - - if (canSpiral) { - displayHelix(block.getLocation(), this.player.getLocation(), block); - } - if (block != null && ((block.getType() == Material.SAND && block.getData() == (byte) 0) || block.getType() == Material.SANDSTONE)) { - displaySandParticle(effectloc2, 1f, 3f, 1f, 20, .2f, false); - } else if (block != null && ((block.getType() == Material.SAND && block.getData() == (byte) 1) || block.getType() == Material.RED_SANDSTONE)) { - displaySandParticle(effectloc2, 1f, 3f, 1f, 20, .2f, true); - } - - Collection players = GeneralMethods.getPlayersAroundPoint(effectloc2, 1.5f); - if (!players.isEmpty()) { - for (Player sPlayer : players) { - if (!sPlayer.equals(player)) { - sPlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindnessTime * 20, 1)); - DamageHandler.damageEntity(sPlayer, damage, this); - } - } - } - } - } - } - - @SuppressWarnings("deprecation") - private void displayHelix(Location location, Location player, Block block) { - this.currentHeight += 0.1; - if (this.currentHeight >= player.getY() - location.getY()) { - this.currentHeight = 0D; - } - - for (int points = 0; points <= 5; points++) { - double x = Math.cos(currentHeight); - double z = Math.sin(currentHeight); - double nx = x * -1; - double nz = z * -1; - Location newLoc = new Location(player.getWorld(), location.getX() + x, location.getY() + currentHeight, location.getZ() + z); - Location secondLoc = new Location(player.getWorld(), location.getX() + nx, location.getY() + currentHeight, location.getZ() + nz); - - if (block != null && ((block.getType() == Material.SAND && block.getData() == (byte) 0) || block.getType() == Material.SANDSTONE)) { - displaySandParticle(newLoc.add(0.5, 0.5, 0.5), 0.1F, 0.1F, 0.1F, 2, 1, false); - displaySandParticle(secondLoc.add(0.5, 0.5, 0.5), 0.1F, 0.1F, 0.1F, 2, 1, false); - } else if (block != null && ((block.getType() == Material.SAND && block.getData() == (byte) 1) || block.getType() == Material.RED_SANDSTONE)) { - displaySandParticle(newLoc.add(0.5, 0.5, 0.5), 0.1F, 0.1F, 0.1F, 2, 1, true); - displaySandParticle(secondLoc.add(0.5, 0.5, 0.5), 0.1F, 0.1F, 0.1F, 2, 1, true); - } - } - } - - public static boolean removeSpouts(Location location, double radius, Player sourcePlayer) { - boolean removed = false; - for (SandSpout spout : getAbilities(SandSpout.class)) { - Player player = spout.player; - if (!player.equals(sourcePlayer)) { - Location loc1 = player.getLocation().getBlock().getLocation(); - location = location.getBlock().getLocation(); - double dx = loc1.getX() - location.getX(); - double dy = loc1.getY() - location.getY(); - double dz = loc1.getZ() - location.getZ(); - - double distance = Math.sqrt(dx * dx + dz * dz); - - if (distance <= radius && dy > 0 && dy < spout.height) { - spout.remove(); - removed = true; - } - } - } - return removed; - } - - @Override - public void remove() { - super.remove(); - flight.revert(); - removeFlight(); - } - - @Override - public String getName() { - return "SandSpout"; - } - - @Override - public Location getLocation() { - return player != null ? player.getLocation() : null; - } - - @Override - public long getCooldown() { - return 0; - } - - @Override - public boolean isSneakAbility() { - return true; - } - - @Override - public boolean isHarmlessAbility() { - return false; - } - - @Override - public List getLocations() { - ArrayList locations = new ArrayList<>(); - if (player == null) { - return locations; - } - Location top = player.getLocation(); - double ySpacing = 2; - for (double i = 0; i < this.getHeight(); i += ySpacing) { - locations.add(top.clone().add(0, -i, 0)); - } - return locations; - } - - public boolean isCanSpiral() { - return canSpiral; - } - - public void setCanSpiral(boolean canSpiral) { - this.canSpiral = canSpiral; - } - - public int getAngle() { - return angle; - } - - public void setAngle(int angle) { - this.angle = angle; - } - - public int getBlindnessTime() { - return blindnessTime; - } - - public void setBlindnessTime(int blindnessTime) { - this.blindnessTime = blindnessTime; - } - - public long getTime() { - return time; - } - - public void setTime(long time) { - this.time = time; - } - - public long getInterval() { - return interval; - } - - public void setInterval(long interval) { - this.interval = interval; - } - - public double getDamage() { - return damage; - } - - public void setDamage(double damage) { - this.damage = damage; - } - - public double getHeight() { - return height; - } - - public void setHeight(double height) { - this.height = height; - } - - public double getCurrentHeight() { - return currentHeight; - } - - public void setCurrentHeight(double currentHeight) { - this.currentHeight = currentHeight; - } - -} diff --git a/src/com/projectkorra/projectkorra/event/AbilityCollisionEvent.java b/src/com/projectkorra/projectkorra/event/AbilityCollisionEvent.java index 408bbb51..bc9b217a 100644 --- a/src/com/projectkorra/projectkorra/event/AbilityCollisionEvent.java +++ b/src/com/projectkorra/projectkorra/event/AbilityCollisionEvent.java @@ -39,4 +39,7 @@ public class AbilityCollisionEvent extends Event implements Cancellable { return HANDLERS; } + public static HandlerList getHandlerList() { + return HANDLERS; + } } diff --git a/src/com/projectkorra/projectkorra/event/AbilityEndEvent.java b/src/com/projectkorra/projectkorra/event/AbilityEndEvent.java index f42863d0..0cff9198 100644 --- a/src/com/projectkorra/projectkorra/event/AbilityEndEvent.java +++ b/src/com/projectkorra/projectkorra/event/AbilityEndEvent.java @@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList; import com.projectkorra.projectkorra.ability.Ability; public class AbilityEndEvent extends Event { - private final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLERS = new HandlerList(); Ability ability; @@ -20,7 +20,10 @@ public class AbilityEndEvent extends Event { @Override public HandlerList getHandlers() { - return handlers; + return HANDLERS; } + public static HandlerList getHandlerList() { + return HANDLERS; + } } diff --git a/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java b/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java index a5a8af3c..ef7924d3 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java @@ -317,7 +317,7 @@ public class FireBlastCharged extends FireAbility { public boolean isHarmlessAbility() { return false; } - + @Override public boolean isCollidable() { return this.launched; diff --git a/src/com/projectkorra/projectkorra/firebending/FireJet.java b/src/com/projectkorra/projectkorra/firebending/FireJet.java index aa1acc71..1c052a42 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireJet.java +++ b/src/com/projectkorra/projectkorra/firebending/FireJet.java @@ -2,7 +2,6 @@ package com.projectkorra.projectkorra.firebending; import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.airbending.AirSpout; -import com.projectkorra.projectkorra.earthbending.sand.SandSpout; import com.projectkorra.projectkorra.util.Flight; import com.projectkorra.projectkorra.util.ParticleEffect; @@ -37,9 +36,6 @@ public class FireJet extends FireAbility { if (hasAbility(player, AirSpout.class)) { AirSpout abil = getAbility(player, AirSpout.class); abil.remove(); - } else if (hasAbility(player, SandSpout.class)) { - SandSpout abil = getAbility(player, SandSpout.class); - abil.remove(); } this.avatarStateToggled = getConfig().getBoolean("Abilities.Avatar.AvatarState.Fire.FireJet.IsAvatarStateToggle"); diff --git a/src/com/projectkorra/projectkorra/firebending/FireManipulation.java b/src/com/projectkorra/projectkorra/firebending/FireManipulation.java index 0c423248..373236bc 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireManipulation.java +++ b/src/com/projectkorra/projectkorra/firebending/FireManipulation.java @@ -98,6 +98,7 @@ public class FireManipulation extends FireAbility { if (!firing && !charging) { if (!player.isSneaking()) { + bPlayer.addCooldown(this, shieldCooldown); remove(); return; } else if (System.currentTimeMillis() - getStartTime() > maxDuration) { @@ -155,6 +156,7 @@ public class FireManipulation extends FireAbility { if (!streamSneaking) { direction = streamSneakDirection; if (System.currentTimeMillis() - streamRemoveTime > 1000) { + bPlayer.addCooldown(this, streamCooldown); remove(); return; } diff --git a/src/com/projectkorra/projectkorra/firebending/WallOfFire.java b/src/com/projectkorra/projectkorra/firebending/WallOfFire.java index d0476c8a..00656819 100644 --- a/src/com/projectkorra/projectkorra/firebending/WallOfFire.java +++ b/src/com/projectkorra/projectkorra/firebending/WallOfFire.java @@ -70,6 +70,14 @@ public class WallOfFire extends FireAbility { duration = (long) getDayFactor(duration); damage = (int) getDayFactor(damage); } + + if (bPlayer.isAvatarState()) { + this.width = getConfig().getInt("Abilities.Avatar.AvatarState.Fire.WallOfFire.Width"); + this.height = getConfig().getInt("Abilities.Avatar.AvatarState.Fire.WallOfFire.Height"); + this.duration = getConfig().getLong("Abilities.Avatar.AvatarState.Fire.WallOfFire.Duration"); + this.damage = getConfig().getInt("Abilities.Avatar.AvatarState.Fire.WallOfFire.Damage"); + this.fireTicks = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.WallOfFire.FireTicks"); + } time = System.currentTimeMillis(); Block block = origin.getBlock(); diff --git a/src/com/projectkorra/projectkorra/firebending/combo/FireKick.java b/src/com/projectkorra/projectkorra/firebending/combo/FireKick.java index 9f3d1823..bd95ed80 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/FireKick.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/FireKick.java @@ -16,7 +16,6 @@ import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; -import com.projectkorra.projectkorra.avatar.AvatarState; public class FireKick extends FireAbility implements ComboAbility { @@ -28,7 +27,7 @@ public class FireKick extends FireAbility implements ComboAbility { private Location destination; private ArrayList affectedEntities; private ArrayList tasks; - + public FireKick(Player player) { super(player); @@ -38,30 +37,30 @@ public class FireKick extends FireAbility implements ComboAbility { this.affectedEntities = new ArrayList<>(); this.tasks = new ArrayList<>(); - - this.damage = getConfig().getDouble("Abilities.Fire.FireCombo.FireKick.Damage"); - this.range = getConfig().getDouble("Abilities.Fire.FireCombo.FireKick.Range"); - this.cooldown = getConfig().getLong("Abilities.Fire.FireCombo.FireKick.Cooldown"); - this.speed = getConfig().getLong("Abilities.Fire.FireCombo.FireKick.Speed");; - + + this.damage = getConfig().getDouble("Abilities.Fire.FireKick.Damage"); + this.range = getConfig().getDouble("Abilities.Fire.FireKick.Range"); + this.cooldown = getConfig().getLong("Abilities.Fire.FireKick.Cooldown"); + this.speed = getConfig().getLong("Abilities.Fire.FireKick.Speed"); + if (bPlayer.isAvatarState()) { this.cooldown = 0; - this.damage = AvatarState.getValue(damage); - this.range = AvatarState.getValue(range); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.Damage"); + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.Range"); } start(); } - @Override - public String getName() { - return "FireKick"; - } + @Override + public String getName() { + return "FireKick"; + } - @Override - public boolean isCollidable() { - return true; - } + @Override + public boolean isCollidable() { + return true; + } @Override public void progress() { @@ -122,7 +121,7 @@ public class FireKick extends FireAbility implements ComboAbility { task.cancel(); } } - + @Override public void handleCollision(Collision collision) { if (collision.isRemovingFirst()) { @@ -158,7 +157,7 @@ public class FireKick extends FireAbility implements ComboAbility { } return locations; } - + @Override public boolean isSneakAbility() { return true; @@ -192,7 +191,7 @@ public class FireKick extends FireAbility implements ComboAbility { public ArrayList getAffectedEntities() { return affectedEntities; } - + public ArrayList getTasks() { return tasks; } diff --git a/src/com/projectkorra/projectkorra/firebending/combo/FireSpin.java b/src/com/projectkorra/projectkorra/firebending/combo/FireSpin.java index 38c7a252..76433898 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/FireSpin.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/FireSpin.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -16,7 +17,6 @@ import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; -import com.projectkorra.projectkorra.avatar.AvatarState; public class FireSpin extends FireAbility implements ComboAbility { @@ -35,20 +35,25 @@ public class FireSpin extends FireAbility implements ComboAbility { if (!bPlayer.canBendIgnoreBindsCooldowns(this)) { return; } + + if (player.getLocation().getBlock().getType() == Material.WATER || player.getLocation().getBlock().getType() == Material.STATIONARY_WATER){ + return; + } this.affectedEntities = new ArrayList<>(); this.tasks = new ArrayList<>(); - this.damage = getConfig().getDouble("Abilities.Fire.FireCombo.FireSpin.Damage"); - this.range = getConfig().getDouble("Abilities.Fire.FireCombo.FireSpin.Range"); - this.cooldown = getConfig().getLong("Abilities.Fire.FireCombo.FireSpin.Cooldown"); - this.knockback = getConfig().getDouble("Abilities.Fire.FireCombo.FireSpin.Knockback"); - this.speed = getConfig().getDouble("Abilities.Fire.FireCombo.FireSpin.Speed"); + this.damage = getConfig().getDouble("Abilities.Fire.FireSpin.Damage"); + this.range = getConfig().getDouble("Abilities.Fire.FireSpin.Range"); + this.cooldown = getConfig().getLong("Abilities.Fire.FireSpin.Cooldown"); + this.knockback = getConfig().getDouble("Abilities.Fire.FireSpin.Knockback"); + this.speed = getConfig().getDouble("Abilities.Fire.FireSpin.Speed"); if (bPlayer.isAvatarState()) { this.cooldown = 0; - this.damage = AvatarState.getValue(damage); - this.range = AvatarState.getValue(range); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireSpin.Damage"); + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireSpin.Range"); + this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireSpin.Knockback"); } start(); @@ -195,4 +200,4 @@ public class FireSpin extends FireAbility implements ComboAbility { public void setTasks(ArrayList tasks) { this.tasks = tasks; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/firebending/combo/FireWheel.java b/src/com/projectkorra/projectkorra/firebending/combo/FireWheel.java index 55659d1e..a68221bf 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/FireWheel.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/FireWheel.java @@ -6,6 +6,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -15,9 +16,7 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.FireAbility; -import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; -import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.firebending.util.FireDamageTimer; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.ParticleEffect; @@ -44,13 +43,13 @@ public class FireWheel extends FireAbility implements ComboAbility { return; } - this.damage = getConfig().getDouble("Abilities.Fire.FireCombo.FireWheel.Damage"); - this.range = getConfig().getDouble("Abilities.Fire.FireCombo.FireWheel.Range"); - this.speed = getConfig().getDouble("Abilities.Fire.FireCombo.FireWheel.Speed"); - this.cooldown = getConfig().getLong("Abilities.Fire.FireCombo.FireWheel.Cooldown"); - this.fireTicks = getConfig().getDouble("Abilities.Fire.FireCombo.FireWheel.FireTicks"); - this.height = getConfig().getInt("Abilities.Fire.FireCombo.FireWheel.Height"); - this.radius = getConfig().getDouble("Abilities.Fire.FireCombo.FireWheel.Radius"); + this.damage = getConfig().getDouble("Abilities.Fire.FireWheel.Damage"); + this.range = getConfig().getDouble("Abilities.Fire.FireWheel.Range"); + this.speed = getConfig().getDouble("Abilities.Fire.FireWheel.Speed"); + this.cooldown = getConfig().getLong("Abilities.Fire.FireWheel.Cooldown"); + this.fireTicks = getConfig().getDouble("Abilities.Fire.FireWheel.FireTicks"); + this.height = getConfig().getInt("Abilities.Fire.FireWheel.Height"); + this.radius = getConfig().getDouble("Abilities.Fire.FireWheel.Radius"); bPlayer.addCooldown(this); origin = player.getLocation(); @@ -61,14 +60,19 @@ public class FireWheel extends FireAbility implements ComboAbility { return; } - location = player.getLocation(); - direction = player.getEyeLocation().getDirection().clone().normalize(); + location = player.getLocation().clone(); + location.setPitch(0); + direction = location.getDirection().clone().normalize(); direction.setY(0); if (bPlayer.isAvatarState()) { this.cooldown = 0; - this.damage = AvatarState.getValue(damage); - this.range = AvatarState.getValue(range); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireWheel.Damage"); + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireWheel.Range"); + this.speed = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireWheel.Speed"); + this.fireTicks = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireWheel.FireTicks"); + this.height = getConfig().getInt("Abilities.Avatar.AvatarState.Fire.FireWheel.Height"); + this.radius = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireWheel.Radius"); } start(); @@ -91,16 +95,19 @@ public class FireWheel extends FireAbility implements ComboAbility { return; } - Block topBlock = GeneralMethods.getTopBlock(location, 2, -4); + Block topBlock = GeneralMethods.getTopBlock(location, 2, 4); if (topBlock.getType().equals(Material.SNOW)) { - - topBlock = topBlock.getLocation().add(0, -1, 0).getBlock(); + topBlock.breakNaturally(); + topBlock = topBlock.getRelative(BlockFace.DOWN); } - if (topBlock == null || (WaterAbility.isWaterbendable(player, getName(), topBlock) && !isPlant(topBlock))) { + if (topBlock == null || isWater(topBlock)) { remove(); return; - } else if (topBlock.getType() == Material.FIRE || ElementalAbility.isPlant(topBlock)) { - topBlock = topBlock.getLocation().add(0, -1, 0).getBlock(); + } else if (topBlock.getType() == Material.FIRE) { + topBlock = topBlock.getRelative(BlockFace.DOWN); + } else if (ElementalAbility.isPlant(topBlock)) { + topBlock.breakNaturally(); + topBlock = topBlock.getRelative(BlockFace.DOWN); } location.setY(topBlock.getY() + height); @@ -112,7 +119,7 @@ public class FireWheel extends FireAbility implements ComboAbility { ParticleEffect.FLAME.display(tempLoc, 0, 0, 0, 0, 1); } - for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), 2)) { + for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 1.5)) { if (entity instanceof LivingEntity && !entity.equals(player)) { if (!affectedEntities.contains(entity)) { affectedEntities.add((LivingEntity) entity); @@ -155,4 +162,4 @@ public class FireWheel extends FireAbility implements ComboAbility { public ArrayList getAffectedEntities() { return affectedEntities; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java b/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java index ed3930d2..e5c6b030 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java @@ -10,7 +10,6 @@ import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; -import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.firebending.FireJet; import com.projectkorra.projectkorra.util.ParticleEffect; @@ -19,9 +18,7 @@ public class JetBlast extends FireAbility implements ComboAbility { private boolean firstTime; private long time; private long cooldown; - private double damage; private double speed; - private double range; private ArrayList tasks; private long duration; @@ -36,14 +33,12 @@ public class JetBlast extends FireAbility implements ComboAbility { this.time = System.currentTimeMillis(); this.tasks = new ArrayList<>(); - this.speed = getConfig().getDouble("Abilities.Fire.FireCombo.JetBlast.Speed"); - this.cooldown = getConfig().getLong("Abilities.Fire.FireCombo.JetBlast.Cooldown"); - this.duration = getConfig().getLong("Abilities.Fire.FireCombo.JetBlast.Duration"); + this.speed = getConfig().getDouble("Abilities.Fire.JetBlast.Speed"); + this.cooldown = getConfig().getLong("Abilities.Fire.JetBlast.Cooldown"); + this.duration = getConfig().getLong("Abilities.Fire.JetBlast.Duration"); if (bPlayer.isAvatarState()) { this.cooldown = 0; - this.damage = AvatarState.getValue(damage); - this.range = AvatarState.getValue(range); } start(); @@ -79,6 +74,7 @@ public class JetBlast extends FireAbility implements ComboAbility { } FireJet fj = getAbility(player, FireJet.class); fj.setSpeed(speed); + fj.setDuration(duration); FireComboStream fs = new FireComboStream(player, this, player.getVelocity().clone().multiply(-1), player.getLocation(), 3, 0.5); @@ -116,4 +112,4 @@ public class JetBlast extends FireAbility implements ComboAbility { return false; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java b/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java index 286f3397..a13c1154 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java @@ -12,7 +12,6 @@ import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; -import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.firebending.FireJet; import com.projectkorra.projectkorra.util.ParticleEffect; @@ -24,7 +23,6 @@ public class JetBlaze extends FireAbility implements ComboAbility { private long cooldown; private double damage; private double speed; - private double range; private double fireTicks; private Vector direction; private ArrayList affectedEntities; @@ -43,16 +41,16 @@ public class JetBlaze extends FireAbility implements ComboAbility { this.affectedEntities = new ArrayList<>(); this.tasks = new ArrayList<>(); - this.damage = getConfig().getDouble("Abilities.Fire.FireCombo.JetBlaze.Damage"); - this.duration = getConfig().getLong("Abilities.Fire.FireCombo.JetBlaze.Duration"); - this.speed = getConfig().getDouble("Abilities.Fire.FireCombo.JetBlaze.Speed"); - this.cooldown = getConfig().getLong("Abilities.Fire.FireCombo.JetBlaze.Cooldown"); - this.fireTicks = getConfig().getDouble("Abilities.Fire.FireCombo.JetBlaze.FireTicks"); + this.damage = getConfig().getDouble("Abilities.Fire.JetBlaze.Damage"); + this.duration = getConfig().getLong("Abilities.Fire.JetBlaze.Duration"); + this.speed = getConfig().getDouble("Abilities.Fire.JetBlaze.Speed"); + this.cooldown = getConfig().getLong("Abilities.Fire.JetBlaze.Cooldown"); + this.fireTicks = getConfig().getDouble("Abilities.Fire.JetBlaze.FireTicks"); if (bPlayer.isAvatarState()) { this.cooldown = 0; - this.damage = AvatarState.getValue(damage); - this.range = AvatarState.getValue(range); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.JetBlaze.Damage"); + this.fireTicks = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.JetBlaze.FireTicks"); } start(); @@ -84,6 +82,7 @@ public class JetBlaze extends FireAbility implements ComboAbility { direction = player.getVelocity().clone().multiply(-1); FireJet fj = getAbility(player, FireJet.class); fj.setSpeed(speed); + fj.setDuration(duration); FireComboStream fs = new FireComboStream(player, this, direction, player.getLocation(), 5, 1); fs.setDensity(8); @@ -129,4 +128,4 @@ public class JetBlaze extends FireAbility implements ComboAbility { public ArrayList getAffectedEntities() { return affectedEntities; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java b/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java index 0f55a838..6bbbf43b 100644 --- a/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java +++ b/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java @@ -2,9 +2,9 @@ package com.projectkorra.projectkorra.firebending.lightning; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import org.bukkit.Location; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -24,6 +24,7 @@ public class Lightning extends LightningAbility { } private static final int POINT_GENERATION = 5; + private static List paralyzed = new ArrayList<>(); private boolean charged; private boolean hitWater; @@ -121,36 +122,28 @@ public class Lightning extends LightningAbility { * @param lent The LivingEntity that is being damaged */ public void electrocute(LivingEntity lent) { - lent.getWorld().playSound(lent.getLocation(), Sound.ENTITY_CREEPER_HURT, 1, 0.01F); - player.getWorld().playSound(player.getLocation(), Sound.ENTITY_CREEPER_HURT, 1, 0.01F); + final UUID uuid = lent.getUniqueId(); + final LivingEntity flent = lent; + playLightningbendingSound(lent.getLocation()); + playLightningbendingSound(player.getLocation()); DamageHandler.damageEntity(lent, damage, this); - if (Math.random() < stunChance) { - final Location lentLoc = lent.getLocation(); - final LivingEntity flent = lent; - + if (Math.random() <= stunChance) { + paralyzed.add(uuid); + if (!(lent instanceof Player)) { + lent.setAI(false); + } new BukkitRunnable() { - int count = 0; @Override public void run() { - if (flent.isDead() || (flent instanceof Player && !((Player) flent).isOnline())) { - cancel(); - return; - } - - Location tempLoc = lentLoc.clone(); - Vector tempVel = flent.getVelocity(); - tempVel.setY(Math.min(0, tempVel.getY())); - tempLoc.setY(flent.getLocation().getY()); - flent.teleport(tempLoc); - flent.setVelocity(tempVel); - count++; - if (count > stunDuration) { - cancel(); + paralyzed.remove(uuid); + if (!(flent instanceof Player)) { + flent.setAI(true); } } - }.runTaskTimer(ProjectKorra.plugin, 0, 1); + + }.runTaskLater(ProjectKorra.plugin, (long) stunDuration); } } @@ -174,6 +167,10 @@ public class Lightning extends LightningAbility { } return false; } + + public static boolean isParalyzed(Entity e) { + return paralyzed.contains(e.getUniqueId()); + } /** * Progresses the instance of this ability by 1 tick. This is the heart of @@ -544,8 +541,8 @@ public class Lightning extends LightningAbility { affectedEntities.add(entity); LivingEntity lent = (LivingEntity) entity; if (lent instanceof Player) { - lent.getWorld().playSound(lent.getLocation(), Sound.ENTITY_CREEPER_HURT, 1, 0.01F); - player.getWorld().playSound(player.getLocation(), Sound.ENTITY_CREEPER_HURT, 1, 0.01F); + playLightningbendingSound(lent.getLocation()); + playLightningbendingSound(player.getLocation()); Player p = (Player) lent; Lightning light = getAbility(p, Lightning.class); if (light != null && light.state == State.START) { diff --git a/src/com/projectkorra/projectkorra/util/DamageHandler.java b/src/com/projectkorra/projectkorra/util/DamageHandler.java index f1575b71..52354db5 100644 --- a/src/com/projectkorra/projectkorra/util/DamageHandler.java +++ b/src/com/projectkorra/projectkorra/util/DamageHandler.java @@ -14,6 +14,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; public class DamageHandler { @@ -27,7 +28,9 @@ public class DamageHandler { */ @SuppressWarnings("deprecation") public static void damageEntity(Entity entity, Player source, double damage, Ability ability, boolean ignoreArmor) { - + if (TempArmor.hasTempArmor((LivingEntity) entity)) { + ignoreArmor = true; + } if (ability == null) { return; } @@ -45,6 +48,11 @@ public class DamageHandler { damage = damageEvent.getDamage(); if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) { NCPExemptionManager.exemptPermanently(source, CheckType.FIGHT_REACH); + NCPExemptionManager.exemptPermanently(source, CheckType.FIGHT_DIRECTION); + NCPExemptionManager.exemptPermanently(source, CheckType.FIGHT_NOSWING); + NCPExemptionManager.exemptPermanently(source, CheckType.FIGHT_SPEED); + NCPExemptionManager.exemptPermanently(source, CheckType.COMBINED_IMPROBABLE); + NCPExemptionManager.exemptPermanently(source, CheckType.FIGHT_SELFHIT); } if (((LivingEntity) entity).getHealth() - damage <= 0 && !entity.isDead()) { @@ -52,17 +60,22 @@ public class DamageHandler { Bukkit.getServer().getPluginManager().callEvent(event); } - DamageCause cause = DamageCause.CUSTOM; - if (ignoreArmor) { - cause = DamageCause.MAGIC; - } - - EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(source, entity, cause, damage); + EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(source, entity, DamageCause.CUSTOM, damage); ((LivingEntity) entity).damage(damage, source); entity.setLastDamageCause(finalEvent); + if (ignoreArmor) { + if (finalEvent.isApplicable(DamageModifier.ARMOR)) { + finalEvent.setDamage(DamageModifier.ARMOR, 0); + } + } if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) { - NCPExemptionManager.unexempt(source); + NCPExemptionManager.unexempt(source, CheckType.FIGHT_REACH); + NCPExemptionManager.unexempt(source, CheckType.FIGHT_DIRECTION); + NCPExemptionManager.unexempt(source, CheckType.FIGHT_NOSWING); + NCPExemptionManager.unexempt(source, CheckType.FIGHT_SPEED); + NCPExemptionManager.unexempt(source, CheckType.COMBINED_IMPROBABLE); + NCPExemptionManager.unexempt(source, CheckType.FIGHT_SELFHIT); } } } diff --git a/src/com/projectkorra/projectkorra/util/Flight.java b/src/com/projectkorra/projectkorra/util/Flight.java index da25efc7..a7d49070 100644 --- a/src/com/projectkorra/projectkorra/util/Flight.java +++ b/src/com/projectkorra/projectkorra/util/Flight.java @@ -13,7 +13,6 @@ import com.projectkorra.projectkorra.airbending.AirScooter; import com.projectkorra.projectkorra.airbending.AirSpout; import com.projectkorra.projectkorra.airbending.Tornado; import com.projectkorra.projectkorra.earthbending.Catapult; -import com.projectkorra.projectkorra.earthbending.sand.SandSpout; import com.projectkorra.projectkorra.firebending.FireJet; import com.projectkorra.projectkorra.waterbending.WaterSpout; import com.projectkorra.projectkorra.waterbending.blood.Bloodbending; @@ -69,7 +68,6 @@ public class Flight { Set airScooterPlayers = CoreAbility.getPlayers(AirScooter.class); Set waterSpoutPlayers = CoreAbility.getPlayers(WaterSpout.class); Set airSpoutPlayers = CoreAbility.getPlayers(AirSpout.class); - Set sandSpoutPlayers = CoreAbility.getPlayers(SandSpout.class); players.addAll(CoreAbility.getPlayers(Tornado.class)); players.addAll(CoreAbility.getPlayers(FireJet.class)); @@ -78,7 +76,7 @@ public class Flight { for (Player player : instances.keySet()) { Flight flight = instances.get(player); if (System.currentTimeMillis() <= flight.time + duration) { - if (airScooterPlayers.contains(player) || waterSpoutPlayers.contains(player) || airSpoutPlayers.contains(player) || sandSpoutPlayers.contains(player)) { + if (airScooterPlayers.contains(player) || waterSpoutPlayers.contains(player) || airSpoutPlayers.contains(player)) { continue; } if (Bloodbending.isBloodbent(player)) { diff --git a/src/com/projectkorra/projectkorra/util/TempBlock.java b/src/com/projectkorra/projectkorra/util/TempBlock.java index dbc3e9ee..a734bad4 100644 --- a/src/com/projectkorra/projectkorra/util/TempBlock.java +++ b/src/com/projectkorra/projectkorra/util/TempBlock.java @@ -31,6 +31,7 @@ public class TempBlock { private BlockState state; private long revertTime; private boolean inRevertQueue; + private RevertTask revertTask = null; @SuppressWarnings("deprecation") public TempBlock(Block block, Material newtype, byte newdata) { @@ -120,6 +121,14 @@ public class TempBlock { public BlockState getState() { return state; } + + public RevertTask getRevertTask() { + return revertTask; + } + + public void setRevertTask(RevertTask task) { + this.revertTask = task; + } public long getRevertTime() { return revertTime; @@ -137,6 +146,12 @@ public class TempBlock { public void revertBlock() { state.update(true); instances.remove(block); + if (REVERT_QUEUE.contains(this)) { + REVERT_QUEUE.remove(this); + } + if (revertTask != null) { + revertTask.run(); + } } public void setState(BlockState newstate) { @@ -173,6 +188,9 @@ public class TempBlock { } } }.runTaskTimer(ProjectKorra.plugin, 0, 1); - + } + + public interface RevertTask { + public void run(); } } \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java b/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java index 2c51a241..f330cd8b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java +++ b/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java @@ -101,6 +101,13 @@ public class OctopusForm extends WaterAbility { } else { this.pc = new PhaseChange(player, PhaseChangeType.CUSTOM); } + + if (bPlayer.isAvatarState()) { + this.damage = getConfig().getInt("Abilities.Avatar.AvatarState.Water.OctopusForm.Damage"); + this.attackRange = getConfig().getInt("Abilities.Avatar.AvatarState.Water.OctopusForm.AttackRange"); + this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.OctopusForm.Knockback"); + this.radius = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.OctopusForm.Radius"); + } this.time = System.currentTimeMillis(); if (!player.isSneaking()) { this.sourceBlock = BlockSource.getWaterSourceBlock(player, range, ClickType.LEFT_CLICK, true, true, bPlayer.canPlantbend()); @@ -689,4 +696,4 @@ public class OctopusForm extends WaterAbility { this.cooldown = cooldown; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java b/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java index 8222889b..c792dea8 100644 --- a/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java +++ b/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java @@ -218,7 +218,7 @@ public class SurgeWall extends WaterAbility { if (System.currentTimeMillis() - time >= interval) { time = System.currentTimeMillis(); - boolean matchesName = bPlayer.getBoundAbilityName().equalsIgnoreCase(getName()); + boolean matchesName = bPlayer.getBoundAbilityName().equals(getName()); if (!progressing && !matchesName) { remove(); diff --git a/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java b/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java index 3f82f60a..c21dd9d7 100644 --- a/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java @@ -23,6 +23,7 @@ import com.projectkorra.projectkorra.firebending.FireBlast; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.TempBlock; +import com.projectkorra.projectkorra.util.TempBlock.RevertTask; import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; @@ -136,7 +137,7 @@ public class SurgeWave extends WaterAbility { freezeradius = maxFreezeRadius; } - for (Block block : GeneralMethods.getBlocksAroundPoint(frozenLocation, freezeradius)) { + for (final Block block : GeneralMethods.getBlocksAroundPoint(frozenLocation, freezeradius)) { if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation()) || GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) { continue; } else if (TempBlock.isTempBlock(block)) { @@ -144,17 +145,26 @@ public class SurgeWave extends WaterAbility { } Block oldBlock = block; + TempBlock tblock = new TempBlock(block, block.getType(), (byte) 0); if (block.getType() == Material.AIR || block.getType() == Material.SNOW || isWater(block)) { - TempBlock tblock = new TempBlock(block, Material.ICE, (byte) 0); - tblock.setRevertTime(iceRevertTime + (new Random().nextInt(1000))); - frozenBlocks.put(block, oldBlock.getType()); - } - if (isPlant(block) && block.getType() != Material.LEAVES) { + tblock.setType(Material.ICE); + } else if (isPlant(block) && block.getType() != Material.LEAVES) { block.breakNaturally(); - TempBlock tblock = new TempBlock(block, Material.ICE, (byte) 0); - tblock.setRevertTime(iceRevertTime + (new Random().nextInt(1000))); - frozenBlocks.put(block, oldBlock.getType()); + tblock.setType(Material.ICE); + } else { + tblock.revertBlock(); + continue; } + tblock.setRevertTask(new RevertTask() { + + @Override + public void run() { + frozenBlocks.remove(block); + } + + }); + tblock.setRevertTime(iceRevertTime + (new Random().nextInt(1000))); + frozenBlocks.put(block, oldBlock.getType()); for (Block sound : frozenBlocks.keySet()) { if ((new Random()).nextInt(4) == 0) { playWaterbendingSound(sound.getLocation()); @@ -239,7 +249,7 @@ public class SurgeWave extends WaterAbility { if (System.currentTimeMillis() - time >= interval) { time = System.currentTimeMillis(); - if (!progressing && !bPlayer.getBoundAbilityName().equalsIgnoreCase(getName())) { + if (!progressing && !bPlayer.getBoundAbilityName().equals(getName())) { remove(); return; } else if (!progressing) { @@ -363,8 +373,9 @@ public class SurgeWave extends WaterAbility { private void thaw() { if (frozenBlocks != null) { for (Block block : frozenBlocks.keySet()) { - TempBlock.revertBlock(block, frozenBlocks.get(block)); - frozenBlocks.remove(block); + if (TempBlock.isTempBlock(block)) { + TempBlock.get(block).revertBlock(); + } } } } @@ -385,8 +396,9 @@ public class SurgeWave extends WaterAbility { surgeWave.waveBlocks.remove(block); } for (Block block : surgeWave.frozenBlocks.keySet()) { - TempBlock.revertBlock(block, Material.AIR); - surgeWave.frozenBlocks.remove(block); + if (TempBlock.isTempBlock(block)) { + TempBlock.get(block).revertBlock(); + } } } } @@ -403,8 +415,10 @@ public class SurgeWave extends WaterAbility { public static void thaw(Block block) { for (SurgeWave surgeWave : getAbilities(SurgeWave.class)) { if (surgeWave.frozenBlocks.containsKey(block)) { - TempBlock.revertBlock(block, Material.AIR); - surgeWave.frozenBlocks.remove(block); + if (TempBlock.isTempBlock(block)) { + TempBlock tb = TempBlock.get(block); + tb.revertBlock(); + } } } } diff --git a/src/com/projectkorra/projectkorra/waterbending/Torrent.java b/src/com/projectkorra/projectkorra/waterbending/Torrent.java index 42c1b388..cdedbc46 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Torrent.java +++ b/src/com/projectkorra/projectkorra/waterbending/Torrent.java @@ -103,6 +103,13 @@ public class Torrent extends WaterAbility { if (bPlayer.isOnCooldown("Torrent")) { return; } + + if (bPlayer.isAvatarState()) { + this.push = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.Torrent.Push"); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.Torrent.InitialDamage"); + this.successiveDamage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.Torrent.SuccessiveDamage"); + this.maxHits = getConfig().getInt("Abilities.Avatar.AvatarState.Water.Torrent.MaxHits"); + } time = System.currentTimeMillis(); sourceBlock = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.LEFT_CLICK, true, true, bPlayer.canPlantbend()); diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java b/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java index c754c2e8..d3c7a6e9 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java @@ -138,8 +138,10 @@ public class WaterBubble extends WaterAbility { set.removeAll(list); for (Block b : set) { - b.setType(waterOrigins.get(b).getItemType()); - b.setData(waterOrigins.get(b).getData()); + if (b.getType() == Material.AIR) { + b.setType(waterOrigins.get(b).getItemType()); + b.setData(waterOrigins.get(b).getData()); + } waterOrigins.remove(b); } } @@ -173,8 +175,10 @@ public class WaterBubble extends WaterAbility { super.remove(); for (Block b : waterOrigins.keySet()) { - b.setType(waterOrigins.get(b).getItemType()); - b.setData(waterOrigins.get(b).getData()); + if (b.getType() == Material.AIR) { + b.setType(waterOrigins.get(b).getItemType()); + b.setData(waterOrigins.get(b).getData()); + } } } @@ -193,4 +197,4 @@ public class WaterBubble extends WaterAbility { return true; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java b/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java index 055c8481..05be2947 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java @@ -78,16 +78,16 @@ public class WaterSpoutWave extends WaterAbility { this.plant = getConfig().getBoolean("Abilities.Water.WaterSpout.Wave.AllowPlantSource"); this.radius = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.Radius"); this.waveRadius = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.WaveRadius"); - this.thawRadius = getConfig().getDouble("Abilities.Water.WaterCombo.IceWave.ThawRadius"); + this.thawRadius = getConfig().getDouble("Abilities.Water.IceWave.ThawRadius"); this.animationSpeed = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.AnimationSpeed"); this.selectRange = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.SelectRange"); this.speed = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.Speed"); - this.damage = getConfig().getDouble("Abilities.Water.WaterCombo.IceWave.Damage"); + this.damage = getConfig().getDouble("Abilities.Water.IceWave.Damage"); this.chargeTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.ChargeTime"); this.flightTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.FlightTime"); this.cooldown = getConfig().getLong("Abilities.Water.WaterSpout.Wave.Cooldown"); - this.revertSphereTime = getConfig().getLong("Abilities.Water.WaterCombo.IceWave.RevertSphereTime"); - this.revertIceSphere = getConfig().getBoolean("Abilities.Water.WaterCombo.IceWave.RevertSphere"); + this.revertSphereTime = getConfig().getLong("Abilities.Water.IceWave.RevertSphereTime"); + this.revertIceSphere = getConfig().getBoolean("Abilities.Water.IceWave.RevertSphere"); this.affectedBlocks = new ConcurrentHashMap<>(); this.affectedEntities = new ArrayList<>(); this.tasks = new ArrayList<>(); @@ -97,6 +97,13 @@ public class WaterSpoutWave extends WaterAbility { if (!bPlayer.canBend(this)) { return; } + + if (bPlayer.isAvatarState()) { + this.chargeTime = 0; + this.flightTime = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.WaterWave.FlightTime"); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceWave.Damage"); + this.cooldown = 0; + } this.time = System.currentTimeMillis(); this.type = type; @@ -124,12 +131,17 @@ public class WaterSpoutWave extends WaterAbility { remove(); return; } + + if (CoreAbility.hasAbility(player, WaterSpout.class)) { + WaterSpout waterSpout = CoreAbility.getAbility(player, WaterSpout.class); + waterSpout.remove(); + } if (type != AbilityType.RELEASE) { if (!player.hasPermission("bending.ability.WaterSpout.Wave")) { remove(); return; - } else if (!bPlayer.getBoundAbilityName().equalsIgnoreCase(getName())) { + } else if (!bPlayer.getBoundAbilityName().equals(getName())) { remove(); return; } diff --git a/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java b/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java index fdb83e09..acc170af 100644 --- a/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java +++ b/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java @@ -38,11 +38,12 @@ public class Bloodbending extends BloodAbility { private long cooldown; private double throwFactor; private Entity target; + private Vector vector; public Bloodbending(Player player) { super(player); - Bloodbending ability = getAbility(player, getClass()); + Bloodbending ability = getAbility(player, Bloodbending.class); if (ability != null) { ability.remove(); return; @@ -56,6 +57,7 @@ public class Bloodbending extends BloodAbility { this.holdTime = getConfig().getInt("Abilities.Water.Bloodbending.HoldTime"); this.cooldown = getConfig().getInt("Abilities.Water.Bloodbending.Cooldown"); this.throwFactor = getConfig().getDouble("Abilities.Water.Bloodbending.ThrowFactor"); + vector = new Vector(0, 0, 0); if (canOnlyBeUsedAtNight && !isNight(player.getWorld()) && !bPlayer.canBloodbendAtAnytime()) { return; @@ -108,12 +110,14 @@ public class Bloodbending extends BloodAbility { if (target == null || !(target instanceof LivingEntity) || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation()) || target.getEntityId() == player.getEntityId()) { return; } else if (target instanceof Player) { - BendingPlayer targetBPlayer = BendingPlayer.getBendingPlayer(player); + BendingPlayer targetBPlayer = BendingPlayer.getBendingPlayer((Player) target); if (targetBPlayer != null) { - if ((targetBPlayer.canBendIgnoreBindsCooldowns(ability) && !canBloodbendOtherBloodbenders) || targetBPlayer.isAvatarState()) { - if (!isDay(target.getWorld()) || targetBPlayer.canBloodbendAtAnytime()) { - return; - } + if (targetBPlayer.canBloodbend() && !canBloodbendOtherBloodbenders) { + return; + } else if (targetBPlayer.isAvatarState()) { + return; + } else if (targetBPlayer.canBloodbendAtAnytime() && !canBloodbendOtherBloodbenders) { + return; } } } else if (!canBeUsedOnUndeadMobs && isUndead(target)) { @@ -213,7 +217,7 @@ public class Bloodbending extends BloodAbility { continue; } if (entity instanceof LivingEntity) { - entity.setVelocity(new Vector(0, 0, 0)); + entity.setVelocity(vector); new TempPotionEffect((LivingEntity) entity, effect); entity.setFallDistance(0); if (entity instanceof Creature) { @@ -229,16 +233,15 @@ public class Bloodbending extends BloodAbility { } } } else { - if (TARGETED_ENTITIES.get(target) != player) { - remove(); - return; - } for (Entity entity : TARGETED_ENTITIES.keySet()) { if (entity instanceof Player) { BendingPlayer targetBPlayer = BendingPlayer.getBendingPlayer((Player) entity); if (targetBPlayer != null && !targetBPlayer.canBeBloodbent()) { TARGETED_ENTITIES.remove(entity); continue; + } else if (targetBPlayer.isAvatarState()) { + TARGETED_ENTITIES.remove(entity); + continue; } } @@ -248,6 +251,16 @@ public class Bloodbending extends BloodAbility { continue; } } + + if (!TARGETED_ENTITIES.containsKey(target)) { + remove(); + return; + } + + if (TARGETED_ENTITIES.get(target) != player) { + remove(); + return; + } Location location = GeneralMethods.getTargetedLocation(player, 6, getTransparentMaterial()); double distance = 0; @@ -258,13 +271,14 @@ public class Bloodbending extends BloodAbility { dx = location.getX() - target.getLocation().getX(); dy = location.getY() - target.getLocation().getY(); dz = location.getZ() - target.getLocation().getZ(); - Vector vector = new Vector(dx, dy, dz); + vector = new Vector(dx, dy, dz); + vector.normalize().multiply(.5); - if (distance > .5) { - target.setVelocity(vector.normalize().multiply(.5)); - } else { - target.setVelocity(new Vector(0, 0, 0)); + if (distance < .6) { + vector = new Vector(0, 0, 0); } + + target.setVelocity(vector); new TempPotionEffect((LivingEntity) target, effect); target.setFallDistance(0); @@ -298,6 +312,24 @@ public class Bloodbending extends BloodAbility { public static Location getBloodbendingLocation(Entity entity) { return entity != null ? TARGETED_ENTITIES.get(entity).getLocation() : null; } + + public static Vector getBloodbendingVector(Entity entity) { + if (!TARGETED_ENTITIES.containsKey(entity)) { + return null; + } + + Bloodbending bb = getAbility(TARGETED_ENTITIES.get(entity), Bloodbending.class); + return bb.vector; + } + + public static BendingPlayer getBloodbender(Entity entity) { + if (!TARGETED_ENTITIES.containsKey(entity)) { + return null; + } + + Bloodbending bb = getAbility(TARGETED_ENTITIES.get(entity), Bloodbending.class); + return bb.getBendingPlayer(); + } @Override public String getName() { diff --git a/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java b/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java index 08fda4a3..e1e72a75 100644 --- a/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java +++ b/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java @@ -43,7 +43,6 @@ public class IceBullet extends IceAbility implements ComboAbility { private double damage; private double speed; private double range; - private double knockback; private double radius; private double shootTime; private double shots; @@ -71,13 +70,13 @@ public class IceBullet extends IceAbility implements ComboAbility { return; } - this.damage = getConfig().getDouble("Abilities.Water.WaterCombo.IceBullet.Damage"); - this.range = getConfig().getDouble("Abilities.Water.WaterCombo.IceBullet.Range"); - this.radius = getConfig().getDouble("Abilities.Water.WaterCombo.IceBullet.Radius"); - this.cooldown = getConfig().getLong("Abilities.Water.WaterCombo.IceBullet.Cooldown"); - this.shootTime = getConfig().getLong("Abilities.Water.WaterCombo.IceBullet.ShootTime"); - this.maxShots = getConfig().getInt("Abilities.Water.WaterCombo.IceBullet.MaxShots"); - this.animationSpeed = getConfig().getDouble("Abilities.Water.WaterCombo.IceBullet.AnimationSpeed"); + this.damage = getConfig().getDouble("Abilities.Water.IceBullet.Damage"); + this.range = getConfig().getDouble("Abilities.Water.IceBullet.Range"); + this.radius = getConfig().getDouble("Abilities.Water.IceBullet.Radius"); + this.cooldown = getConfig().getLong("Abilities.Water.IceBullet.Cooldown"); + this.shootTime = getConfig().getLong("Abilities.Water.IceBullet.ShootTime"); + this.maxShots = getConfig().getInt("Abilities.Water.IceBullet.MaxShots"); + this.animationSpeed = getConfig().getDouble("Abilities.Water.IceBullet.AnimationSpeed"); this.speed = 1; this.name = getName(); @@ -98,7 +97,6 @@ public class IceBullet extends IceAbility implements ComboAbility { this.range = AvatarState.getValue(range); this.shootTime = AvatarState.getValue(shootTime); this.maxShots = AvatarState.getValue(maxShots); - this.knockback = knockback * 1.3; } start(); @@ -202,10 +200,6 @@ public class IceBullet extends IceAbility implements ComboAbility { } if (!entity.equals(player)) { - if (knockback != 0) { - Vector force = fstream.getDirection(); - entity.setVelocity(force.multiply(knockback)); - } if (damage != 0) { if (entity instanceof LivingEntity) { DamageHandler.damageEntity(entity, damage, this); @@ -439,14 +433,6 @@ public class IceBullet extends IceAbility implements ComboAbility { this.range = range; } - public double getKnockback() { - return knockback; - } - - public void setKnockback(double knockback) { - this.knockback = knockback; - } - public double getRadius() { return radius; } @@ -550,4 +536,4 @@ public class IceBullet extends IceAbility implements ComboAbility { public void setName(String name) { this.name = name; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java b/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java index e5b438fd..8e0aeb72 100644 --- a/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java @@ -33,7 +33,7 @@ public class IceWave extends IceAbility implements ComboAbility { return; } - this.cooldown = getConfig().getLong("Abilities.Water.WaterCombo.IceWave.Cooldown"); + this.cooldown = getConfig().getLong("Abilities.Water.IceWave.Cooldown"); if (bPlayer.isAvatarState()) { this.cooldown = 0; @@ -119,4 +119,4 @@ public class IceWave extends IceAbility implements ComboAbility { public ArrayList getCombination() { return null; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java b/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java index 99c0e045..3cb0d20c 100644 --- a/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java +++ b/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java @@ -92,11 +92,13 @@ public class HealingWaters extends HealingAbility { } if (!player.isSneaking()) { + bPlayer.addCooldown(this); remove(); return; } if (!inWater(player) && !WaterReturn.hasWaterBottle(player) && !charged) { + bPlayer.addCooldown(this); remove(); return; } diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java index 5637fa7e..4358a4b8 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java @@ -61,6 +61,12 @@ public class IceBlast extends IceAbility { if (!bPlayer.canBend(this) || !bPlayer.canIcebend()) { return; } + + if (bPlayer.isAvatarState()) { + this.cooldown = 0; + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceBlast.Range"); + this.damage = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceBlast.Damage"); + } block(player); range = getNightFactor(range, player.getWorld()); diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java index b91a378d..61ab4537 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java @@ -66,6 +66,15 @@ public class IceSpikeBlast extends IceAbility { if (!bPlayer.canBend(this) || !bPlayer.canIcebend()) { return; } + + if (bPlayer.isAvatarState()) { + this.cooldown = 0; + this.slowCooldown = 0; + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.Range"); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.Damage"); + this.slowPower = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.SlowPower"); + this.slowDuration = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.SlowDuration"); + } block(player); this.range = getNightFactor(range); diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java index 7b6669ad..e5337b8b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java @@ -134,6 +134,15 @@ public class IceSpikePillar extends IceAbility { this.damaged = new ArrayList<>(); this.interval = (long) (1000. / speed); + + if (bPlayer.isAvatarState()) { + this.slowPower = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.SlowPower"); + this.slowDuration = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.SlowDuration"); + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Damage"); + this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Range"); + this.height = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.Height"); + this.thrownForce = new Vector(0, getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Push"), 0); + } } /** diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java index 16f24871..f9fa07f1 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java @@ -1,9 +1,8 @@ package com.projectkorra.projectkorra.waterbending.ice; -import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.IceAbility; -import com.projectkorra.projectkorra.ability.WaterAbility; -import com.projectkorra.projectkorra.util.TempBlock; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; import org.bukkit.Location; import org.bukkit.Material; @@ -14,9 +13,10 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; +import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ability.IceAbility; +import com.projectkorra.projectkorra.ability.WaterAbility; +import com.projectkorra.projectkorra.util.TempBlock; public class IceSpikePillarField extends IceAbility { @@ -35,9 +35,16 @@ public class IceSpikePillarField extends IceAbility { this.damage = getConfig().getDouble("Abilities.Water.IceSpike.Field.Damage"); this.radius = getConfig().getDouble("Abilities.Water.IceSpike.Field.Radius"); - this.numberOfSpikes = (int) (((radius * 2) * (radius * 2)) / 16); this.cooldown = getConfig().getLong("Abilities.Water.IceSpike.Field.Cooldown"); this.thrownForce = new Vector(0, getConfig().getDouble("Abilities.Water.IceSpike.Field.Push"), 0); + + if (bPlayer.isAvatarState()) { + this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Field.Damage"); + this.radius = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Field.Radius"); + this.thrownForce = new Vector(0, getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Field.Push"), 0); + } + + this.numberOfSpikes = (int) (((radius * 2) * (radius * 2)) / 16); Random random = new Random(); int locX = player.getLocation().getBlockX(); @@ -52,7 +59,7 @@ public class IceSpikePillarField extends IceAbility { if (WaterAbility.isIcebendable(player, testBlock.getType(), false) && testBlock.getRelative(BlockFace.UP).getType() == Material.AIR && !(testBlock.getX() == player.getEyeLocation().getBlock().getX() && testBlock.getZ() == player.getEyeLocation().getBlock().getZ()) - && !TempBlock.isTempBlock(testBlock)) { + || (TempBlock.isTempBlock(testBlock) && WaterAbility.isBendableWaterTempBlock(testBlock))) { iceBlocks.add(testBlock); for (int i = 0; i < iceBlocks.size() / 2 + 1; i++) { Random rand = new Random(); @@ -94,6 +101,7 @@ public class IceSpikePillarField extends IceAbility { } if (targetBlock.getRelative(BlockFace.UP).getType() != Material.ICE) { + IceSpikePillar pillar = new IceSpikePillar(player, targetBlock.getLocation(), (int) damage, thrownForce, cooldown); pillar.inField = true; bPlayer.addCooldown("IceSpikePillarField", cooldown); @@ -167,4 +175,4 @@ public class IceSpikePillarField extends IceAbility { this.cooldown = cooldown; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java b/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java index f014d977..5bb98d9b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java @@ -323,6 +323,7 @@ public class PhaseChange extends IceAbility { for (Location l : GeneralMethods.getCircle(center, radius, 3, true, true, 0)) { if (isIce(l.getBlock()) || isSnow(l.getBlock())) { ice.add(l.getBlock()); + } } @@ -404,7 +405,7 @@ public class PhaseChange extends IceAbility { Material m = allowMeltFlow ? Material.WATER : Material.STATIONARY_WATER; b.setType(m); melted_blocks.add(b); - } else if (b.getType() == Material.SNOW) { + } else if (b.getType() == Material.SNOW_BLOCK || b.getType() == Material.SNOW) { if (b.getData() == 0) { new TempBlock(b, Material.AIR, (byte) 0).setRevertTime(120 * 1000L); } else { @@ -568,4 +569,4 @@ public class PhaseChange extends IceAbility { public List getActiveTypes() { return active_types; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java index d89cd1ba..03556757 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java @@ -1,5 +1,18 @@ package com.projectkorra.projectkorra.waterbending.multiabilities; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +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.entity.Player; + import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.FireAbility; @@ -14,19 +27,6 @@ import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArmsWhip.W import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - public class WaterArms extends WaterAbility { /** @@ -92,7 +92,6 @@ public class WaterArms extends WaterAbility { if (player.isSneaking()) { oldArms.prepareCancel(); } else { - switch (player.getInventory().getHeldItemSlot()) { case 0: if (player.hasPermission("bending.ability.WaterArms.Pull")) { @@ -156,7 +155,7 @@ public class WaterArms extends WaterAbility { fullSource = false; } - ParticleEffect.LARGE_SMOKE.display(getWaterSourceBlock(player, sourceGrabRange, canUsePlantSource).getLocation().clone().add(0.5, 0.5, 0.5), 0, 0, 0, 0F, 4); + ParticleEffect.LARGE_SMOKE.display(sourceBlock.getLocation().clone().add(0.5, 0.5, 0.5), 0, 0, 0, 0F, 4); return true; } else if (WaterReturn.hasWaterBottle(player)) { WaterReturn.emptyWaterBottle(player); @@ -396,6 +395,7 @@ public class WaterArms extends WaterAbility { if (player.isOnline()) { bPlayer.addCooldown("WaterArms", cooldown); } + new WaterReturn(player, player.getLocation().getBlock()); } public void prepareCancel() { @@ -743,4 +743,4 @@ public class WaterArms extends WaterAbility { this.activeArm = activeArm; } -} +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java b/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java index ecabcd2d..84dc650d 100644 --- a/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java +++ b/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java @@ -12,24 +12,32 @@ import com.projectkorra.projectkorra.waterbending.WaterSpout; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms; public class FastSwim extends WaterAbility implements PassiveAbility { - + + private long cooldown; private double swimSpeed; public FastSwim(Player player) { super(player); + this.cooldown = ConfigManager.getConfig().getLong("Abilities.Water.Passive.FastSwim.Cooldown"); this.swimSpeed = ConfigManager.getConfig().getDouble("Abilities.Water.Passive.FastSwim.SpeedFactor"); } @Override public void progress() { + if (bPlayer.isOnCooldown(this)) { + return; + } if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, EarthArmor.class)) { return; } else if (CoreAbility.hasAbility(player, WaterArms.class)) { return; } else if (bPlayer.getBoundAbility() == null || (bPlayer.getBoundAbility() != null && !bPlayer.getBoundAbility().isSneakAbility())) { if (player.isSneaking() && WaterAbility.isWater(player.getLocation().getBlock())) { - player.setVelocity(player.getEyeLocation().getDirection().clone().normalize().multiply(swimSpeed)); + player.setVelocity(player.getEyeLocation().getDirection().clone().normalize().multiply(swimSpeed)); + } + else if (!player.isSneaking()) { + bPlayer.addCooldown(this); } } } @@ -46,7 +54,7 @@ public class FastSwim extends WaterAbility implements PassiveAbility { @Override public long getCooldown() { - return 0; + return cooldown; } @Override diff --git a/src/plugin.yml b/src/plugin.yml index f271a3a5..fbfec640 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -241,4 +241,7 @@ permissions: description: Grants access to all water passives. children: bending.ability.FastSwim: true - bending.ability.Hydrosink: true \ No newline at end of file + bending.ability.Hydrosink: true + bending.donor: + default: false + description: Grants the Donor tag. \ No newline at end of file