From c6d56bd9ce7fe30aa8d9ffe1943079450fea745e Mon Sep 17 00:00:00 2001 From: jayoevans Date: Mon, 11 Nov 2019 14:24:46 +1000 Subject: [PATCH] Setup ability handler system --- .../projectkorra/BendingManager.java | 9 +- .../projectkorra/BendingPlayer.java | 4 +- .../projectkorra/GeneralMethods.java | 421 ++++-------------- .../projectkorra/projectkorra/PKListener.java | 14 +- .../projectkorra/ability/Ability.java | 19 +- .../projectkorra/ability/AbilityHandler.java | 77 ++++ .../projectkorra/ability/AbilityManager.java | 303 ++++++------- .../ability/ComboAbilityManager.java | 64 +-- .../ability/MultiAbilityManager.java | 86 ++-- .../ability/PassiveAbilityManager.java | 53 +-- .../AddonAbility.java} | 4 +- .../ability/api/AvatarAbility.java | 30 +- .../projectkorra/ability/api/ChiAbility.java | 22 - .../ComboAbility.java} | 4 +- .../MultiAbility.java} | 8 +- .../PassiveAbility.java} | 4 +- .../ability/bind/AbilityBindManager.java | 122 ++++- .../ability/info/AbilityInfo.java | 35 -- .../ability/info/AvatarAbilityInfo.java | 6 - .../ability/{api => legacy}/AirAbility.java | 20 +- .../ability/legacy/AvatarAbility.java | 32 ++ .../ability/{api => legacy}/BloodAbility.java | 2 +- .../ability/legacy/ChiAbility.java | 22 + .../{api => legacy}/CombustionAbility.java | 2 +- .../ability/{api => legacy}/EarthAbility.java | 2 +- .../{api => legacy}/ElementalAbility.java | 10 +- .../ability/{api => legacy}/FireAbility.java | 2 +- .../{api => legacy}/FlightAbility.java | 2 +- .../{api => legacy}/HealingAbility.java | 2 +- .../ability/{api => legacy}/IceAbility.java | 2 +- .../ability/{api => legacy}/LavaAbility.java | 2 +- .../{api => legacy}/LightningAbility.java | 2 +- .../ability/{api => legacy}/MetalAbility.java | 2 +- .../ability/{api => legacy}/PlantAbility.java | 2 +- .../ability/{api => legacy}/SandAbility.java | 2 +- .../{api => legacy}/SpiritualAbility.java | 2 +- .../ability/{api => legacy}/SubAbility.java | 2 +- .../ability/{api => legacy}/WaterAbility.java | 2 +- .../ability/util/CollisionManager.java | 2 +- .../projectkorra/airbending/AirBlast.java | 2 +- .../projectkorra/airbending/AirBurst.java | 2 +- .../projectkorra/airbending/AirScooter.java | 4 +- .../projectkorra/airbending/AirShield.java | 2 +- .../projectkorra/airbending/AirSpout.java | 4 +- .../projectkorra/airbending/AirSuction.java | 2 +- .../projectkorra/airbending/AirSwipe.java | 4 +- .../projectkorra/airbending/Suffocate.java | 2 +- .../projectkorra/airbending/Tornado.java | 4 +- .../airbending/combo/AirStream.java | 2 +- .../airbending/combo/AirSweep.java | 2 +- .../airbending/combo/Twister.java | 2 +- .../airbending/flight/FlightMultiAbility.java | 2 +- .../airbending/passive/AirAgility.java | 2 +- .../airbending/passive/AirSaturation.java | 128 ++++-- .../airbending/passive/GracefulDescent.java | 2 +- .../airbending/util/AirAddonAbilityInfo.java | 2 +- .../util/AirPassiveAbilityInfo.java | 2 +- .../projectkorra/avatar/AvatarState.java | 2 +- .../chiblocking/AcrobatStance.java | 2 +- .../projectkorra/chiblocking/HighJump.java | 2 +- .../projectkorra/chiblocking/Paralyze.java | 2 +- .../projectkorra/chiblocking/QuickStrike.java | 2 +- .../projectkorra/chiblocking/RapidPunch.java | 2 +- .../projectkorra/chiblocking/Smokescreen.java | 2 +- .../projectkorra/chiblocking/SwiftKick.java | 4 +- .../chiblocking/WarriorStance.java | 2 +- .../chiblocking/combo/Immobilize.java | 2 +- .../chiblocking/passive/Acrobatics.java | 2 +- .../chiblocking/passive/ChiAgility.java | 2 +- .../chiblocking/passive/ChiPassive.java | 2 +- .../chiblocking/passive/ChiSaturation.java | 75 +++- .../projectkorra/command/AddCommand.java | 6 - .../projectkorra/command/BindCommand.java | 4 +- .../projectkorra/command/ClearCommand.java | 2 +- .../projectkorra/command/DisplayCommand.java | 12 +- .../projectkorra/command/HelpCommand.java | 6 +- .../command/PermaremoveCommand.java | 3 - .../projectkorra/command/RemoveCommand.java | 7 - .../projectkorra/earthbending/Catapult.java | 2 +- .../projectkorra/earthbending/Collapse.java | 2 +- .../earthbending/CollapseWall.java | 2 +- .../projectkorra/earthbending/EarthArmor.java | 4 +- .../projectkorra/earthbending/EarthBlast.java | 4 +- .../projectkorra/earthbending/EarthDome.java | 2 +- .../projectkorra/earthbending/EarthGrab.java | 4 +- .../projectkorra/earthbending/EarthSmash.java | 4 +- .../earthbending/EarthTunnel.java | 4 +- .../projectkorra/earthbending/RaiseEarth.java | 2 +- .../earthbending/RaiseEarthWall.java | 2 +- .../projectkorra/earthbending/Ripple.java | 4 +- .../projectkorra/earthbending/Shockwave.java | 2 +- .../earthbending/Tremorsense.java | 4 +- .../earthbending/combo/EarthDomeOthers.java | 2 +- .../earthbending/combo/EarthDomeSelf.java | 2 +- .../earthbending/combo/EarthPillars.java | 2 +- .../earthbending/lava/LavaFlow.java | 4 +- .../earthbending/metal/Extraction.java | 2 +- .../earthbending/metal/MetalClips.java | 2 +- .../earthbending/passive/DensityShift.java | 4 +- .../earthbending/passive/FerroControl.java | 2 +- .../projectkorra/element/ElementManager.java | 42 +- .../event/PlayerChangeElementEvent.java | 59 +-- .../projectkorra/firebending/Blaze.java | 2 +- .../projectkorra/firebending/BlazeArc.java | 2 +- .../projectkorra/firebending/BlazeRing.java | 2 +- .../projectkorra/firebending/FireBlast.java | 4 +- .../firebending/FireBlastCharged.java | 4 +- .../projectkorra/firebending/FireBurst.java | 2 +- .../projectkorra/firebending/FireJet.java | 4 +- .../firebending/FireManipulation.java | 2 +- .../projectkorra/firebending/FireShield.java | 2 +- .../projectkorra/firebending/HeatControl.java | 2 +- .../firebending/Illumination.java | 2 +- .../projectkorra/firebending/WallOfFire.java | 4 +- .../firebending/combo/FireComboStream.java | 2 +- .../firebending/combo/FireKick.java | 2 +- .../firebending/combo/FireSpin.java | 2 +- .../firebending/combo/FireWheel.java | 4 +- .../firebending/combo/JetBlast.java | 2 +- .../firebending/combo/JetBlaze.java | 2 +- .../firebending/combustion/Combustion.java | 6 +- .../firebending/lightning/Lightning.java | 2 +- .../firebending/util/FirebendingManager.java | 2 +- .../projectkorra/module/Module.java | 9 +- .../projectkorra/module/ModuleManager.java | 32 +- .../module/PlayerDatabaseModule.java | 31 ++ .../object/HorizontalVelocityTracker.java | 2 +- .../projectkorra/player/BendingPlayer.java | 71 ++- .../player/BendingPlayerManager.java | 31 +- .../projectkorra/util/BlockSource.java | 6 +- .../projectkorra/util/MultiKeyMap.java | 104 +++++ .../projectkorra/util/PassiveHandler.java | 12 +- .../projectkorra/util/RevertChecker.java | 2 +- .../waterbending/OctopusForm.java | 4 +- .../projectkorra/waterbending/SurgeWall.java | 4 +- .../projectkorra/waterbending/SurgeWave.java | 6 +- .../projectkorra/waterbending/Torrent.java | 4 +- .../waterbending/TorrentWave.java | 2 +- .../waterbending/WaterBubble.java | 4 +- .../waterbending/WaterManipulation.java | 4 +- .../projectkorra/waterbending/WaterSpout.java | 4 +- .../waterbending/WaterSpoutWave.java | 4 +- .../waterbending/blood/Bloodbending.java | 4 +- .../waterbending/combo/IceBullet.java | 4 +- .../waterbending/combo/IceWave.java | 2 +- .../waterbending/healing/HealingWaters.java | 6 +- .../waterbending/ice/IceBlast.java | 4 +- .../waterbending/ice/IceSpikeBlast.java | 4 +- .../waterbending/ice/IceSpikePillar.java | 8 +- .../waterbending/ice/IceSpikePillarField.java | 6 +- .../waterbending/ice/PhaseChange.java | 4 +- .../multiabilities/WaterArms.java | 6 +- .../multiabilities/WaterArmsFreeze.java | 2 +- .../multiabilities/WaterArmsSpear.java | 2 +- .../multiabilities/WaterArmsWhip.java | 2 +- .../waterbending/passive/FastSwim.java | 2 +- .../waterbending/passive/HydroSink.java | 4 +- .../waterbending/plant/PlantRegrowth.java | 4 +- .../waterbending/util/WaterReturn.java | 2 +- .../waterbending/util/WaterSourceGrabber.java | 4 +- 160 files changed, 1223 insertions(+), 1116 deletions(-) create mode 100644 src/com/projectkorra/projectkorra/ability/AbilityHandler.java rename src/com/projectkorra/projectkorra/ability/{info/AddonAbilityInfo.java => api/AddonAbility.java} (86%) delete mode 100644 src/com/projectkorra/projectkorra/ability/api/ChiAbility.java rename src/com/projectkorra/projectkorra/ability/{info/ComboAbilityInfo.java => api/ComboAbility.java} (73%) rename src/com/projectkorra/projectkorra/ability/{info/MultiAbilityInfo.java => api/MultiAbility.java} (51%) rename src/com/projectkorra/projectkorra/ability/{info/PassiveAbilityInfo.java => api/PassiveAbility.java} (79%) delete mode 100644 src/com/projectkorra/projectkorra/ability/info/AbilityInfo.java delete mode 100644 src/com/projectkorra/projectkorra/ability/info/AvatarAbilityInfo.java rename src/com/projectkorra/projectkorra/ability/{api => legacy}/AirAbility.java (95%) create mode 100644 src/com/projectkorra/projectkorra/ability/legacy/AvatarAbility.java rename src/com/projectkorra/projectkorra/ability/{api => legacy}/BloodAbility.java (92%) create mode 100644 src/com/projectkorra/projectkorra/ability/legacy/ChiAbility.java rename src/com/projectkorra/projectkorra/ability/{api => legacy}/CombustionAbility.java (91%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/EarthAbility.java (99%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/ElementalAbility.java (95%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/FireAbility.java (99%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/FlightAbility.java (90%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/HealingAbility.java (90%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/IceAbility.java (90%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/LavaAbility.java (90%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/LightningAbility.java (91%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/MetalAbility.java (90%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/PlantAbility.java (90%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/SandAbility.java (90%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/SpiritualAbility.java (90%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/SubAbility.java (85%) rename src/com/projectkorra/projectkorra/ability/{api => legacy}/WaterAbility.java (99%) create mode 100644 src/com/projectkorra/projectkorra/module/PlayerDatabaseModule.java create mode 100644 src/com/projectkorra/projectkorra/util/MultiKeyMap.java diff --git a/src/com/projectkorra/projectkorra/BendingManager.java b/src/com/projectkorra/projectkorra/BendingManager.java index 5a018cf5..747368b9 100644 --- a/src/com/projectkorra/projectkorra/BendingManager.java +++ b/src/com/projectkorra/projectkorra/BendingManager.java @@ -2,7 +2,7 @@ package com.projectkorra.projectkorra; import co.aikar.timings.lib.MCTiming; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.properties.FirePropertiesConfig; import com.projectkorra.projectkorra.configuration.configs.properties.WaterPropertiesConfig; @@ -31,13 +31,12 @@ public class BendingManager implements Runnable { long interval; private final HashMap times = new HashMap(); // true if day time - private final MCTiming CORE_ABILITY_TIMING, TEMP_POTION_TIMING, DAY_NIGHT_TIMING, HORIZONTAL_VELOCITY_TRACKER_TIMING, COOLDOWN_TIMING, TEMP_ARMOR_TIMING, ACTIONBAR_STATUS_TIMING; + private final MCTiming TEMP_POTION_TIMING, DAY_NIGHT_TIMING, HORIZONTAL_VELOCITY_TRACKER_TIMING, COOLDOWN_TIMING, TEMP_ARMOR_TIMING, ACTIONBAR_STATUS_TIMING; public BendingManager() { instance = this; this.time = System.currentTimeMillis(); - this.CORE_ABILITY_TIMING = ProjectKorra.timing("CoreAbility#ProgressAll"); this.TEMP_POTION_TIMING = ProjectKorra.timing("TempPotion#ProgressAll"); this.DAY_NIGHT_TIMING = ProjectKorra.timing("HandleDayNight"); this.HORIZONTAL_VELOCITY_TRACKER_TIMING = ProjectKorra.timing("HorizontalVelocityTracker#UpdateAll"); @@ -118,10 +117,6 @@ public class BendingManager implements Runnable { this.time = System.currentTimeMillis(); ProjectKorra.time_step = this.interval; - try (MCTiming timing = this.CORE_ABILITY_TIMING.startTiming()) { - CoreAbility.progressAll(); - } - try (MCTiming timing = this.TEMP_POTION_TIMING.startTiming()) { TempPotionEffect.progressAll(); } diff --git a/src/com/projectkorra/projectkorra/BendingPlayer.java b/src/com/projectkorra/projectkorra/BendingPlayer.java index 1057e923..bc33ef59 100644 --- a/src/com/projectkorra/projectkorra/BendingPlayer.java +++ b/src/com/projectkorra/projectkorra/BendingPlayer.java @@ -2,8 +2,8 @@ package com.projectkorra.projectkorra; import com.projectkorra.projectkorra.Element.SubElement; import com.projectkorra.projectkorra.ability.Ability; -import com.projectkorra.projectkorra.ability.api.AvatarAbility; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.AvatarAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.util.PassiveManager; import com.projectkorra.projectkorra.avatar.AvatarState; diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index be3c62ce..da4fa183 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -24,15 +24,16 @@ import com.palmergames.bukkit.towny.object.WorldCoord; import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; import com.palmergames.bukkit.towny.war.flagwar.TownyWar; import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig; -import com.projectkorra.projectkorra.Element.SubElement; import com.projectkorra.projectkorra.ability.Ability; +import com.projectkorra.projectkorra.ability.AbilityManager; import com.projectkorra.projectkorra.ability.api.AddonAbility; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; +import com.projectkorra.projectkorra.ability.info.AbilityInfo; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.CollisionInitializer; import com.projectkorra.projectkorra.ability.util.CollisionManager; @@ -46,20 +47,15 @@ import com.projectkorra.projectkorra.airbending.AirSpout; import com.projectkorra.projectkorra.airbending.AirSuction; import com.projectkorra.projectkorra.airbending.AirSwipe; import com.projectkorra.projectkorra.configuration.ConfigManager; -import com.projectkorra.projectkorra.configuration.configs.commands.BindCommandConfig; -import com.projectkorra.projectkorra.configuration.configs.properties.ChatPropertiesConfig; import com.projectkorra.projectkorra.configuration.configs.properties.GeneralPropertiesConfig; import com.projectkorra.projectkorra.earthbending.EarthBlast; import com.projectkorra.projectkorra.earthbending.passive.EarthPassive; -import com.projectkorra.projectkorra.element.ElementManager; -import com.projectkorra.projectkorra.event.BendingPlayerCreationEvent; import com.projectkorra.projectkorra.event.BendingReloadEvent; -import com.projectkorra.projectkorra.event.PlayerBindChangeEvent; import com.projectkorra.projectkorra.firebending.FireBlast; import com.projectkorra.projectkorra.firebending.FireShield; import com.projectkorra.projectkorra.firebending.combustion.Combustion; +import com.projectkorra.projectkorra.module.ModuleManager; import com.projectkorra.projectkorra.object.Preset; -import com.projectkorra.projectkorra.player.BendingPlayerManager; import com.projectkorra.projectkorra.storage.DBConnection; import com.projectkorra.projectkorra.util.ActionBar; import com.projectkorra.projectkorra.util.BlockCacheElement; @@ -133,8 +129,6 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.sql.ResultSet; -import java.sql.SQLException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -170,57 +164,6 @@ public class GeneralMethods { } } - /** - * Checks to see if an AbilityExists. Uses method - * {@link #getAbility(String)} to check if it exists. - * - * @param string Ability Name - * @return true if ability exists - */ - public static boolean abilityExists(final String string) { - return CoreAbility.getAbility(string) != null; - } - - /** - * Binds a Ability to the hotbar slot that the player is on. - * - * @param player The player to bind to - * @param ability The ability name to Bind - * @see #bindAbility(Player, String, int) - */ - public static void bindAbility(final Player player, final String ability) { - final int slot = player.getInventory().getHeldItemSlot(); - bindAbility(player, ability, slot); - } - - /** - * Binds a Ability to a specific hotbar slot. - * - * @param player The player to bind to - * @param ability - * @param slot - * @see #bindAbility(Player, String) - */ - public static void bindAbility(final Player player, final String ability, final int slot) { - if (MultiAbilityManager.playerAbilities.containsKey(player)) { - GeneralMethods.sendBrandingMessage(player, ChatColor.RED + "You can't edit your binds right now!"); - return; - } - - final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player.getName()); - final CoreAbility coreAbil = CoreAbility.getAbility(ability); - - if (bPlayer == null) { - return; - } - bPlayer.getAbilities()[slot] = ability; - - if (coreAbil != null) { - GeneralMethods.sendBrandingMessage(player, coreAbil.getElement().getColor() + ConfigManager.getConfig(BindCommandConfig.class).SuccessfullyBoundMessage.replace("{ability}", ability).replace("{slot}", String.valueOf(slot + 1))); - } - saveAbility(bPlayer, slot, ability); - } - /** * This method was used for the old collision detection system. Please see * {@link Collision} for the new system. @@ -317,90 +260,6 @@ public class GeneralMethods { return (a || b || c || (a && b)); } - /** - * Creates a {@link BendingPlayer} with the data from the database. This - * runs when a player logs in. - * - * @param uuid The UUID of the player - * @param player The player name - * @throws SQLException - * - * @deprecated use {@link BendingPlayerManager} and {@link ElementManager}. - */ - @Deprecated - public static void createBendingPlayer(final UUID uuid, final String player) { - new BukkitRunnable() { - - @Override - public void run() { - createBendingPlayerAsynchronously(uuid, player); - } - - }.runTaskAsynchronously(ProjectKorra.plugin); - } - - @Deprecated - private static void createBendingPlayerAsynchronously(final UUID uuid, final String player) { - ResultSet rs = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + uuid.toString() + "'"); - try { - if (!rs.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 BukkitRunnable() { - @Override - public void run() { - new BendingPlayer(uuid, player, new ArrayList<>(), new ArrayList<>(), new String[9], false); - ProjectKorra.log.info("Created new BendingPlayer for " + player); - } - }.runTask(ProjectKorra.plugin); - } else { - // The player has at least played before. - final String player2 = rs.getString("player"); - if (!player.equalsIgnoreCase(player2)) { - DBConnection.sql.modifyQuery("UPDATE pk_players SET player = '" + player + "' WHERE uuid = '" + uuid.toString() + "';"); - // They have changed names. - ProjectKorra.log.info("Updating Player Name for " + player); - } - final boolean permaremoved = rs.getBoolean("permaremoved"); - final List elements = new ArrayList<>(); - final List subelements = new ArrayList<>(); - final String[] abilities = new String[9]; - - for (int i = 0; i < 9; i++) { - final String ability = rs.getString("slot" + (i + 1)); - if (CoreAbility.getAbility(ability) != null && CoreAbility.getAbility(ability).isEnabled()) { - abilities[i] = ability; - } - } - - ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_player_elements WHERE uuid = '" + uuid.toString() + "';"); - while (rs2.next()) { - String elementName = rs2.getString("element"); - boolean isSub = rs2.getBoolean("sub_element"); - - Element element = Element.fromString(elementName); - - if (element == null) { - continue; - } - - if (isSub) { - subelements.add((SubElement)element); - } else { - elements.add(element); - } - } - - new BukkitRunnable() { - @Override - public void run() { - new BendingPlayer(uuid, player, elements, subelements, abilities, permaremoved); - } - }.runTask(ProjectKorra.plugin); - } - } catch (final SQLException ex) { - ex.printStackTrace(); - } - } /** * Deserializes the configuration file "bendingPlayers.yml" of the old @@ -502,31 +361,6 @@ public class GeneralMethods { } } - public static void displayMovePreview(final Player player) { - displayMovePreview(player, player.getInventory().getHeldItemSlot()); - } - - public static void displayMovePreview(final Player player, final int slot) { - if (!ConfigManager.getConfig(GeneralPropertiesConfig.class).BendingPreview) { - return; - } - - final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - if (bPlayer == null) { - return; - } - String displayedMessage = bPlayer.getAbilities()[slot]; - final CoreAbility ability = CoreAbility.getAbility(displayedMessage); - - if (ability != null && bPlayer != null) { - displayedMessage = ability.getMovePreview(player); - } else if (displayedMessage == null || displayedMessage.isEmpty() || displayedMessage.equals("")) { - displayedMessage = ""; - } - - ActionBar.sendActionBar(displayedMessage, player); - } - public static float getAbsorbationHealth(final Player player) { try { @@ -812,7 +646,6 @@ public class GeneralMethods { * @param block The single block * @param type The Material type to change the block into * @param data The block data to change the block into - * @param breakitem Unused * @return The item drops fromt the specified block */ public static Collection getDrops(final Block block, final Material type, final BlockData data) { @@ -884,25 +717,6 @@ public class GeneralMethods { return null; } - /** - * Returns the last ability used by a player. Also checks if a combo was - * used. - * - * @param player The player to check - * @return name of last ability used - */ - public static String getLastUsedAbility(final Player player, final boolean checkCombos) { - final List lastUsedAbility = ComboManager.getRecentlyUsedAbilities(player, 1); - if (!lastUsedAbility.isEmpty()) { - if (ComboManager.checkForValidCombo(player) != null && checkCombos) { - return ComboManager.checkForValidCombo(player).getName(); - } else { - return lastUsedAbility.get(0).getAbilityName(); - } - } - return null; - } - /** * Gets a location with a specified distance away from the left side of a * location. @@ -1302,18 +1116,18 @@ public class GeneralMethods { return isRegionProtectedFromBuild(player, null, loc); } - public static boolean isRegionProtectedFromBuildPostCache(final Player player, final String ability, final Location loc) { + public static boolean isRegionProtectedFromBuildPostCache(final Player player, final String abilityName, final Location loc) { boolean isIgnite = false; boolean isExplosive = false; boolean isHarmless = false; - final CoreAbility coreAbil = CoreAbility.getAbility(ability); - if (coreAbil != null) { - isIgnite = coreAbil.isIgniteAbility(); - isExplosive = coreAbil.isExplosiveAbility(); - isHarmless = coreAbil.isHarmlessAbility(); + final AbilityInfo abilityInfo = ModuleManager.getModule(AbilityManager.class).getAbilityInfo(abilityName); + if (abilityInfo != null) { + isIgnite = abilityInfo.isIgniteAbility(); + isExplosive = abilityInfo.isExplosiveAbility(); + isHarmless = abilityInfo.isHarmlessAbility(); } - if (ability == null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.AllowHarmlessAbilities) { + if (abilityName == null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.AllowHarmlessAbilities) { return false; } if (isHarmless && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.AllowHarmlessAbilities) { @@ -1524,55 +1338,55 @@ public class GeneralMethods { return mat != null && (mat == Material.WOODEN_AXE || mat == Material.WOODEN_PICKAXE || mat == Material.WOODEN_SHOVEL || mat == Material.WOODEN_SWORD || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE || mat == Material.STONE_SHOVEL || mat == Material.STONE_SWORD || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE || mat == Material.IRON_SWORD || mat == Material.IRON_SHOVEL || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SHOVEL || mat == Material.GOLDEN_AXE || mat == Material.GOLDEN_HOE || mat == Material.GOLDEN_SWORD || mat == Material.GOLDEN_PICKAXE || mat == Material.GOLDEN_SHOVEL || mat == Material.TRIDENT); } - public static void loadBendingPlayer(final BendingPlayer pl) { - final Player player = Bukkit.getPlayer(pl.getUUID()); - final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - - if (bPlayer == null) { - return; - } - - if (PKListener.getToggledOut().contains(player.getUniqueId())) { - bPlayer.toggleBending(); - player.sendMessage(ChatColor.YELLOW + "Reminder, you toggled your bending before signing off. Enable it again with /bending toggle."); - } - - Preset.loadPresets(player); - Element element = null; - String prefix = ""; - - prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).NonbenderPrefix) + " "; - if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) { - prefix = Element.AVATAR.getPrefix(); - } else if (bPlayer.getElements().size() > 0) { - element = bPlayer.getElements().get(0); - prefix = element.getPrefix(); - } - - if (ConfigManager.getConfig(ChatPropertiesConfig.class).Enabled) { - player.setDisplayName(player.getName()); - player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName()); - } - - // Handle the AirSpout/WaterSpout login glitches. - if (player.getGameMode() != GameMode.CREATIVE) { - final String[] bound = bPlayer.getAbilities(); - for (final String str : bound) { - if (str.equalsIgnoreCase("AirSpout") || str.equalsIgnoreCase("WaterSpout") || str.equalsIgnoreCase("SandSpout")) { - final Player fplayer = player; - new BukkitRunnable() { - @Override - public void run() { - fplayer.setFlying(false); - fplayer.setAllowFlight(false); - } - }.runTaskLater(ProjectKorra.plugin, 2); - break; - } - } - } - Bukkit.getServer().getPluginManager().callEvent(new BendingPlayerCreationEvent(bPlayer)); - } +// public static void loadBendingPlayer(final BendingPlayer pl) { +// final Player player = Bukkit.getPlayer(pl.getUUID()); +// final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); +// +// if (bPlayer == null) { +// return; +// } +// +// if (PKListener.getToggledOut().contains(player.getUniqueId())) { +// bPlayer.toggleBending(); +// player.sendMessage(ChatColor.YELLOW + "Reminder, you toggled your bending before signing off. Enable it again with /bending toggle."); +// } +// +// Preset.loadPresets(player); +// Element element = null; +// String prefix = ""; +// +// prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).NonbenderPrefix) + " "; +// if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) { +// prefix = Element.AVATAR.getPrefix(); +// } else if (bPlayer.getElements().size() > 0) { +// element = bPlayer.getElements().get(0); +// prefix = element.getPrefix(); +// } +// +// if (ConfigManager.getConfig(ChatPropertiesConfig.class).Enabled) { +// player.setDisplayName(player.getName()); +// player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName()); +// } +// +// // Handle the AirSpout/WaterSpout login glitches. +// if (player.getGameMode() != GameMode.CREATIVE) { +// final String[] bound = bPlayer.getAbilities(); +// for (final String str : bound) { +// if (str.equalsIgnoreCase("AirSpout") || str.equalsIgnoreCase("WaterSpout") || str.equalsIgnoreCase("SandSpout")) { +// final Player fplayer = player; +// new BukkitRunnable() { +// @Override +// public void run() { +// fplayer.setFlying(false); +// fplayer.setAllowFlight(false); +// } +// }.runTaskLater(ProjectKorra.plugin, 2); +// break; +// } +// } +// } +// Bukkit.getServer().getPluginManager().callEvent(new BendingPlayerCreationEvent(bPlayer)); +// } public static void reloadPlugin(final CommandSender sender) { ProjectKorra.log.info("Reloading ProjectKorra and configuration"); @@ -1587,14 +1401,12 @@ public class GeneralMethods { } GeneralMethods.stopBending(); ConfigManager.clearCache(); - Preset.loadExternalPresets(); - new MultiAbilityManager(); - new ComboManager(); +// Preset.loadExternalPresets(); + ModuleManager.startup(); // 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(); @@ -1605,23 +1417,25 @@ public class GeneralMethods { ProjectKorra.log.severe("Unable to enable ProjectKorra due to the database not being open"); stopPlugin(); } - for (final Player player : Bukkit.getOnlinePlayers()) { - Preset.unloadPreset(player); - GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); - PassiveManager.registerPassives(player); - } +// for (final Player player : Bukkit.getOnlinePlayers()) { +// Preset.unloadPreset(player); +// GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); +// PassiveManager.registerPassives(player); +// } plugin.updater.checkUpdate(); ProjectKorra.log.info("Reload complete"); } public static void reloadAddonPlugins() { - for (int i = CoreAbility.getAddonPlugins().size() - 1; i > -1; i--) { - final String entry = CoreAbility.getAddonPlugins().get(i); + AbilityManager abilityManager = ModuleManager.getModule(AbilityManager.class); + + for (int i = abilityManager.getAddonPlugins().size() - 1; i > -1; i--) { + final String entry = abilityManager.getAddonPlugins().get(i); final String[] split = entry.split("::"); if (Bukkit.getServer().getPluginManager().isPluginEnabled(split[0])) { - CoreAbility.registerPluginAbilities((JavaPlugin) Bukkit.getServer().getPluginManager().getPlugin(split[0]), split[1]); + abilityManager.registerPluginAbilities((JavaPlugin) Bukkit.getServer().getPluginManager().getPlugin(split[0]), split[1]); } else { - CoreAbility.getAddonPlugins().remove(i); + abilityManager.getAddonPlugins().remove(i); } } } @@ -1638,6 +1452,7 @@ public class GeneralMethods { } public static void removeUnusableAbilities(final String player) { + final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); if (bPlayer == null) { return; @@ -1848,88 +1663,6 @@ public class GeneralMethods { } - public static void saveAbility(final BendingPlayer bPlayer, final int slot, final String ability) { - if (bPlayer == null) { - return; - } - final String uuid = bPlayer.getUUIDString(); - - final PlayerBindChangeEvent event = new PlayerBindChangeEvent(Bukkit.getPlayer(UUID.fromString(uuid)), ability, slot, false); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - // Temp code to block modifications of binds, Should be replaced when bind event is added. - if (MultiAbilityManager.playerAbilities.containsKey(Bukkit.getPlayer(bPlayer.getUUID()))) { - return; - } - final String[] abilities = bPlayer.getAbilities(); - - DBConnection.sql.modifyQuery("UPDATE pk_players SET slot" + (slot + 1) + " = '" + (abilities[slot] == null ? null : abilities[slot - 1]) + "' WHERE uuid = '" + uuid + "'"); - } - - public static void saveElements(final BendingPlayer bPlayer, List e) { - if (bPlayer == null) { - return; - } - final String uuid = bPlayer.getUUIDString(); - - StringBuilder queryBuilder = new StringBuilder(); - e.forEach(element -> { - queryBuilder.append("INSERT INTO pk_player_elements (uuid, element, sub_element) VALUES ('" + uuid + "', '" + element.getName().toLowerCase() + "', " + String.valueOf(e instanceof SubElement) + ");"); - }); - final String query = queryBuilder.toString(); - - DBConnection.sql.modifyQuery(query); - } - - public static void saveElement(final BendingPlayer bPlayer, Element e) { - if (bPlayer == null) { - return; - } - - final String uuid = bPlayer.getUUIDString(); - final String element = e.getName().toLowerCase(); - final boolean subElement = e instanceof SubElement; - - DBConnection.sql.modifyQuery("INSERT INTO pk_player_elements (uuid, element, sub_element) VALUES ('" + uuid + "', '" + element + "', " + String.valueOf(subElement) + ");"); - } - - public static void deleteElements(final BendingPlayer bPlayer, List e) { - if (bPlayer == null) { - return; - } - final String uuid = bPlayer.getUUIDString(); - - StringBuilder queryBuilder = new StringBuilder(); - e.forEach(element -> { - queryBuilder.append("DELETE FROM pk_player_elements WHERE uuid='" + uuid + "' AND element='" + element.getName().toLowerCase() + "';"); - }); - final String query = queryBuilder.toString(); - - DBConnection.sql.modifyQuery(query); - } - - public static void deleteElement(final BendingPlayer bPlayer, Element e) { - if (bPlayer == null) { - return; - } - - final String uuid = bPlayer.getUUIDString(); - final String element = e.getName().toLowerCase(); - - DBConnection.sql.modifyQuery("DELETE FROM pk_player_elements WHERE uuid='" + uuid + "' AND element='" + element + "';"); - } - - public static void savePermaRemoved(final BendingPlayer bPlayer) { - if (bPlayer == null) { - return; - } - final String uuid = bPlayer.getUUIDString(); - final boolean permaRemoved = bPlayer.isPermaRemoved(); - DBConnection.sql.modifyQuery("UPDATE pk_players SET permaremoved = " + String.valueOf(permaRemoved) + " WHERE uuid = '" + uuid + "'"); - } - public static void setVelocity(final Entity entity, final Vector velocity) { if (entity instanceof TNTPrimed) { if (ConfigManager.getConfig(GeneralPropertiesConfig.class).BendingAffectFallingSand_TNT) { diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index bb33ea6e..2e65446e 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -80,14 +80,14 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.ability.Ability; import com.projectkorra.projectkorra.ability.api.AddonAbility; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.AvatarAbility; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.AvatarAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.ability.util.ComboManager; import com.projectkorra.projectkorra.ability.util.MultiAbilityManager; import com.projectkorra.projectkorra.ability.util.PassiveManager; diff --git a/src/com/projectkorra/projectkorra/ability/Ability.java b/src/com/projectkorra/projectkorra/ability/Ability.java index 717e1b80..cedbf276 100644 --- a/src/com/projectkorra/projectkorra/ability/Ability.java +++ b/src/com/projectkorra/projectkorra/ability/Ability.java @@ -1,7 +1,6 @@ package com.projectkorra.projectkorra.ability; import com.projectkorra.projectkorra.Manager; -import com.projectkorra.projectkorra.ability.info.AbilityInfo; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.CollisionManager; import com.projectkorra.projectkorra.attribute.Attribute; @@ -45,7 +44,7 @@ import java.util.jar.JarFile; * @see #registerAddonAbilities(String) * @see #registerPluginAbilities(JavaPlugin, String) */ -public abstract class Ability { +public abstract class Ability { private static final double DEFAULT_COLLISION_RADIUS = 0.3; private static final Map, Map> ATTRIBUTE_FIELDS = new HashMap<>(); @@ -54,9 +53,10 @@ public abstract class Ability) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0])); +// protected final Info info = (Info) this.manager.getAbilityInfo(getClass()); +// protected final Config config = ConfigManager.getConfig(((Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0])); + protected Handler abilityHandler; protected Player player; protected BendingPlayer bendingPlayer; protected FlightHandler flightHandler; @@ -104,13 +104,14 @@ public abstract class Ability getConfigType(); // public String getMovePreview(final Player player) { // final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); diff --git a/src/com/projectkorra/projectkorra/ability/AbilityHandler.java b/src/com/projectkorra/projectkorra/ability/AbilityHandler.java new file mode 100644 index 00000000..4fd15c4e --- /dev/null +++ b/src/com/projectkorra/projectkorra/ability/AbilityHandler.java @@ -0,0 +1,77 @@ +package com.projectkorra.projectkorra.ability; + +import com.projectkorra.projectkorra.configuration.ConfigManager; +import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig; +import com.projectkorra.projectkorra.element.Element; +import com.projectkorra.projectkorra.player.BendingPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +public abstract class AbilityHandler implements Listener { + + private final Class abilityClass; + private final Class configClass; + + public AbilityHandler(Class abilityClass, Class configClass) { + this.abilityClass = abilityClass; + this.configClass = configClass; + } + + public T newInstance(Player player) { + try { + Constructor constructor = abilityClass.getDeclaredConstructor(Player.class); + + return constructor.newInstance(player); + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new AbilityException(e); + } + } + + public Class getAbility() { + return this.abilityClass; + } + + public U getConfig() { + return ConfigManager.getConfig(this.configClass); + } + + /** + * The name of the ability is used for commands such as /bending + * display and /bending help. The name is also used for + * determining the tag for cooldowns + * {@link BendingPlayer#addCooldown(Ability)}, therefore if two abilities + * have the same name they will also share cooldowns. If two classes share + * the same name (SurgeWall/SurgeWave) but need to have independent + * cooldowns, then {@link BendingPlayer#addCooldown(String, long)} should be + * called explicitly. + * + * @return Returns the name of the ability + */ + public abstract String getName(); + + public abstract boolean isSneakAbility(); + + public abstract boolean isHarmlessAbility(); + + public abstract boolean isIgniteAbility(); + + public abstract boolean isExplosiveAbility(); + + public abstract long getCooldown(); + + public abstract Element getElement(); + + public abstract String getDescription(); + + public abstract String getInstructions(); + + /** + * @return true if this is a hidden ability. + */ + public boolean isHidden() { + return false; + } +} diff --git a/src/com/projectkorra/projectkorra/ability/AbilityManager.java b/src/com/projectkorra/projectkorra/ability/AbilityManager.java index 2a38741c..120cbe5b 100644 --- a/src/com/projectkorra/projectkorra/ability/AbilityManager.java +++ b/src/com/projectkorra/projectkorra/ability/AbilityManager.java @@ -2,23 +2,24 @@ package com.projectkorra.projectkorra.ability; import co.aikar.timings.lib.MCTiming; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.info.*; -import com.projectkorra.projectkorra.ability.util.AbilityRegistry; -import com.projectkorra.projectkorra.ability.util.AddonAbilityRegistry; +import com.projectkorra.projectkorra.ability.api.AddonAbility; +import com.projectkorra.projectkorra.ability.api.ComboAbility; +import com.projectkorra.projectkorra.ability.api.MultiAbility; +import com.projectkorra.projectkorra.ability.api.PassiveAbility; +import com.projectkorra.projectkorra.airbending.passive.AirSaturation; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig; +import com.projectkorra.projectkorra.configuration.configs.abilities.air.AirSaturationConfig; import com.projectkorra.projectkorra.element.Element; import com.projectkorra.projectkorra.element.SubElement; import com.projectkorra.projectkorra.event.AbilityProgressEvent; import com.projectkorra.projectkorra.module.Module; import com.projectkorra.projectkorra.module.ModuleManager; +import com.projectkorra.projectkorra.util.MultiKeyMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import java.io.File; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.ParameterizedType; import java.text.SimpleDateFormat; import java.util.*; @@ -30,12 +31,12 @@ public class AbilityManager extends Module { private final MultiAbilityManager multiAbilityManager; private final PassiveAbilityManager passiveAbilityManager; - private final Map abilityInfoByName = new HashMap<>(); - private final Map, AbilityInfo> abilityInfoByClass = new HashMap<>(); + private final MultiKeyMap handlerMap = new MultiKeyMap<>(); - private final Set playerAbilitySet = new HashSet<>(); - private final Map, LinkedList>> playerAbilityMap = new HashMap<>(); + private final Set abilities = new HashSet<>(); + private final Map, LinkedList>> abilityMap = new HashMap<>(); + private final MCTiming timing = ProjectKorra.timing("AbilityManager"); private final Set addonPlugins = new HashSet<>(); public AbilityManager() { @@ -46,54 +47,55 @@ public class AbilityManager extends Module { this.passiveAbilityManager = ModuleManager.getModule(PassiveAbilityManager.class); runTimer(() -> { - for (Ability ability : playerAbilitySet) { - if (ability.getInfo() instanceof PassiveAbilityInfo) { - if (!((PassiveAbilityInfo) ability).isProgressable()) { - return; - } + try (MCTiming timing = this.timing.startTiming()) { + for (Ability ability : abilities) { + if (ability.getHandler() instanceof PassiveAbility) { + if (!((PassiveAbility) ability.getHandler()).isProgressable()) { + return; + } - // This has to be before isDead as isDead will return true if they are offline. - if (!ability.getPlayer().isOnline()) { + // This has to be before isDead as isDead will return true if they are offline. + if (!ability.getPlayer().isOnline()) { + ability.remove(); + return; + } + + if (ability.getPlayer().isDead()) { + return; + } + } else if (ability.getPlayer().isDead()) { ability.remove(); - return; + continue; + } else if (!ability.getPlayer().isOnline()) { + ability.remove(); + continue; } - if (ability.getPlayer().isDead()) { - return; - } - } else if (ability.getPlayer().isDead()) { - ability.remove(); - continue; - } else if (!ability.getPlayer().isOnline()) { - ability.remove(); - continue; - } - - try { - ability.tryModifyAttributes(); - - try (MCTiming timing = ProjectKorra.timing(ability.getName()).startTiming()) { - ability.progress(); - } - - getPlugin().getServer().getPluginManager().callEvent(new AbilityProgressEvent(ability)); - } catch (Exception e) { - e.printStackTrace(); - getPlugin().getLogger().severe(ability.toString()); - try { - ability.getPlayer().sendMessage(ChatColor.YELLOW + "[" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()) + "] " + ChatColor.RED + "There was an error running " + ability.getName() + ". please notify the server owner describing exactly what you were doing at this moment"); - } catch (final Exception me) { - Bukkit.getLogger().severe("unable to notify ability user of error"); - } - try { - ability.remove(); - } catch (final Exception re) { - Bukkit.getLogger().severe("unable to fully remove ability of above error"); + ability.tryModifyAttributes(); + + try (MCTiming abilityTiming = ProjectKorra.timing(ability.getName()).startTiming()) { + ability.progress(); + } + + getPlugin().getServer().getPluginManager().callEvent(new AbilityProgressEvent(ability)); + } catch (Exception e) { + e.printStackTrace(); + getPlugin().getLogger().severe(ability.toString()); + + try { + ability.getPlayer().sendMessage(ChatColor.YELLOW + "[" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()) + "] " + ChatColor.RED + "There was an error running " + ability.getName() + ". please notify the server owner describing exactly what you were doing at this moment"); + } catch (final Exception me) { + Bukkit.getLogger().severe("unable to notify ability user of error"); + } + try { + ability.remove(); + } catch (final Exception re) { + Bukkit.getLogger().severe("unable to fully remove ability of above error"); + } } } } - // TODO progress abilities }, 1L, 1L); registerAbilities(); @@ -104,115 +106,114 @@ public class AbilityManager extends Module { * located in a Jar file inside of the /ProjectKorra/Abilities/ folder. */ public void registerAbilities() { - this.playerAbilitySet.clear(); - this.playerAbilityMap.clear(); + this.abilities.clear(); + this.abilityMap.clear(); - registerPluginAbilities("com.projectkorra"); - registerAddonAbilities("Abilities"); +// registerPluginAbilities(getPlugin(), "com.projectkorra"); +// registerAddonAbilities("Abilities"); -// registerAbility(FireBlast.class); + registerAbility(new AirSaturation.AirSaturationHandler(AirSaturation.class, AirSaturationConfig.class)); } - /** - * Scans a JavaPlugin and registers Ability class files. - * - * @param plugin a JavaPlugin containing Ability class files - * @param packageBase a prefix of the package name, used to increase - * performance - * @see #getAllAbilityInfo() - * @see #getAbility(String) - */ - public void registerPluginAbilities(String packageBase) { - AbilityRegistry abilityRegistry = new AbilityRegistry<>(getPlugin(), packageBase); - List> loadedAbilities = abilityRegistry.load(Ability.class, Ability.class); +// /** +// * Scans a JavaPlugin and registers Ability class files. +// * +// * @param plugin a JavaPlugin containing Ability class files +// * @param packageBase a prefix of the package name, used to increase +// * performance +// * @see #getAllAbilityInfo() +// * @see #getAbility(String) +// */ +// public void registerPluginAbilities(JavaPlugin plugin, String packageBase) { +// AbilityRegistry abilityRegistry = new AbilityRegistry<>(plugin, packageBase); +// List> loadedAbilities = abilityRegistry.load(Ability.class, Ability.class); +// +// String entry = getPlugin().getName() + "::" + packageBase; +// this.addonPlugins.add(entry); +// +// for (Class abilityClass : loadedAbilities) { +// AbilityInfo abilityInfo = getAbilityInfo(abilityClass); +// +// registerAbility(abilityClass, abilityInfo); +// } +// } +// +// /** +// * Scans all of the Jar files inside of /ProjectKorra/folder and registers +// * all of the Ability class files that were found. +// * +// * @param folder the name of the folder to scan +// * @see #getAllAbilityInfo() +// * @see #getAbility(String) +// */ +// public void registerAddonAbilities(String folder) { +// File file = new File(getPlugin().getDataFolder(), folder); +// +// if (!file.exists()) { +// file.mkdir(); +// return; +// } +// +// AddonAbilityRegistry abilityRegistery = new AddonAbilityRegistry<>(getPlugin(), file); +// List> loadedAbilities = abilityRegistery.load(Ability.class, Ability.class); +// +// for (Class abilityClass : loadedAbilities) { +// AbilityInfo abilityInfo = getAbilityInfo(abilityClass); +// +// if (!(abilityInfo instanceof AddonAbilityInfo)) { +// throw new AbilityException(abilityClass.getName() + " must have an AddonAbilityInfo"); +// } +// +// registerAbility(abilityClass, abilityInfo); +// } +// } - String entry = getPlugin().getName() + "::" + packageBase; - this.addonPlugins.add(entry); - - for (Class abilityClass : loadedAbilities) { - AbilityInfo abilityInfo = getAbilityInfo(abilityClass); - - registerAbility(abilityClass, abilityInfo); - } - } - - /** - * Scans all of the Jar files inside of /ProjectKorra/folder and registers - * all of the Ability class files that were found. - * - * @param folder the name of the folder to scan - * @see #getAllAbilityInfo() - * @see #getAbility(String) - */ - public void registerAddonAbilities(String folder) { - File file = new File(getPlugin().getDataFolder(), folder); - - if (!file.exists()) { - file.mkdir(); - return; + private void registerAbility(T abilityHandler) throws AbilityException { + if (abilityHandler == null) { + throw new AbilityException("abilityHandler is null"); } - AddonAbilityRegistry abilityRegistery = new AddonAbilityRegistry<>(getPlugin(), file); - List> loadedAbilities = abilityRegistery.load(Ability.class, Ability.class); - - for (Class abilityClass : loadedAbilities) { - AbilityInfo abilityInfo = getAbilityInfo(abilityClass); - - if (!(abilityInfo instanceof AddonAbilityInfo)) { - throw new AbilityException(abilityClass.getName() + " must have an AddonAbilityInfo"); - } - - registerAbility(abilityClass, abilityInfo); - } - } - - private void registerAbility(Class abilityClass, AbilityInfo abilityInfo) throws AbilityException { - AbilityConfig abilityConfig = getAbilityConfig(abilityClass); - - String abilityName = abilityInfo.getName(); + String abilityName = abilityHandler.getName(); if (abilityName == null) { - throw new AbilityException("Ability " + abilityClass.getName() + " has no name"); + throw new AbilityException("Ability " + abilityHandler.getClass().getName() + " has no name"); } - if (!abilityConfig.Enabled) { + if (!abilityHandler.getConfig().Enabled) { getPlugin().getLogger().info(abilityName + " is disabled"); return; } - if (abilityInfo instanceof AddonAbilityInfo) { - ((AddonAbilityInfo) abilityInfo).load(); + if (abilityHandler instanceof AddonAbility) { + ((AddonAbility) abilityHandler).load(); } - if (abilityInfo instanceof ComboAbilityInfo) { - ComboAbilityInfo comboAbilityInfo = (ComboAbilityInfo) abilityInfo; + if (abilityHandler instanceof ComboAbility) { + ComboAbility comboAbility = (ComboAbility) abilityHandler; - if (comboAbilityInfo.getCombination() == null || comboAbilityInfo.getCombination().size() < 2) { + if (comboAbility.getCombination() == null || comboAbility.getCombination().size() < 2) { getPlugin().getLogger().info(abilityName + " has no combination"); return; } - this.comboAbilityManager.registerAbility(abilityClass, comboAbilityInfo); + this.comboAbilityManager.registerAbility(abilityHandler); return; } - if (abilityInfo instanceof MultiAbilityInfo) { - MultiAbilityInfo multiAbilityInfo = (MultiAbilityInfo) abilityInfo; - - this.multiAbilityManager.registerAbility(abilityClass, multiAbilityInfo); + if (abilityHandler instanceof MultiAbility) { + this.multiAbilityManager.registerAbility(abilityHandler); return; } - if (abilityInfo instanceof PassiveAbilityInfo) { - PassiveAbilityInfo passiveAbilityInfo = (PassiveAbilityInfo) abilityInfo; + if (abilityHandler instanceof PassiveAbility) { + PassiveAbility passiveAbility = (PassiveAbility) abilityHandler; // TODO Set Hidden Ability - this.passiveAbilityManager.registerAbility(abilityClass, passiveAbilityInfo); + this.passiveAbilityManager.registerAbility(abilityHandler); return; } - this.abilityInfoByName.put(abilityInfo.getName(), abilityInfo); - this.abilityInfoByClass.put(abilityClass, abilityInfo); + this.handlerMap.put(abilityName, abilityHandler); } private AbilityConfig getAbilityConfig(Class abilityClass) throws AbilityException { @@ -223,23 +224,13 @@ public class AbilityManager extends Module { } } - public T createAbility(Player player, Class abilityClass) throws AbilityException { - try { - Constructor constructor = abilityClass.getDeclaredConstructor(Player.class); - - return constructor.newInstance(player); - } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { - throw new AbilityException(e); - } - } - public void startAbility(Ability ability) { if (ability.isStarted()) { return; } - this.playerAbilitySet.add(ability); - this.playerAbilityMap.computeIfAbsent(ability.getPlayer().getUniqueId(), k -> new HashMap<>()) + this.abilities.add(ability); + this.abilityMap.computeIfAbsent(ability.getPlayer().getUniqueId(), k -> new HashMap<>()) .computeIfAbsent(ability.getClass(), k -> new LinkedList<>()) .add(ability); } @@ -249,8 +240,8 @@ public class AbilityManager extends Module { return; } - this.playerAbilitySet.remove(ability); - this.playerAbilityMap.values().removeIf(abilityMap -> + this.abilities.remove(ability); + this.abilityMap.values().removeIf(abilityMap -> { abilityMap.values().removeIf(abilityList -> { @@ -268,11 +259,11 @@ public class AbilityManager extends Module { * removed. */ public void removeAll() { - new HashSet<>(this.playerAbilitySet).forEach(Ability::remove); + new HashSet<>(this.abilities).forEach(Ability::remove); } public boolean hasAbility(Player player, Class ability) { - Map, LinkedList> abilities = this.playerAbilityMap.get(player.getUniqueId()); + Map, LinkedList> abilities = this.abilityMap.get(player.getUniqueId()); if (abilities == null || !abilities.containsKey(ability)) { return false; @@ -282,7 +273,7 @@ public class AbilityManager extends Module { } public T getAbility(Player player, Class ability) { - Map, LinkedList> abilities = this.playerAbilityMap.get(player.getUniqueId()); + Map, LinkedList> abilities = this.abilityMap.get(player.getUniqueId()); if (abilities == null || !abilities.containsKey(ability)) { return null; @@ -292,7 +283,7 @@ public class AbilityManager extends Module { } public Collection getAbilities(Player player, Class ability) { - Map, LinkedList> abilities = this.playerAbilityMap.get(player.getUniqueId()); + Map, LinkedList> abilities = this.abilityMap.get(player.getUniqueId()); if (abilities == null || !abilities.containsKey(ability)) { return null; @@ -301,22 +292,22 @@ public class AbilityManager extends Module { return abilities.get(abilities).stream().map(ability::cast).collect(Collectors.toList()); } - public AbilityInfo getAbilityInfo(String abilityName) { - return this.abilityInfoByName.get(abilityName); + public AbilityHandler getHandler(String abilityName) { + return this.handlerMap.get(abilityName); } - public AbilityInfo getAbilityInfo(Class abilityClass) { - return this.abilityInfoByClass.get(abilityClass); + public AbilityHandler getHandler(Class handlerClass) { + return this.handlerMap.get(handlerClass); } - public List getAbilityInfo() { - return new ArrayList<>(this.abilityInfoByName.values()); + public List getHandlers() { + return new ArrayList<>(this.handlerMap.values()); } public LinkedList getAbilities(Class abilityClass) { LinkedList abilities = new LinkedList<>(); - this.playerAbilityMap.values().forEach(a -> { + this.abilityMap.values().forEach(a -> { a.values().forEach(ability -> abilities.add(abilityClass.cast(ability))); }); @@ -324,11 +315,11 @@ public class AbilityManager extends Module { } public List getAbilities() { - return new ArrayList<>(this.playerAbilitySet); + return new ArrayList<>(this.abilities); } - public List getAbilities(Element element) { - return this.abilityInfoByName.values().stream() + public List getHandlers(Element element) { + return this.handlerMap.values().stream() .filter(ability -> { if (ability.getElement().equals(element)) { @@ -352,7 +343,7 @@ public class AbilityManager extends Module { * @return a list of entrys with the plugin name and path abilities can be * found at */ - public Set getAddonPlugins() { - return this.addonPlugins; + public List getAddonPlugins() { + return new ArrayList<>(this.addonPlugins); } } diff --git a/src/com/projectkorra/projectkorra/ability/ComboAbilityManager.java b/src/com/projectkorra/projectkorra/ability/ComboAbilityManager.java index a046159f..8f6ba261 100644 --- a/src/com/projectkorra/projectkorra/ability/ComboAbilityManager.java +++ b/src/com/projectkorra/projectkorra/ability/ComboAbilityManager.java @@ -1,12 +1,13 @@ package com.projectkorra.projectkorra.ability; -import com.projectkorra.projectkorra.ability.info.ComboAbilityInfo; +import com.projectkorra.projectkorra.ability.api.ComboAbility; import com.projectkorra.projectkorra.element.Element; import com.projectkorra.projectkorra.module.Module; import com.projectkorra.projectkorra.module.ModuleManager; import com.projectkorra.projectkorra.player.BendingPlayer; import com.projectkorra.projectkorra.player.BendingPlayerManager; import com.projectkorra.projectkorra.util.ClickType; +import com.projectkorra.projectkorra.util.MultiKeyMap; import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -28,8 +29,9 @@ public class ComboAbilityManager extends Module { private final BendingPlayerManager bendingPlayerManager; private final AbilityManager abilityManager; - private final Map abilities = new HashMap<>(); - private final List comboAbilities = new ArrayList<>(); + private final MultiKeyMap handlerMap = new MultiKeyMap<>(); + + private final List comboAbilities = new ArrayList<>(); private final Map> recentlyUsed = new HashMap<>(); @@ -40,15 +42,15 @@ public class ComboAbilityManager extends Module { this.bendingPlayerManager = ModuleManager.getModule(BendingPlayerManager.class); this.abilityManager = ModuleManager.getModule(AbilityManager.class); - - this.abilities.clear(); } - public void registerAbility(Class abilityClass, ComboAbilityInfo comboAbilityInfo) { - ComboAbility comboAbility = new ComboAbility(abilityClass, comboAbilityInfo.getName(), comboAbilityInfo.getCombination()); + public void registerAbility(AbilityHandler abilityHandler) { + ComboAbility comboAbility = (ComboAbility) abilityHandler; - this.abilities.put(comboAbilityInfo.getName(), comboAbilityInfo); - this.comboAbilities.add(comboAbility); + ComboAbilityInfo comboAbilityInfo = new ComboAbilityInfo(abilityHandler, comboAbility.getCombination()); + + this.handlerMap.put(abilityHandler.getName(), abilityHandler); + this.comboAbilities.add(comboAbilityInfo); } private void processComboAbility(Player player, ClickType clickType) { @@ -64,41 +66,45 @@ public class ComboAbilityManager extends Module { recentlyUsed.removeLast(); } - ComboAbility comboAbility = getAbility(recentlyUsed); + ComboAbilityInfo comboAbilityInfo = getAbility(recentlyUsed); - if (comboAbility == null) { + if (comboAbilityInfo == null) { return; } - if (!player.hasPermission("bending.ability." + comboAbility.abilityName)) { + if (!player.hasPermission("bending.ability." + comboAbilityInfo.abilityHandler.getName())) { return; } - this.abilityManager.createAbility(player, comboAbility.abilityClass); + comboAbilityInfo.abilityHandler.newInstance(player); } - private ComboAbility getAbility(LinkedList recentlyUsed) { - for (ComboAbility comboAbility : this.comboAbilities) { - int comboSize = comboAbility.combinations.size(); + private ComboAbilityInfo getAbility(LinkedList recentlyUsed) { + for (ComboAbilityInfo comboAbilityInfo : this.comboAbilities) { + int comboSize = comboAbilityInfo.combinationList.size(); if (recentlyUsed.size() < comboSize) { continue; } - if (recentlyUsed.subList(0, comboSize).equals(comboAbility.combinations)) { - return comboAbility; + if (recentlyUsed.subList(0, comboSize).equals(comboAbilityInfo.combinationList)) { + return comboAbilityInfo; } } return null; } - public ComboAbilityInfo getAbility(String abilityName) { - return this.abilities.get(abilityName); + public AbilityHandler getHandler(String abilityName) { + return this.handlerMap.get(abilityName); } - public List getAbilities(Element element) { - return this.abilities.values().stream() + public AbilityHandler getHandler(Class handlerClass) { + return this.handlerMap.get(handlerClass); + } + + public List getHandlers(Element element) { + return this.handlerMap.values().stream() .filter(comboAbilityInfo -> comboAbilityInfo.getElement().equals(element)) .collect(Collectors.toList()); } @@ -212,15 +218,13 @@ public class ComboAbilityManager extends Module { } } - private class ComboAbility { - private final Class abilityClass; - private final String abilityName; - private final List combinations; + private class ComboAbilityInfo { + private final AbilityHandler abilityHandler; + private final List combinationList; - ComboAbility(Class abilityClass, String abilityName, List combinations) { - this.abilityClass = abilityClass; - this.abilityName = abilityName; - this.combinations = combinations; + ComboAbilityInfo(AbilityHandler abilityHandler, List combinationList) { + this.abilityHandler = abilityHandler; + this.combinationList = combinationList; } } } diff --git a/src/com/projectkorra/projectkorra/ability/MultiAbilityManager.java b/src/com/projectkorra/projectkorra/ability/MultiAbilityManager.java index 8db8c003..5e9c736e 100644 --- a/src/com/projectkorra/projectkorra/ability/MultiAbilityManager.java +++ b/src/com/projectkorra/projectkorra/ability/MultiAbilityManager.java @@ -1,9 +1,9 @@ package com.projectkorra.projectkorra.ability; import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ability.api.MultiAbility; import com.projectkorra.projectkorra.ability.api.PlayerBindChangeEvent; -import com.projectkorra.projectkorra.ability.info.AbilityInfo; -import com.projectkorra.projectkorra.ability.info.MultiAbilityInfo; +import com.projectkorra.projectkorra.ability.bind.AbilityBindManager; import com.projectkorra.projectkorra.event.AbilityEndEvent; import com.projectkorra.projectkorra.event.PlayerSwingEvent; import com.projectkorra.projectkorra.module.Module; @@ -16,40 +16,40 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerItemHeldEvent; import java.util.*; +import java.util.stream.Collectors; public class MultiAbilityManager extends Module { private final BendingPlayerManager bendingPlayerManager; private final AbilityManager abilityManager; + private final AbilityBindManager abilityBindManager; - private final Map abilities = new HashMap<>(); - private final Map> multiAbilities = new HashMap<>(); +// private final Map abilities = new HashMap<>(); +// private final Map> multiAbilities = new HashMap<>(); + + private final Map multiAbilityMap = new HashMap<>(); + private final Map handlerMap = new HashMap<>(); private final Map> playerMultiAbility = new HashMap<>(); - private final Map> playerAbilities = new HashMap<>(); + private final Map playerAbilities = new HashMap<>(); private MultiAbilityManager() { super("Multi Ability"); this.bendingPlayerManager = ModuleManager.getModule(BendingPlayerManager.class); this.abilityManager = ModuleManager.getModule(AbilityManager.class); + this.abilityBindManager = ModuleManager.getModule(AbilityBindManager.class); } - public void registerAbility(Class abilityClass, MultiAbilityInfo multiAbilityInfo) { - List> abilities = multiAbilityInfo.getAbilities(); + public void registerAbility(AbilityHandler abilityHandler) { + MultiAbility multiAbility = (MultiAbility) abilityHandler; - Map> abilitiesByName = new HashMap<>(); + Map handlerMap = multiAbility.getAbilities().stream().collect(Collectors.toMap(AbilityHandler::getName, h -> h)); - for (Class ability : abilities) { - AbilityInfo info = this.abilityManager.getAbilityInfo(ability); + MultiAbilityInfo multiAbilityInfo = new MultiAbilityInfo(abilityHandler, new ArrayList<>(handlerMap.keySet())); - abilitiesByName.put(info.getName(), ability); - } - - MultiAbility multiAbility = new MultiAbility(abilityClass, multiAbilityInfo.getName(), abilitiesByName.keySet()); - - this.abilities.put(multiAbilityInfo.getName(), multiAbility); - this.multiAbilities.putAll(abilitiesByName); + this.multiAbilityMap.put(abilityHandler.getName(), multiAbilityInfo); + this.handlerMap.putAll(handlerMap); } @EventHandler @@ -58,22 +58,33 @@ public class MultiAbilityManager extends Module { BendingPlayer bendingPlayer = event.getBendingPlayer(); String abilityName = event.getAbilityName(); - MultiAbility multiAbility = this.abilities.get(abilityName); + MultiAbilityInfo multiAbilityInfo = this.multiAbilityMap.get(abilityName); - if (multiAbility == null) { + if (multiAbilityInfo == null) { return; } - this.playerMultiAbility.put(player.getUniqueId(), multiAbility.abilityClass); + this.playerMultiAbility.put(player.getUniqueId(), multiAbilityInfo.abilityHandler.getAbility()); this.playerAbilities.put(player.getUniqueId(), bendingPlayer.getAbilities()); - Ability ability = this.abilityManager.createAbility(player, multiAbility.abilityClass); + multiAbilityInfo.abilityHandler.newInstance(player); - String[] abilities = multiAbility.abilities.stream() - .filter(name -> player.hasPermission("bending.ability." + multiAbility.abilityName + "." + name)) - .toArray(String[]::new); + // TODO Allow AbilityBindManager to create 'temp' abilities which are not stored + for (int slot = 0; slot < multiAbilityInfo.abilities.size(); slot++) { + String multiAbility = multiAbilityInfo.abilities.get(slot); - bendingPlayer.setAbilities(abilities); + if (!player.hasPermission("bending.ability." + multiAbilityInfo.abilityHandler.getName() + "." + multiAbility)) { + continue; + } + + this.abilityBindManager.bindAbility(player, multiAbility, slot, false); + } + +// String[] abilities = multiAbilityInfo.abilities.stream() +// .filter(name -> player.hasPermission("bending.ability." + multiAbilityInfo.abilityHandler.getName() + "." + name)) +// .toArray(String[]::new); + +// bendingPlayer.setAbilities(abilities); player.getInventory().setHeldItemSlot(0); } @@ -82,13 +93,13 @@ public class MultiAbilityManager extends Module { Player player = event.getPlayer(); String abilityName = event.getAbilityName(); - Class abilityClass = this.multiAbilities.get(abilityName); + AbilityHandler abilityHandler = this.handlerMap.get(abilityName); - if (abilityClass == null) { + if (abilityHandler == null) { return; } - Ability ability = this.abilityManager.createAbility(player, abilityClass); + abilityHandler.newInstance(player); } @EventHandler @@ -96,7 +107,6 @@ public class MultiAbilityManager extends Module { Ability ability = event.getAbility(); Player player = ability.getPlayer(); - BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); Class multiAbility = this.playerMultiAbility.get(player.getUniqueId()); @@ -105,9 +115,9 @@ public class MultiAbilityManager extends Module { } this.playerMultiAbility.remove(player.getUniqueId()); - List abilities = this.playerAbilities.remove(player.getUniqueId()); + String[] abilities = this.playerAbilities.remove(player.getUniqueId()); - bendingPlayer.setAbilities(abilities.toArray(new String[0])); + this.abilityBindManager.setAbilities(player, abilities); } @EventHandler @@ -119,7 +129,7 @@ public class MultiAbilityManager extends Module { return; } - int abilities = bendingPlayer.getAbilities().size(); + int abilities = bendingPlayer.getAbilities().length; if (event.getNewSlot() < abilities) { return; @@ -138,14 +148,12 @@ public class MultiAbilityManager extends Module { GeneralMethods.sendBrandingMessage(event.getPlayer(), ChatColor.RED + "You can't edit your binds right now!"); } - public class MultiAbility { - private final Class abilityClass; - private final String abilityName; - private final Set abilities; + public class MultiAbilityInfo { + private final AbilityHandler abilityHandler; + private final List abilities; - MultiAbility(Class abilityClass, String abilityName, Set abilities) { - this.abilityClass = abilityClass; - this.abilityName = abilityName; + MultiAbilityInfo(AbilityHandler abilityHandler, List abilities) { + this.abilityHandler = abilityHandler; this.abilities = abilities; } } diff --git a/src/com/projectkorra/projectkorra/ability/PassiveAbilityManager.java b/src/com/projectkorra/projectkorra/ability/PassiveAbilityManager.java index 3480bf65..4beafff5 100644 --- a/src/com/projectkorra/projectkorra/ability/PassiveAbilityManager.java +++ b/src/com/projectkorra/projectkorra/ability/PassiveAbilityManager.java @@ -1,25 +1,24 @@ package com.projectkorra.projectkorra.ability; -import com.projectkorra.projectkorra.ability.info.PassiveAbilityInfo; +import com.projectkorra.projectkorra.ability.api.PassiveAbility; import com.projectkorra.projectkorra.element.Element; import com.projectkorra.projectkorra.element.SubElement; import com.projectkorra.projectkorra.module.Module; import com.projectkorra.projectkorra.module.ModuleManager; import com.projectkorra.projectkorra.player.BendingPlayer; import com.projectkorra.projectkorra.player.BendingPlayerManager; +import com.projectkorra.projectkorra.util.MultiKeyMap; import org.bukkit.entity.Player; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class PassiveAbilityManager extends Module { private final BendingPlayerManager bendingPlayerManager; private final AbilityManager abilityManager; - private final Map, PassiveAbilityInfo> abilities = new HashMap<>(); + private final MultiKeyMap handlerMap = new MultiKeyMap<>(); private PassiveAbilityManager() { super("Passive Ability"); @@ -28,38 +27,38 @@ public class PassiveAbilityManager extends Module { this.abilityManager = ModuleManager.getModule(AbilityManager.class); } - public void registerAbility(Class abilityClass, PassiveAbilityInfo passiveAbilityInfo) { - this.abilities.put(abilityClass, passiveAbilityInfo); + public void registerAbility(AbilityHandler abilityHandler) { + this.handlerMap.put(abilityHandler.getName(), abilityHandler); } public void registerPassives(Player player) { - this.abilities.forEach((abilityClass, passiveAbilityInfo) -> { - if (!canUsePassive(player, abilityClass)) { + this.handlerMap.values().forEach(abilityHandler -> { + if (!canUsePassive(player, abilityHandler)) { return; } - if (this.abilityManager.hasAbility(player, abilityClass)) { + if (this.abilityManager.hasAbility(player, abilityHandler.getAbility())) { return; } - if (!passiveAbilityInfo.isInstantiable()) { + if (!((PassiveAbility) abilityHandler).isInstantiable()) { return; } - Ability ability = this.abilityManager.createAbility(player, abilityClass); + Ability ability = abilityHandler.newInstance(player); ability.start(); }); } - public boolean canUsePassive(Player player, Class abilityClass) { + public boolean canUsePassive(Player player, AbilityHandler abilityHandler) { BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); - PassiveAbilityInfo passiveAbilityInfo = this.abilities.get(abilityClass); +// AbilityHandler abilityHandler = this.handlerMap.get(handlerClass); - if (passiveAbilityInfo == null) { - return false; - } +// if (abilityHandler == null) { +// return false; +// } - Element element = passiveAbilityInfo.getElement(); + Element element = abilityHandler.getElement(); if (element instanceof SubElement) { element = ((SubElement) element).getParent(); @@ -80,26 +79,30 @@ public class PassiveAbilityManager extends Module { return true; } - public PassiveAbilityInfo getPassiveAbility(Class abilityClass) { - return this.abilities.get(abilityClass); + public AbilityHandler getHandler(String abbilityName) { + return this.handlerMap.get(abbilityName); } - public List getPassives(Element element) { - List abilities = new ArrayList<>(); + public AbilityHandler getHandler(Class handlerClass) { + return this.handlerMap.get(handlerClass); + } - this.abilities.values().forEach(passiveAbilityInfo -> { + public List getPassives(Element element) { + List handlerList = new ArrayList<>(); - Element passiveElement = passiveAbilityInfo.getElement(); + this.handlerMap.values().forEach(abilityHandler -> { + + Element passiveElement = abilityHandler.getElement(); if (passiveElement instanceof SubElement) { passiveElement = ((SubElement) passiveElement).getParent(); } if (passiveElement.equals(element)) { - abilities.add(passiveAbilityInfo); + handlerList.add(abilityHandler); } }); - return abilities; + return handlerList; } } diff --git a/src/com/projectkorra/projectkorra/ability/info/AddonAbilityInfo.java b/src/com/projectkorra/projectkorra/ability/api/AddonAbility.java similarity index 86% rename from src/com/projectkorra/projectkorra/ability/info/AddonAbilityInfo.java rename to src/com/projectkorra/projectkorra/ability/api/AddonAbility.java index 98b71276..45d06e43 100644 --- a/src/com/projectkorra/projectkorra/ability/info/AddonAbilityInfo.java +++ b/src/com/projectkorra/projectkorra/ability/api/AddonAbility.java @@ -1,8 +1,8 @@ -package com.projectkorra.projectkorra.ability.info; +package com.projectkorra.projectkorra.ability.api; import com.projectkorra.projectkorra.ability.AbilityManager; -public interface AddonAbilityInfo extends AbilityInfo { +public interface AddonAbility { /** * Called when the ability is loaded by PK. This is where the developer diff --git a/src/com/projectkorra/projectkorra/ability/api/AvatarAbility.java b/src/com/projectkorra/projectkorra/ability/api/AvatarAbility.java index d81319bc..dac69ede 100644 --- a/src/com/projectkorra/projectkorra/ability/api/AvatarAbility.java +++ b/src/com/projectkorra/projectkorra/ability/api/AvatarAbility.java @@ -1,32 +1,6 @@ package com.projectkorra.projectkorra.ability.api; -import com.projectkorra.projectkorra.ability.info.AbilityInfo; -import com.projectkorra.projectkorra.configuration.ConfigManager; -import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig; -import com.projectkorra.projectkorra.configuration.configs.abilities.avatar.AvatarStateConfig; -import org.bukkit.Location; -import org.bukkit.entity.Player; +public interface AvatarAbility { -public abstract class AvatarAbility extends ElementalAbility { - - public AvatarAbility(final Player player) { - super(player); - } - - @Override - public boolean isIgniteAbility() { - return false; - } - - @Override - public boolean isExplosiveAbility() { - return false; - } - - public static void playAvatarSound(final Location loc) { - AvatarStateConfig avatar = ConfigManager.getConfig(AvatarStateConfig.class); - if (avatar.PlaySound) { - loc.getWorld().playSound(loc, avatar.SoundType, avatar.SoundVolume, avatar.SoundPitch); - } - } + boolean requireAvatar(); } diff --git a/src/com/projectkorra/projectkorra/ability/api/ChiAbility.java b/src/com/projectkorra/projectkorra/ability/api/ChiAbility.java deleted file mode 100644 index 01acd102..00000000 --- a/src/com/projectkorra/projectkorra/ability/api/ChiAbility.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.projectkorra.projectkorra.ability.api; - -import com.projectkorra.projectkorra.ability.info.AbilityInfo; -import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig; -import org.bukkit.entity.Player; - -public abstract class ChiAbility extends ElementalAbility { - - public ChiAbility(final Player player) { - super(player); - } - - @Override - public boolean isIgniteAbility() { - return false; - } - - @Override - public boolean isExplosiveAbility() { - return false; - } -} diff --git a/src/com/projectkorra/projectkorra/ability/info/ComboAbilityInfo.java b/src/com/projectkorra/projectkorra/ability/api/ComboAbility.java similarity index 73% rename from src/com/projectkorra/projectkorra/ability/info/ComboAbilityInfo.java rename to src/com/projectkorra/projectkorra/ability/api/ComboAbility.java index d2915eec..815f39bf 100644 --- a/src/com/projectkorra/projectkorra/ability/info/ComboAbilityInfo.java +++ b/src/com/projectkorra/projectkorra/ability/api/ComboAbility.java @@ -1,10 +1,10 @@ -package com.projectkorra.projectkorra.ability.info; +package com.projectkorra.projectkorra.ability.api; import com.projectkorra.projectkorra.ability.ComboAbilityManager; import java.util.LinkedList; -public interface ComboAbilityInfo extends AbilityInfo { +public interface ComboAbility { /** * Returns the list of abilities which constitute the combo. diff --git a/src/com/projectkorra/projectkorra/ability/info/MultiAbilityInfo.java b/src/com/projectkorra/projectkorra/ability/api/MultiAbility.java similarity index 51% rename from src/com/projectkorra/projectkorra/ability/info/MultiAbilityInfo.java rename to src/com/projectkorra/projectkorra/ability/api/MultiAbility.java index a3c02019..66d425ca 100644 --- a/src/com/projectkorra/projectkorra/ability/info/MultiAbilityInfo.java +++ b/src/com/projectkorra/projectkorra/ability/api/MultiAbility.java @@ -1,10 +1,10 @@ -package com.projectkorra.projectkorra.ability.info; +package com.projectkorra.projectkorra.ability.api; -import com.projectkorra.projectkorra.ability.Ability; +import com.projectkorra.projectkorra.ability.AbilityHandler; import java.util.List; -public interface MultiAbilityInfo extends AbilityInfo { +public interface MultiAbility { /** * Returns the sub abilities of a MultiAbility. For example: @@ -14,5 +14,5 @@ public interface MultiAbilityInfo extends AbilityInfo { * * @return a list of sub MultiAbilities */ - List> getAbilities(); + List getAbilities(); } diff --git a/src/com/projectkorra/projectkorra/ability/info/PassiveAbilityInfo.java b/src/com/projectkorra/projectkorra/ability/api/PassiveAbility.java similarity index 79% rename from src/com/projectkorra/projectkorra/ability/info/PassiveAbilityInfo.java rename to src/com/projectkorra/projectkorra/ability/api/PassiveAbility.java index 963617dd..8a2afd73 100644 --- a/src/com/projectkorra/projectkorra/ability/info/PassiveAbilityInfo.java +++ b/src/com/projectkorra/projectkorra/ability/api/PassiveAbility.java @@ -1,6 +1,6 @@ -package com.projectkorra.projectkorra.ability.info; +package com.projectkorra.projectkorra.ability.api; -public interface PassiveAbilityInfo extends AbilityInfo { +public interface PassiveAbility { /** * This is a check to see if the passive requires some form of activation, diff --git a/src/com/projectkorra/projectkorra/ability/bind/AbilityBindManager.java b/src/com/projectkorra/projectkorra/ability/bind/AbilityBindManager.java index 25449f99..91ece5cf 100644 --- a/src/com/projectkorra/projectkorra/ability/bind/AbilityBindManager.java +++ b/src/com/projectkorra/projectkorra/ability/bind/AbilityBindManager.java @@ -1,26 +1,36 @@ package com.projectkorra.projectkorra.ability.bind; -import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ability.AbilityHandler; +import com.projectkorra.projectkorra.ability.AbilityManager; import com.projectkorra.projectkorra.ability.api.PlayerBindChangeEvent; +import com.projectkorra.projectkorra.configuration.ConfigManager; +import com.projectkorra.projectkorra.configuration.configs.properties.GeneralPropertiesConfig; import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent; -import com.projectkorra.projectkorra.module.DatabaseModule; import com.projectkorra.projectkorra.module.ModuleManager; +import com.projectkorra.projectkorra.module.PlayerDatabaseModule; import com.projectkorra.projectkorra.player.BendingPlayer; import com.projectkorra.projectkorra.player.BendingPlayerLoadedEvent; import com.projectkorra.projectkorra.player.BendingPlayerManager; +import com.projectkorra.projectkorra.util.ActionBar; +import com.projectkorra.projectkorra.util.TimeUtil; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import java.sql.SQLException; +import java.util.Arrays; +import java.util.UUID; -public class AbilityBindManager extends DatabaseModule { +public class AbilityBindManager extends PlayerDatabaseModule { private final BendingPlayerManager bendingPlayerManager; + private final AbilityManager abilityManager; private AbilityBindManager() { super("Ability Binds", new AbilityBindRepository()); this.bendingPlayerManager = ModuleManager.getModule(BendingPlayerManager.class); + this.abilityManager = ModuleManager.getModule(AbilityManager.class); runAsync(() -> { try { @@ -37,20 +47,37 @@ public class AbilityBindManager extends DatabaseModule { @EventHandler public void onBendingPlayerLoaded(BendingPlayerLoadedEvent event) { + Player player = event.getPlayer(); BendingPlayer bendingPlayer = event.getBendingPlayer(); runAsync(() -> { try { String[] abilities = getRepository().selectPlayerAbilities(bendingPlayer.getId()); - bendingPlayer.setAbilities(abilities); + setData(player, abilities); } catch (SQLException e) { e.printStackTrace(); } }); } + @EventHandler + public void onCooldownChange(PlayerCooldownChangeEvent event) { + Player player = event.getPlayer(); + + int slot = player.getInventory().getHeldItemSlot(); + String abilityName = getData(player)[slot]; + + if (abilityName != null && abilityName.equals(event.getAbility())) { + displayMovePreview(player, slot); + } + } + public Result bindAbility(Player player, String abilityName, int slot) { + return bindAbility(player, abilityName, slot, true); + } + + public Result bindAbility(Player player, String abilityName, int slot, boolean save) { BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); PlayerBindChangeEvent playerBindChangeEvent = new PlayerBindChangeEvent(player, abilityName, slot, PlayerBindChangeEvent.Reason.ADD); @@ -60,15 +87,17 @@ public class AbilityBindManager extends DatabaseModule { return Result.CANCELLED; } - bendingPlayer.setAbility(slot, abilityName); + getData(player)[slot] = abilityName; - runAsync(() -> { - try { - getRepository().insertPlayerAbility(bendingPlayer.getId(), abilityName, slot); - } catch (SQLException e) { - e.printStackTrace(); - } - }); + if (save) { + runAsync(() -> { + try { + getRepository().insertPlayerAbility(bendingPlayer.getId(), abilityName, slot); + } catch (SQLException e) { + e.printStackTrace(); + } + }); + } return Result.SUCCESS; } @@ -88,7 +117,7 @@ public class AbilityBindManager extends DatabaseModule { return Result.CANCELLED; } - bendingPlayer.setAbility(slot, null); + getData(player)[slot] = null; runAsync(() -> { try { @@ -101,7 +130,7 @@ public class AbilityBindManager extends DatabaseModule { return Result.SUCCESS; } - public Result clearBinds(Player player) { + public Result clearAbilities(Player player) { BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); PlayerBindChangeEvent playerBindChangeEvent = new PlayerBindChangeEvent(player, PlayerBindChangeEvent.Reason.REMOVE); @@ -111,7 +140,7 @@ public class AbilityBindManager extends DatabaseModule { return Result.CANCELLED; } - bendingPlayer.setAbilities(new String[9]); + Arrays.fill(getData(player), null); runAsync(() -> { try { @@ -124,6 +153,69 @@ public class AbilityBindManager extends DatabaseModule { return Result.SUCCESS; } + public void setAbilities(Player player, String[] abilities) { + setData(player, abilities); + } + + public String getBoundAbility(Player player) { + return getAbility(player, player.getInventory().getHeldItemSlot()); + } + + public String getAbility(Player player, int slot) { + return getData(player)[slot]; + } + + public String[] getAbilities(Player player) { + String[] abilities = getData(player); + + return Arrays.copyOf(abilities, abilities.length); + } + + public void displayMovePreview(Player player, int slot) { + if (!ConfigManager.getConfig(GeneralPropertiesConfig.class).BendingPreview) { + return; + } + + String abilityName = getData(player)[slot]; + + if (abilityName == null) { + ActionBar.sendActionBar("", player); + return; + } + + AbilityHandler abilityHandler = this.abilityManager.getHandler(abilityName); + + if (abilityHandler == null) { + ActionBar.sendActionBar(abilityName, player); + return; + } + + BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); + + if (bendingPlayer.isOnCooldown(abilityName)) { + long cooldown = bendingPlayer.getCooldown(abilityName) - System.currentTimeMillis(); + String display = abilityHandler.getElement().getColor() + (ChatColor.STRIKETHROUGH + abilityHandler.getName() + abilityHandler.getElement().getColor() + " - " + TimeUtil.formatTime(cooldown)); + + ActionBar.sendActionBar(display, player); + return; + } + + String display = abilityHandler.getElement().getColor().toString(); + + if (bendingPlayer.getStance() != null && bendingPlayer.getStance().getName().equals(abilityHandler.getName())) { + display += ChatColor.UNDERLINE.toString(); + } + + display += abilityHandler.getName(); + + ActionBar.sendActionBar(display, player); + } + + @Override + protected String[] addData(UUID uuid) { + return new String[9]; + } + public enum Result { SUCCESS, CANCELLED, ALREADY_EMPTY } diff --git a/src/com/projectkorra/projectkorra/ability/info/AbilityInfo.java b/src/com/projectkorra/projectkorra/ability/info/AbilityInfo.java deleted file mode 100644 index 8bd668c9..00000000 --- a/src/com/projectkorra/projectkorra/ability/info/AbilityInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.projectkorra.projectkorra.ability.info; - -import com.projectkorra.projectkorra.ability.Ability; -import com.projectkorra.projectkorra.element.Element; -import com.projectkorra.projectkorra.player.BendingPlayer; - -public interface AbilityInfo { - - /** - * The name of the ability is used for commands such as /bending - * display and /bending help. The name is also used for - * determining the tag for cooldowns - * {@link BendingPlayer#addCooldown(Ability)}, therefore if two abilities - * have the same name they will also share cooldowns. If two classes share - * the same name (SurgeWall/SurgeWave) but need to have independent - * cooldowns, then {@link BendingPlayer#addCooldown(String, long)} should be - * called explicitly. - * - * @return Returns the name of the ability - */ - String getName(); - - Element getElement(); - - String getDescription(); - - String getInstructions(); - - /** - * @return true if this is a hidden ability. - */ - default boolean isHidden() { - return false; - } -} diff --git a/src/com/projectkorra/projectkorra/ability/info/AvatarAbilityInfo.java b/src/com/projectkorra/projectkorra/ability/info/AvatarAbilityInfo.java deleted file mode 100644 index 34f6a289..00000000 --- a/src/com/projectkorra/projectkorra/ability/info/AvatarAbilityInfo.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.projectkorra.projectkorra.ability.info; - -public interface AvatarAbilityInfo extends AbilityInfo { - - boolean requireAvatar(); -} diff --git a/src/com/projectkorra/projectkorra/ability/api/AirAbility.java b/src/com/projectkorra/projectkorra/ability/legacy/AirAbility.java similarity index 95% rename from src/com/projectkorra/projectkorra/ability/api/AirAbility.java rename to src/com/projectkorra/projectkorra/ability/legacy/AirAbility.java index cf35df97..974cd857 100644 --- a/src/com/projectkorra/projectkorra/ability/api/AirAbility.java +++ b/src/com/projectkorra/projectkorra/ability/legacy/AirAbility.java @@ -1,13 +1,4 @@ -package com.projectkorra.projectkorra.ability.api; - -import java.util.ArrayList; -import java.util.List; - -import com.projectkorra.projectkorra.ability.info.AbilityInfo; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; +package com.projectkorra.projectkorra.ability.legacy; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.util.Collision; @@ -17,8 +8,15 @@ import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig; import com.projectkorra.projectkorra.configuration.configs.properties.AirPropertiesConfig; import com.projectkorra.projectkorra.util.ParticleEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; -public abstract class AirAbility extends ElementalAbility { +import java.util.ArrayList; +import java.util.List; + +public abstract class AirAbility extends ElementalAbility { public AirAbility(final Player player) { super(player); diff --git a/src/com/projectkorra/projectkorra/ability/legacy/AvatarAbility.java b/src/com/projectkorra/projectkorra/ability/legacy/AvatarAbility.java new file mode 100644 index 00000000..f34125ce --- /dev/null +++ b/src/com/projectkorra/projectkorra/ability/legacy/AvatarAbility.java @@ -0,0 +1,32 @@ +package com.projectkorra.projectkorra.ability.legacy; + +import com.projectkorra.projectkorra.ability.info.AbilityInfo; +import com.projectkorra.projectkorra.configuration.ConfigManager; +import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig; +import com.projectkorra.projectkorra.configuration.configs.abilities.avatar.AvatarStateConfig; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public abstract class AvatarAbility extends ElementalAbility { + + public AvatarAbility(final Player player) { + super(player); + } + + @Override + public boolean isIgniteAbility() { + return false; + } + + @Override + public boolean isExplosiveAbility() { + return false; + } + + public static void playAvatarSound(final Location loc) { + AvatarStateConfig avatar = ConfigManager.getConfig(AvatarStateConfig.class); + if (avatar.PlaySound) { + loc.getWorld().playSound(loc, avatar.SoundType, avatar.SoundVolume, avatar.SoundPitch); + } + } +} diff --git a/src/com/projectkorra/projectkorra/ability/api/BloodAbility.java b/src/com/projectkorra/projectkorra/ability/legacy/BloodAbility.java similarity index 92% rename from src/com/projectkorra/projectkorra/ability/api/BloodAbility.java rename to src/com/projectkorra/projectkorra/ability/legacy/BloodAbility.java index 379cc1a2..f8b4783f 100644 --- a/src/com/projectkorra/projectkorra/ability/api/BloodAbility.java +++ b/src/com/projectkorra/projectkorra/ability/legacy/BloodAbility.java @@ -1,4 +1,4 @@ -package com.projectkorra.projectkorra.ability.api; +package com.projectkorra.projectkorra.ability.legacy; import com.projectkorra.projectkorra.ability.Ability; import com.projectkorra.projectkorra.ability.info.AbilityInfo; diff --git a/src/com/projectkorra/projectkorra/ability/legacy/ChiAbility.java b/src/com/projectkorra/projectkorra/ability/legacy/ChiAbility.java new file mode 100644 index 00000000..7b23a3eb --- /dev/null +++ b/src/com/projectkorra/projectkorra/ability/legacy/ChiAbility.java @@ -0,0 +1,22 @@ +package com.projectkorra.projectkorra.ability.legacy; + +import com.projectkorra.projectkorra.ability.AbilityHandler; +import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig; +import org.bukkit.entity.Player; + +public abstract class ChiAbility extends ElementalAbility { + + public ChiAbility(final Handler abilityHandler, final Player player) { + super(abilityHandler, player); + } + + @Override + public boolean isIgniteAbility() { + return false; + } + + @Override + public boolean isExplosiveAbility() { + return false; + } +} diff --git a/src/com/projectkorra/projectkorra/ability/api/CombustionAbility.java b/src/com/projectkorra/projectkorra/ability/legacy/CombustionAbility.java similarity index 91% rename from src/com/projectkorra/projectkorra/ability/api/CombustionAbility.java rename to src/com/projectkorra/projectkorra/ability/legacy/CombustionAbility.java index 5e849f7b..b8891e38 100644 --- a/src/com/projectkorra/projectkorra/ability/api/CombustionAbility.java +++ b/src/com/projectkorra/projectkorra/ability/legacy/CombustionAbility.java @@ -1,4 +1,4 @@ -package com.projectkorra.projectkorra.ability.api; +package com.projectkorra.projectkorra.ability.legacy; import com.projectkorra.projectkorra.ability.Ability; import com.projectkorra.projectkorra.ability.info.AbilityInfo; diff --git a/src/com/projectkorra/projectkorra/ability/api/EarthAbility.java b/src/com/projectkorra/projectkorra/ability/legacy/EarthAbility.java similarity index 99% rename from src/com/projectkorra/projectkorra/ability/api/EarthAbility.java rename to src/com/projectkorra/projectkorra/ability/legacy/EarthAbility.java index ff03896c..8e8a77e6 100644 --- a/src/com/projectkorra/projectkorra/ability/api/EarthAbility.java +++ b/src/com/projectkorra/projectkorra/ability/legacy/EarthAbility.java @@ -1,4 +1,4 @@ -package com.projectkorra.projectkorra.ability.api; +package com.projectkorra.projectkorra.ability.legacy; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; diff --git a/src/com/projectkorra/projectkorra/ability/api/ElementalAbility.java b/src/com/projectkorra/projectkorra/ability/legacy/ElementalAbility.java similarity index 95% rename from src/com/projectkorra/projectkorra/ability/api/ElementalAbility.java rename to src/com/projectkorra/projectkorra/ability/legacy/ElementalAbility.java index c4722f26..dd0152bb 100644 --- a/src/com/projectkorra/projectkorra/ability/api/ElementalAbility.java +++ b/src/com/projectkorra/projectkorra/ability/legacy/ElementalAbility.java @@ -1,8 +1,8 @@ -package com.projectkorra.projectkorra.ability.api; +package com.projectkorra.projectkorra.ability.legacy; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.Ability; -import com.projectkorra.projectkorra.ability.info.AbilityInfo; +import com.projectkorra.projectkorra.ability.AbilityHandler; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig; import com.projectkorra.projectkorra.configuration.configs.properties.EarthPropertiesConfig; @@ -27,7 +27,7 @@ import java.util.stream.Stream; * Air, Water, Earth, Fire, Chi, or AvatarAbility. This class is mainly used to * keep CoreAbility from becoming too cluttered. */ -public abstract class ElementalAbility extends Ability { +public abstract class ElementalAbility extends Ability { private static final PotionEffectType[] POSITIVE_EFFECTS = { PotionEffectType.ABSORPTION, PotionEffectType.DAMAGE_RESISTANCE, PotionEffectType.FAST_DIGGING, PotionEffectType.FIRE_RESISTANCE, PotionEffectType.HEAL, PotionEffectType.HEALTH_BOOST, PotionEffectType.INCREASE_DAMAGE, PotionEffectType.JUMP, PotionEffectType.NIGHT_VISION, PotionEffectType.REGENERATION, PotionEffectType.SATURATION, PotionEffectType.SPEED, PotionEffectType.WATER_BREATHING }; private static final PotionEffectType[] NEUTRAL_EFFECTS = { PotionEffectType.INVISIBILITY }; private static final PotionEffectType[] NEGATIVE_EFFECTS = { PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER }; @@ -42,8 +42,8 @@ public abstract class ElementalAbility { +public class AirSaturation extends AirAbility { + @Override + public boolean isSneakAbility() { + return false; + } + + @Override + public boolean isHarmlessAbility() { + return false; + } + + @Override + public long getCooldown() { + return 0; + } + + @Override + public String getName() { + return null; + } + public AirSaturation(final Player player) { super(player); } @@ -19,51 +42,70 @@ public class AirSaturation extends AirAbility getConfigType() { - return AirSaturationConfig.class; - } -} - -class AirSaturationInfo extends AirPassiveAbilityInfo { - - @Override - public String getName() { - return "AirSaturation"; - } - - @Override - public boolean isInstantiable() { - return false; - } - - @Override - public boolean isProgressable() { - return false; + public static class AirSaturationHandler extends AbilityHandler implements PassiveAbility { + + public AirSaturationHandler(Class abilityClass, Class configClass) { + super(abilityClass, configClass); + } + + @Override + public String getName() { + return "AirSaturation"; + } + + @Override + public boolean isSneakAbility() { + return false; + } + + @Override + public boolean isHarmlessAbility() { + return false; + } + + @Override + public boolean isIgniteAbility() { + return false; + } + + @Override + public boolean isExplosiveAbility() { + return false; + } + + @Override + public long getCooldown() { + return 0; + } + + @Override + public Element getElement() { + return null; + } + + @Override + public String getDescription() { + return null; + } + + @Override + public String getInstructions() { + return null; + } + + @Override + public boolean isInstantiable() { + return false; + } + + @Override + public boolean isProgressable() { + return false; + } } } diff --git a/src/com/projectkorra/projectkorra/airbending/passive/GracefulDescent.java b/src/com/projectkorra/projectkorra/airbending/passive/GracefulDescent.java index ad0811b0..6d13f91b 100644 --- a/src/com/projectkorra/projectkorra/airbending/passive/GracefulDescent.java +++ b/src/com/projectkorra/projectkorra/airbending/passive/GracefulDescent.java @@ -3,7 +3,7 @@ package com.projectkorra.projectkorra.airbending.passive; import org.bukkit.Location; import org.bukkit.entity.Player; -import com.projectkorra.projectkorra.ability.api.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; import com.projectkorra.projectkorra.configuration.configs.abilities.air.GracefulDescentConfig; diff --git a/src/com/projectkorra/projectkorra/airbending/util/AirAddonAbilityInfo.java b/src/com/projectkorra/projectkorra/airbending/util/AirAddonAbilityInfo.java index 4541d567..cccb76f5 100644 --- a/src/com/projectkorra/projectkorra/airbending/util/AirAddonAbilityInfo.java +++ b/src/com/projectkorra/projectkorra/airbending/util/AirAddonAbilityInfo.java @@ -1,6 +1,6 @@ package com.projectkorra.projectkorra.airbending.util; -import com.projectkorra.projectkorra.ability.info.AddonAbilityInfo; +import com.projectkorra.projectkorra.ability.api.AddonAbilityInfo; import com.projectkorra.projectkorra.element.Element; import com.projectkorra.projectkorra.element.ElementManager; import com.projectkorra.projectkorra.module.ModuleManager; diff --git a/src/com/projectkorra/projectkorra/airbending/util/AirPassiveAbilityInfo.java b/src/com/projectkorra/projectkorra/airbending/util/AirPassiveAbilityInfo.java index d18ef646..f1aee790 100644 --- a/src/com/projectkorra/projectkorra/airbending/util/AirPassiveAbilityInfo.java +++ b/src/com/projectkorra/projectkorra/airbending/util/AirPassiveAbilityInfo.java @@ -1,6 +1,6 @@ package com.projectkorra.projectkorra.airbending.util; -import com.projectkorra.projectkorra.ability.info.PassiveAbilityInfo; +import com.projectkorra.projectkorra.ability.api.PassiveAbilityInfo; import com.projectkorra.projectkorra.element.Element; import com.projectkorra.projectkorra.element.ElementManager; import com.projectkorra.projectkorra.module.ModuleManager; diff --git a/src/com/projectkorra/projectkorra/avatar/AvatarState.java b/src/com/projectkorra/projectkorra/avatar/AvatarState.java index 3f194300..5c2941d4 100644 --- a/src/com/projectkorra/projectkorra/avatar/AvatarState.java +++ b/src/com/projectkorra/projectkorra/avatar/AvatarState.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import com.projectkorra.projectkorra.ability.api.AvatarAbility; +import com.projectkorra.projectkorra.ability.legacy.AvatarAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.avatar.AvatarStateConfig; diff --git a/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java b/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java index 277ddf28..47159954 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java +++ b/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java @@ -8,7 +8,7 @@ import org.bukkit.potion.PotionEffectType; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.AcrobatStanceConfig; diff --git a/src/com/projectkorra/projectkorra/chiblocking/HighJump.java b/src/com/projectkorra/projectkorra/chiblocking/HighJump.java index ee4dad96..5da7d1dc 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/HighJump.java +++ b/src/com/projectkorra/projectkorra/chiblocking/HighJump.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.HighJumpConfig; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArmsWhip; diff --git a/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java b/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java index 52ea75a9..2106f29d 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java +++ b/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java @@ -8,7 +8,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.Element; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.airbending.Suffocate; import com.projectkorra.projectkorra.attribute.Attribute; diff --git a/src/com/projectkorra/projectkorra/chiblocking/QuickStrike.java b/src/com/projectkorra/projectkorra/chiblocking/QuickStrike.java index c95ed859..14d2d70b 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/QuickStrike.java +++ b/src/com/projectkorra/projectkorra/chiblocking/QuickStrike.java @@ -4,7 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.chiblocking.passive.ChiPassive; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.QuickStrikeConfig; diff --git a/src/com/projectkorra/projectkorra/chiblocking/RapidPunch.java b/src/com/projectkorra/projectkorra/chiblocking/RapidPunch.java index 5b060fd2..4f5c5c50 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/RapidPunch.java +++ b/src/com/projectkorra/projectkorra/chiblocking/RapidPunch.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.airbending.Suffocate; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.chiblocking.passive.ChiPassive; diff --git a/src/com/projectkorra/projectkorra/chiblocking/Smokescreen.java b/src/com/projectkorra/projectkorra/chiblocking/Smokescreen.java index 54a98f80..f4a7edda 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/Smokescreen.java +++ b/src/com/projectkorra/projectkorra/chiblocking/Smokescreen.java @@ -11,7 +11,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.SmokescreenConfig; diff --git a/src/com/projectkorra/projectkorra/chiblocking/SwiftKick.java b/src/com/projectkorra/projectkorra/chiblocking/SwiftKick.java index 6ee2aafc..3201a2d6 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/SwiftKick.java +++ b/src/com/projectkorra/projectkorra/chiblocking/SwiftKick.java @@ -4,8 +4,8 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import com.projectkorra.projectkorra.ability.api.ChiAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.chiblocking.passive.ChiPassive; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.SwiftKickConfig; diff --git a/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java b/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java index d9f2d796..dbe7edd3 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java +++ b/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java @@ -8,7 +8,7 @@ import org.bukkit.potion.PotionEffectType; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.WarriorStanceConfig; diff --git a/src/com/projectkorra/projectkorra/chiblocking/combo/Immobilize.java b/src/com/projectkorra/projectkorra/chiblocking/combo/Immobilize.java index d9c7dd89..d1b120ee 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/combo/Immobilize.java +++ b/src/com/projectkorra/projectkorra/chiblocking/combo/Immobilize.java @@ -9,7 +9,7 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.api.ComboAbility; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; diff --git a/src/com/projectkorra/projectkorra/chiblocking/passive/Acrobatics.java b/src/com/projectkorra/projectkorra/chiblocking/passive/Acrobatics.java index 80b76e5b..cbb70aba 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/passive/Acrobatics.java +++ b/src/com/projectkorra/projectkorra/chiblocking/passive/Acrobatics.java @@ -3,7 +3,7 @@ package com.projectkorra.projectkorra.chiblocking.passive; import org.bukkit.Location; import org.bukkit.entity.Player; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.AcrobaticsConfig; diff --git a/src/com/projectkorra/projectkorra/chiblocking/passive/ChiAgility.java b/src/com/projectkorra/projectkorra/chiblocking/passive/ChiAgility.java index ad1911ba..3fd65183 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/passive/ChiAgility.java +++ b/src/com/projectkorra/projectkorra/chiblocking/passive/ChiAgility.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.ChiAgilityConfig; diff --git a/src/com/projectkorra/projectkorra/chiblocking/passive/ChiPassive.java b/src/com/projectkorra/projectkorra/chiblocking/passive/ChiPassive.java index e2446d12..e36d017c 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/passive/ChiPassive.java +++ b/src/com/projectkorra/projectkorra/chiblocking/passive/ChiPassive.java @@ -7,7 +7,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.airbending.Suffocate; import com.projectkorra.projectkorra.chiblocking.AcrobatStance; diff --git a/src/com/projectkorra/projectkorra/chiblocking/passive/ChiSaturation.java b/src/com/projectkorra/projectkorra/chiblocking/passive/ChiSaturation.java index b3dac390..9dc99b22 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/passive/ChiSaturation.java +++ b/src/com/projectkorra/projectkorra/chiblocking/passive/ChiSaturation.java @@ -1,16 +1,18 @@ package com.projectkorra.projectkorra.chiblocking.passive; +import com.projectkorra.projectkorra.ability.AbilityHandler; +import com.projectkorra.projectkorra.element.Element; import org.bukkit.Location; import org.bukkit.entity.Player; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.chi.ChiSaturationConfig; -public class ChiSaturation extends ChiAbility implements PassiveAbility { - public ChiSaturation(final ChiSaturationConfig config, final Player player) { - super(config, player); +public class ChiSaturation extends ChiAbility implements PassiveAbility { + private ChiSaturation(final ChiSaturationHandler abilityHandler, final Player player) { + super(abilityHandler, player); } public static double getExhaustionFactor() { @@ -54,9 +56,66 @@ public class ChiSaturation extends ChiAbility implements Pa public boolean isProgressable() { return false; } - - @Override - public Class getConfigType() { - return ChiSaturationConfig.class; + + public static class ChiSaturationHandler extends AbilityHandler implements PassiveAbility { + + public ChiSaturationHandler(Class abilityClass, Class configClass) { + super(abilityClass, configClass); + } + + @Override + public String getName() { + return "ChiSaturation"; + } + + @Override + public boolean isSneakAbility() { + return false; + } + + @Override + public boolean isHarmlessAbility() { + return false; + } + + @Override + public boolean isIgniteAbility() { + return false; + } + + @Override + public boolean isExplosiveAbility() { + return false; + } + + @Override + public long getCooldown() { + return 0; + } + + @Override + public Element getElement() { + return null; + } + + @Override + public String getDescription() { + return null; + } + + @Override + public String getInstructions() { + return null; + } + + @Override + public boolean isInstantiable() { + return false; + } + + @Override + public boolean isProgressable() { + return false; + } } } diff --git a/src/com/projectkorra/projectkorra/command/AddCommand.java b/src/com/projectkorra/projectkorra/command/AddCommand.java index 1ae05f69..b1942519 100644 --- a/src/com/projectkorra/projectkorra/command/AddCommand.java +++ b/src/com/projectkorra/projectkorra/command/AddCommand.java @@ -6,8 +6,6 @@ import com.projectkorra.projectkorra.configuration.configs.commands.AddCommandCo import com.projectkorra.projectkorra.configuration.configs.properties.CommandPropertiesConfig; import com.projectkorra.projectkorra.element.Element; import com.projectkorra.projectkorra.element.SubElement; -import com.projectkorra.projectkorra.event.PlayerChangeElementEvent; -import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result; import com.projectkorra.projectkorra.player.BendingPlayer; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -112,8 +110,6 @@ public class AddCommand extends PKCommand { } elements.append(element.getColor() + element.getName()); - - Bukkit.getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.ADD)); } if (added.size() > 0) { @@ -161,8 +157,6 @@ public class AddCommand extends PKCommand { this.elementManager.addElement(target, elem); added.add(elem); - - Bukkit.getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, elem, Result.ADD)); } if (added.isEmpty()) { diff --git a/src/com/projectkorra/projectkorra/command/BindCommand.java b/src/com/projectkorra/projectkorra/command/BindCommand.java index 36b140b1..d637e0d2 100644 --- a/src/com/projectkorra/projectkorra/command/BindCommand.java +++ b/src/com/projectkorra/projectkorra/command/BindCommand.java @@ -3,8 +3,8 @@ package com.projectkorra.projectkorra.command; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.bind.AbilityBindManager; import com.projectkorra.projectkorra.ability.info.AbilityInfo; -import com.projectkorra.projectkorra.ability.info.ComboAbilityInfo; -import com.projectkorra.projectkorra.ability.info.PassiveAbilityInfo; +import com.projectkorra.projectkorra.ability.api.ComboAbilityInfo; +import com.projectkorra.projectkorra.ability.api.PassiveAbilityInfo; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.commands.BindCommandConfig; import com.projectkorra.projectkorra.element.Element; diff --git a/src/com/projectkorra/projectkorra/command/ClearCommand.java b/src/com/projectkorra/projectkorra/command/ClearCommand.java index bdd24ba5..fd30d38a 100644 --- a/src/com/projectkorra/projectkorra/command/ClearCommand.java +++ b/src/com/projectkorra/projectkorra/command/ClearCommand.java @@ -43,7 +43,7 @@ public class ClearCommand extends PKCommand { Player player = (Player) sender; if (args.isEmpty()) { - if (this.abilityBindManager.clearBinds(player) == AbilityBindManager.Result.SUCCESS) { + if (this.abilityBindManager.clearAbilities(player) == AbilityBindManager.Result.SUCCESS) { GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + this.cleared); } diff --git a/src/com/projectkorra/projectkorra/command/DisplayCommand.java b/src/com/projectkorra/projectkorra/command/DisplayCommand.java index 8b5c2382..54eaea30 100644 --- a/src/com/projectkorra/projectkorra/command/DisplayCommand.java +++ b/src/com/projectkorra/projectkorra/command/DisplayCommand.java @@ -4,13 +4,11 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Objects; -import java.util.Set; -import java.util.stream.Stream; import com.projectkorra.projectkorra.ability.info.AbilityInfo; -import com.projectkorra.projectkorra.ability.info.AddonAbilityInfo; -import com.projectkorra.projectkorra.ability.info.ComboAbilityInfo; -import com.projectkorra.projectkorra.ability.info.PassiveAbilityInfo; +import com.projectkorra.projectkorra.ability.api.AddonAbilityInfo; +import com.projectkorra.projectkorra.ability.api.ComboAbilityInfo; +import com.projectkorra.projectkorra.ability.api.PassiveAbilityInfo; import com.projectkorra.projectkorra.element.Element; import com.projectkorra.projectkorra.element.SubElement; import com.projectkorra.projectkorra.player.BendingPlayer; @@ -19,7 +17,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.SubAbility; +import com.projectkorra.projectkorra.ability.legacy.SubAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.commands.DisplayCommandConfig; import com.projectkorra.projectkorra.configuration.configs.properties.CommandPropertiesConfig; @@ -292,7 +290,7 @@ public class DisplayCommand extends PKCommand { /** * Displays a Player's bound abilities. * - * @param sender The CommandSender to output the bound abilities to + * @param player The Player to output the bound abilities to */ private void displayBinds(final Player player) { BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); diff --git a/src/com/projectkorra/projectkorra/command/HelpCommand.java b/src/com/projectkorra/projectkorra/command/HelpCommand.java index f61981fd..ab304df4 100644 --- a/src/com/projectkorra/projectkorra/command/HelpCommand.java +++ b/src/com/projectkorra/projectkorra/command/HelpCommand.java @@ -2,9 +2,9 @@ package com.projectkorra.projectkorra.command; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.info.AbilityInfo; -import com.projectkorra.projectkorra.ability.info.AddonAbilityInfo; -import com.projectkorra.projectkorra.ability.info.ComboAbilityInfo; -import com.projectkorra.projectkorra.ability.info.PassiveAbilityInfo; +import com.projectkorra.projectkorra.ability.api.AddonAbilityInfo; +import com.projectkorra.projectkorra.ability.api.ComboAbilityInfo; +import com.projectkorra.projectkorra.ability.api.PassiveAbilityInfo; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.commands.HelpCommandConfig; import com.projectkorra.projectkorra.configuration.configs.properties.*; diff --git a/src/com/projectkorra/projectkorra/command/PermaremoveCommand.java b/src/com/projectkorra/projectkorra/command/PermaremoveCommand.java index 900bd7a4..1de590c7 100644 --- a/src/com/projectkorra/projectkorra/command/PermaremoveCommand.java +++ b/src/com/projectkorra/projectkorra/command/PermaremoveCommand.java @@ -2,8 +2,6 @@ package com.projectkorra.projectkorra.command; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.configuration.configs.commands.PermaremoveCommandConfig; -import com.projectkorra.projectkorra.event.PlayerChangeElementEvent; -import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result; import com.projectkorra.projectkorra.player.BendingPlayer; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -77,7 +75,6 @@ public class PermaremoveCommand extends PKCommand { if (!(sender instanceof Player) || !sender.getName().equalsIgnoreCase(player.getName())) { GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.removedConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.RED)); } - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.PERMAREMOVE)); } } diff --git a/src/com/projectkorra/projectkorra/command/RemoveCommand.java b/src/com/projectkorra/projectkorra/command/RemoveCommand.java index 69a130ca..29dae1f4 100644 --- a/src/com/projectkorra/projectkorra/command/RemoveCommand.java +++ b/src/com/projectkorra/projectkorra/command/RemoveCommand.java @@ -3,8 +3,6 @@ package com.projectkorra.projectkorra.command; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.configuration.configs.commands.RemoveCommandConfig; import com.projectkorra.projectkorra.element.Element; -import com.projectkorra.projectkorra.event.PlayerChangeElementEvent; -import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result; import com.projectkorra.projectkorra.player.BendingPlayer; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -70,8 +68,6 @@ public class RemoveCommand extends PKCommand { GeneralMethods.removeUnusableAbilities(player.getName()); GeneralMethods.sendBrandingMessage(sender, e.getColor() + this.succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending())); - - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE)); return; } @@ -92,8 +88,6 @@ public class RemoveCommand extends PKCommand { GeneralMethods.removeUnusableAbilities(player.getName()); GeneralMethods.sendBrandingMessage(player, e.getColor() + this.succesfullyRemovedElementTarget.replace("{element}", e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor())); GeneralMethods.sendBrandingMessage(sender, e.getColor() + this.succesfullyRemovedElementTargetConfirm.replace("{element}", e.getName() + e.getType().getBending()).replace("{target}", ChatColor.DARK_AQUA + player.getName() + e.getColor())); - - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE)); return; } @@ -106,7 +100,6 @@ public class RemoveCommand extends PKCommand { } GeneralMethods.sendBrandingMessage(player, ChatColor.YELLOW + this.succesfullyRemovedAllElementsTarget.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + ChatColor.YELLOW)); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.REMOVE)); } } diff --git a/src/com/projectkorra/projectkorra/earthbending/Catapult.java b/src/com/projectkorra/projectkorra/earthbending/Catapult.java index 875dde60..51348096 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Catapult.java +++ b/src/com/projectkorra/projectkorra/earthbending/Catapult.java @@ -13,7 +13,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.CatapultConfig; import com.projectkorra.projectkorra.util.ParticleEffect; diff --git a/src/com/projectkorra/projectkorra/earthbending/Collapse.java b/src/com/projectkorra/projectkorra/earthbending/Collapse.java index 3fdc7e81..9aa7f4ce 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Collapse.java +++ b/src/com/projectkorra/projectkorra/earthbending/Collapse.java @@ -10,7 +10,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.CollapseConfig; import com.projectkorra.projectkorra.util.BlockSource; diff --git a/src/com/projectkorra/projectkorra/earthbending/CollapseWall.java b/src/com/projectkorra/projectkorra/earthbending/CollapseWall.java index 6cba236f..0cb224cb 100644 --- a/src/com/projectkorra/projectkorra/earthbending/CollapseWall.java +++ b/src/com/projectkorra/projectkorra/earthbending/CollapseWall.java @@ -10,7 +10,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.CollapseConfig; import com.projectkorra.projectkorra.util.BlockSource; diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java b/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java index a75de53c..9aa61e85 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java @@ -19,8 +19,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java b/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java index 4f98f538..2f6e0d81 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java @@ -13,8 +13,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.EarthBlastConfig; diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthDome.java b/src/com/projectkorra/projectkorra/earthbending/EarthDome.java index c5ef37f9..eaa0c17f 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthDome.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthDome.java @@ -11,7 +11,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.EarthDomeConfig; diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java b/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java index ec092fb5..c37939b9 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java @@ -28,8 +28,8 @@ import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.EarthGrabConfig; diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java b/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java index 899a7788..6a1a038c 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java @@ -16,8 +16,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.EarthSmashConfig; diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java b/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java index e930ddc3..be5e11ec 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java @@ -10,8 +10,8 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.EarthTunnelConfig; import com.projectkorra.projectkorra.util.TempBlock; diff --git a/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java b/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java index 65910006..11263fc1 100644 --- a/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java +++ b/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java @@ -9,7 +9,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.RaiseEarthConfig; import com.projectkorra.projectkorra.util.BlockSource; diff --git a/src/com/projectkorra/projectkorra/earthbending/RaiseEarthWall.java b/src/com/projectkorra/projectkorra/earthbending/RaiseEarthWall.java index 0c30fec8..1c450f97 100644 --- a/src/com/projectkorra/projectkorra/earthbending/RaiseEarthWall.java +++ b/src/com/projectkorra/projectkorra/earthbending/RaiseEarthWall.java @@ -7,7 +7,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.RaiseEarthConfig; import com.projectkorra.projectkorra.util.BlockSource; diff --git a/src/com/projectkorra/projectkorra/earthbending/Ripple.java b/src/com/projectkorra/projectkorra/earthbending/Ripple.java index d0c8dc8a..547ebd52 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Ripple.java +++ b/src/com/projectkorra/projectkorra/earthbending/Ripple.java @@ -14,8 +14,8 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.command.Commands; diff --git a/src/com/projectkorra/projectkorra/earthbending/Shockwave.java b/src/com/projectkorra/projectkorra/earthbending/Shockwave.java index 5fbf9eac..563db8f7 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Shockwave.java +++ b/src/com/projectkorra/projectkorra/earthbending/Shockwave.java @@ -4,7 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.ShockwaveConfig; import com.projectkorra.projectkorra.util.ParticleEffect; diff --git a/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java b/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java index cd6a09ad..2fb2d75f 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java +++ b/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java @@ -13,8 +13,8 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.TremorsenseConfig; diff --git a/src/com/projectkorra/projectkorra/earthbending/combo/EarthDomeOthers.java b/src/com/projectkorra/projectkorra/earthbending/combo/EarthDomeOthers.java index ad06d70f..e282e768 100644 --- a/src/com/projectkorra/projectkorra/earthbending/combo/EarthDomeOthers.java +++ b/src/com/projectkorra/projectkorra/earthbending/combo/EarthDomeOthers.java @@ -9,7 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.EarthDomeConfig; import com.projectkorra.projectkorra.earthbending.EarthDome; diff --git a/src/com/projectkorra/projectkorra/earthbending/combo/EarthDomeSelf.java b/src/com/projectkorra/projectkorra/earthbending/combo/EarthDomeSelf.java index d3ea5d34..d3a83f06 100644 --- a/src/com/projectkorra/projectkorra/earthbending/combo/EarthDomeSelf.java +++ b/src/com/projectkorra/projectkorra/earthbending/combo/EarthDomeSelf.java @@ -6,7 +6,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.EarthDomeConfig; diff --git a/src/com/projectkorra/projectkorra/earthbending/combo/EarthPillars.java b/src/com/projectkorra/projectkorra/earthbending/combo/EarthPillars.java index e1efccbc..37bf0b14 100644 --- a/src/com/projectkorra/projectkorra/earthbending/combo/EarthPillars.java +++ b/src/com/projectkorra/projectkorra/earthbending/combo/EarthPillars.java @@ -14,7 +14,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/earthbending/lava/LavaFlow.java b/src/com/projectkorra/projectkorra/earthbending/lava/LavaFlow.java index bfc73935..19385a6b 100644 --- a/src/com/projectkorra/projectkorra/earthbending/lava/LavaFlow.java +++ b/src/com/projectkorra/projectkorra/earthbending/lava/LavaFlow.java @@ -17,8 +17,8 @@ import org.bukkit.scheduler.BukkitRunnable; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.LavaAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.LavaAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.LavaFlowConfig; import com.projectkorra.projectkorra.util.BlockSource; diff --git a/src/com/projectkorra/projectkorra/earthbending/metal/Extraction.java b/src/com/projectkorra/projectkorra/earthbending/metal/Extraction.java index 76d6c1b6..bd58c351 100644 --- a/src/com/projectkorra/projectkorra/earthbending/metal/Extraction.java +++ b/src/com/projectkorra/projectkorra/earthbending/metal/Extraction.java @@ -10,7 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.MetalAbility; +import com.projectkorra.projectkorra.ability.legacy.MetalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.ExtractionConfig; import com.projectkorra.projectkorra.util.TempBlock; diff --git a/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java b/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java index 7bbc8c1b..57a82c4f 100644 --- a/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java +++ b/src/com/projectkorra/projectkorra/earthbending/metal/MetalClips.java @@ -21,7 +21,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.MetalAbility; +import com.projectkorra.projectkorra.ability.legacy.MetalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.MetalClipsConfig; import com.projectkorra.projectkorra.util.DamageHandler; diff --git a/src/com/projectkorra/projectkorra/earthbending/passive/DensityShift.java b/src/com/projectkorra/projectkorra/earthbending/passive/DensityShift.java index 1845c135..9a3daa4a 100644 --- a/src/com/projectkorra/projectkorra/earthbending/passive/DensityShift.java +++ b/src/com/projectkorra/projectkorra/earthbending/passive/DensityShift.java @@ -11,8 +11,8 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.EarthAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/earthbending/passive/FerroControl.java b/src/com/projectkorra/projectkorra/earthbending/passive/FerroControl.java index eedc34f8..8467627d 100644 --- a/src/com/projectkorra/projectkorra/earthbending/passive/FerroControl.java +++ b/src/com/projectkorra/projectkorra/earthbending/passive/FerroControl.java @@ -11,7 +11,7 @@ import org.bukkit.block.data.type.TrapDoor; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.MetalAbility; +import com.projectkorra.projectkorra.ability.legacy.MetalAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; import com.projectkorra.projectkorra.configuration.configs.abilities.earth.FerroControlConfig; diff --git a/src/com/projectkorra/projectkorra/element/ElementManager.java b/src/com/projectkorra/projectkorra/element/ElementManager.java index 992c5bdc..b427162f 100644 --- a/src/com/projectkorra/projectkorra/element/ElementManager.java +++ b/src/com/projectkorra/projectkorra/element/ElementManager.java @@ -2,8 +2,9 @@ package com.projectkorra.projectkorra.element; import com.google.common.base.Preconditions; import com.google.common.base.Predicates; -import com.projectkorra.projectkorra.module.DatabaseModule; +import com.projectkorra.projectkorra.event.PlayerChangeElementEvent; import com.projectkorra.projectkorra.module.ModuleManager; +import com.projectkorra.projectkorra.module.PlayerDatabaseModule; import com.projectkorra.projectkorra.player.BendingPlayer; import com.projectkorra.projectkorra.player.BendingPlayerLoadedEvent; import com.projectkorra.projectkorra.player.BendingPlayerManager; @@ -16,7 +17,7 @@ import java.util.*; import java.util.regex.Pattern; import java.util.stream.Collectors; -public class ElementManager extends DatabaseModule { +public class ElementManager extends PlayerDatabaseModule, ElementRepository> { private static final String WATER = "water", EARTH = "earth", FIRE = "fire", AIR = "air", CHI = "chi", AVATAR = "avatar"; private static final String BLOOD = "blood", HEALING = "healing", ICE = "ice", PLANT = "plant"; @@ -93,7 +94,7 @@ public class ElementManager extends DatabaseModule { try { List elements = getRepository().selectPlayerElements(bendingPlayer.getId()).stream().map(this.elements::get).collect(Collectors.toList()); - elements.forEach(bendingPlayer::addElement); + elements.forEach(element -> getPlugin().getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(event.getPlayer(), element, PlayerChangeElementEvent.Reason.ADD))); } catch (SQLException e) { e.printStackTrace(); } @@ -103,9 +104,11 @@ public class ElementManager extends DatabaseModule { public boolean addElement(Player player, Element element) { BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); - if (!bendingPlayer.addElement(element)) { + if (!getData(player).add(element)) { return false; } +// PlayerChangeElementEvent playerChangeElementEvent = new PlayerChangeElementEvent(player, element, PlayerChangeElementEvent.Reason.ADD); +// getPlugin().getServer().getPluginManager().callEvent(playerChangeElementEvent); runAsync(() -> { try { @@ -121,8 +124,10 @@ public class ElementManager extends DatabaseModule { public void setElement(Player player, Element element) { BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); - bendingPlayer.clearElements(); - bendingPlayer.addElement(element); + getData(player).clear(); + getData(player).add(element); +// PlayerChangeElementEvent playerChangeElementEvent = new PlayerChangeElementEvent(player, element, PlayerChangeElementEvent.Reason.SET); +// getPlugin().getServer().getPluginManager().callEvent(playerChangeElementEvent); runAsync(() -> { try { @@ -137,9 +142,11 @@ public class ElementManager extends DatabaseModule { public boolean removeElement(Player player, Element element) { BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); - if (!bendingPlayer.removeElement(element)) { + if (!getData(player).remove(element)) { return false; } +// PlayerChangeElementEvent playerChangeElementEvent = new PlayerChangeElementEvent(player, element, PlayerChangeElementEvent.Reason.REMOVE); +// getPlugin().getServer().getPluginManager().callEvent(playerChangeElementEvent); runAsync(() -> { try { @@ -155,7 +162,9 @@ public class ElementManager extends DatabaseModule { public void clearElements(Player player) { BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); - bendingPlayer.clearElements(); + getData(player).clear(); +// PlayerChangeElementEvent playerChangeElementEvent = new PlayerChangeElementEvent(player, null, PlayerChangeElementEvent.Reason.CLEAR); +// getPlugin().getServer().getPluginManager().callEvent(playerChangeElementEvent); runAsync(() -> { try { @@ -166,6 +175,18 @@ public class ElementManager extends DatabaseModule { }); } + public Set getElements(Player player) { + return Collections.unmodifiableSet(getData(player)); + } + + public boolean hasElement(Player player, Element element) { + if (element.equals(this.avatar)) { + return player.hasPermission("bending.avatar"); + } + + return getData(player).contains(element); + } + public Element getElement(String elementName) { return this.names.get(elementName); } @@ -297,6 +318,11 @@ public class ElementManager extends DatabaseModule { return new ArrayList<>(this.elements.values()); } + @Override + protected Set addData(UUID uuid) { + return new HashSet<>(); + } + public enum ElementType { BENDING("bending", "bender", "bend"), BLOCKING("blocking", "blocker", "block"), NO_SUFFIX("", "", ""); diff --git a/src/com/projectkorra/projectkorra/event/PlayerChangeElementEvent.java b/src/com/projectkorra/projectkorra/event/PlayerChangeElementEvent.java index 34ecea3e..b28390c7 100644 --- a/src/com/projectkorra/projectkorra/event/PlayerChangeElementEvent.java +++ b/src/com/projectkorra/projectkorra/event/PlayerChangeElementEvent.java @@ -1,7 +1,6 @@ package com.projectkorra.projectkorra.event; import com.projectkorra.projectkorra.element.Element; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -11,50 +10,31 @@ import org.bukkit.event.HandlerList; */ public class PlayerChangeElementEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - private final CommandSender sender; - private final Player target; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Player player; private final Element element; - private final Result result; + private final Reason reason; /** * - * @param sender the {@link CommandSender} who changed the player's bending - * @param target the {@link Player player} who's bending was changed + * @param player the {@link Player player} who's bending was changed * @param element the {@link Element element} that was affected - * @param result whether the element was chosen, added, removed, or + * @param reason whether the element was chosen, added, removed, or * permaremoved */ - public PlayerChangeElementEvent(final CommandSender sender, final Player target, final Element element, final Result result) { - this.sender = sender; - this.target = target; + public PlayerChangeElementEvent(final Player player, final Element element, final Reason reason) { + this.player = player; this.element = element; - this.result = result; - } - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - /** - * - * @return the {@link CommandSender} who changed the player's bending - */ - public CommandSender getSender() { - return this.sender; + this.reason = reason; } /** * * @return the {@link Player player} who's bending was changed */ - public Player getTarget() { - return this.target; + public Player getPlayer() { + return this.player; } /** @@ -69,13 +49,20 @@ public class PlayerChangeElementEvent extends Event { * * @return whether the element was chosen, added, removed, or permaremoved */ - public Result getResult() { - return this.result; + public Reason getReason() { + return this.reason; } - public static enum Result { - CHOOSE, REMOVE, ADD, PERMAREMOVE; - private Result() {} + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; } + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + + public enum Reason { + ADD, SET, REMOVE, CLEAR + } } diff --git a/src/com/projectkorra/projectkorra/firebending/Blaze.java b/src/com/projectkorra/projectkorra/firebending/Blaze.java index 8e89db6f..9485301e 100644 --- a/src/com/projectkorra/projectkorra/firebending/Blaze.java +++ b/src/com/projectkorra/projectkorra/firebending/Blaze.java @@ -4,7 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.BlazeConfig; diff --git a/src/com/projectkorra/projectkorra/firebending/BlazeArc.java b/src/com/projectkorra/projectkorra/firebending/BlazeArc.java index 36034b01..ec540204 100644 --- a/src/com/projectkorra/projectkorra/firebending/BlazeArc.java +++ b/src/com/projectkorra/projectkorra/firebending/BlazeArc.java @@ -14,7 +14,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.BlazeConfig; import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; diff --git a/src/com/projectkorra/projectkorra/firebending/BlazeRing.java b/src/com/projectkorra/projectkorra/firebending/BlazeRing.java index 1e666dc6..054b1678 100644 --- a/src/com/projectkorra/projectkorra/firebending/BlazeRing.java +++ b/src/com/projectkorra/projectkorra/firebending/BlazeRing.java @@ -4,7 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.BlazeConfig; diff --git a/src/com/projectkorra/projectkorra/firebending/FireBlast.java b/src/com/projectkorra/projectkorra/firebending/FireBlast.java index ab8829b0..94b293f6 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBlast.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBlast.java @@ -16,8 +16,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; diff --git a/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java b/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java index 39dbff97..1a4c5163 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBlastCharged.java @@ -17,9 +17,9 @@ import org.bukkit.entity.TNTPrimed; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.FireBlastConfig; diff --git a/src/com/projectkorra/projectkorra/firebending/FireBurst.java b/src/com/projectkorra/projectkorra/firebending/FireBurst.java index 5b96e622..a78fe5a0 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBurst.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBurst.java @@ -12,7 +12,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.FireBlastConfig; diff --git a/src/com/projectkorra/projectkorra/firebending/FireJet.java b/src/com/projectkorra/projectkorra/firebending/FireJet.java index fbccfbe3..8621da7d 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireJet.java +++ b/src/com/projectkorra/projectkorra/firebending/FireJet.java @@ -10,8 +10,8 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.airbending.AirSpout; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.FireJetConfig; diff --git a/src/com/projectkorra/projectkorra/firebending/FireManipulation.java b/src/com/projectkorra/projectkorra/firebending/FireManipulation.java index 10e36491..67766ead 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireManipulation.java +++ b/src/com/projectkorra/projectkorra/firebending/FireManipulation.java @@ -13,7 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.FireManipulationConfig; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.ParticleEffect; diff --git a/src/com/projectkorra/projectkorra/firebending/FireShield.java b/src/com/projectkorra/projectkorra/firebending/FireShield.java index f04f58e0..bbd1db15 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireShield.java +++ b/src/com/projectkorra/projectkorra/firebending/FireShield.java @@ -13,7 +13,7 @@ import org.bukkit.entity.Projectile; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.FireShieldConfig; diff --git a/src/com/projectkorra/projectkorra/firebending/HeatControl.java b/src/com/projectkorra/projectkorra/firebending/HeatControl.java index bafa906d..4fc20dc9 100644 --- a/src/com/projectkorra/projectkorra/firebending/HeatControl.java +++ b/src/com/projectkorra/projectkorra/firebending/HeatControl.java @@ -24,7 +24,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.HeatControlConfig; diff --git a/src/com/projectkorra/projectkorra/firebending/Illumination.java b/src/com/projectkorra/projectkorra/firebending/Illumination.java index c6973d34..33409459 100644 --- a/src/com/projectkorra/projectkorra/firebending/Illumination.java +++ b/src/com/projectkorra/projectkorra/firebending/Illumination.java @@ -12,7 +12,7 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.IlluminationConfig; import com.projectkorra.projectkorra.util.TempBlock; diff --git a/src/com/projectkorra/projectkorra/firebending/WallOfFire.java b/src/com/projectkorra/projectkorra/firebending/WallOfFire.java index 4fa994ce..5ff1c02c 100644 --- a/src/com/projectkorra/projectkorra/firebending/WallOfFire.java +++ b/src/com/projectkorra/projectkorra/firebending/WallOfFire.java @@ -12,8 +12,8 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.WallOfFireConfig; import com.projectkorra.projectkorra.firebending.util.FireDamageTimer; diff --git a/src/com/projectkorra/projectkorra/firebending/combo/FireComboStream.java b/src/com/projectkorra/projectkorra/firebending/combo/FireComboStream.java index ef005028..892b6852 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/FireComboStream.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/FireComboStream.java @@ -17,7 +17,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.firebending.util.FireDamageTimer; import com.projectkorra.projectkorra.util.DamageHandler; diff --git a/src/com/projectkorra/projectkorra/firebending/combo/FireKick.java b/src/com/projectkorra/projectkorra/firebending/combo/FireKick.java index a6ff8987..e93bf5e9 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/FireKick.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/FireKick.java @@ -13,7 +13,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; diff --git a/src/com/projectkorra/projectkorra/firebending/combo/FireSpin.java b/src/com/projectkorra/projectkorra/firebending/combo/FireSpin.java index 6bf72ed9..450ea7af 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/FireSpin.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/FireSpin.java @@ -14,7 +14,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; diff --git a/src/com/projectkorra/projectkorra/firebending/combo/FireWheel.java b/src/com/projectkorra/projectkorra/firebending/combo/FireWheel.java index fe6df6dc..96165a14 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/FireWheel.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/FireWheel.java @@ -14,8 +14,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java b/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java index dda6dc4c..41aeb876 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java b/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java index 199d69b2..ac688a23 100644 --- a/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java +++ b/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java @@ -10,7 +10,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/firebending/combustion/Combustion.java b/src/com/projectkorra/projectkorra/firebending/combustion/Combustion.java index 12e44b44..efe49c70 100644 --- a/src/com/projectkorra/projectkorra/firebending/combustion/Combustion.java +++ b/src/com/projectkorra/projectkorra/firebending/combustion/Combustion.java @@ -9,9 +9,9 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.CombustionAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.CombustionAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; diff --git a/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java b/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java index 48b49e6c..1d93f426 100644 --- a/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java +++ b/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java @@ -16,7 +16,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.LightningAbility; +import com.projectkorra.projectkorra.ability.legacy.LightningAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.fire.LightningConfig; import com.projectkorra.projectkorra.util.DamageHandler; diff --git a/src/com/projectkorra/projectkorra/firebending/util/FirebendingManager.java b/src/com/projectkorra/projectkorra/firebending/util/FirebendingManager.java index 2d3a96d2..93ce248a 100644 --- a/src/com/projectkorra/projectkorra/firebending/util/FirebendingManager.java +++ b/src/com/projectkorra/projectkorra/firebending/util/FirebendingManager.java @@ -1,7 +1,7 @@ package com.projectkorra.projectkorra.firebending.util; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; import com.projectkorra.projectkorra.firebending.BlazeArc; public class FirebendingManager implements Runnable { diff --git a/src/com/projectkorra/projectkorra/module/Module.java b/src/com/projectkorra/projectkorra/module/Module.java index f68e0f0a..1dc09c93 100644 --- a/src/com/projectkorra/projectkorra/module/Module.java +++ b/src/com/projectkorra/projectkorra/module/Module.java @@ -40,15 +40,14 @@ public abstract class Module implements Listener { log("Disabling..."); HandlerList.unregisterAll(this); - onDisable(); long finishTime = System.currentTimeMillis(); log(String.format("Disabled! [%sms]", finishTime - startTime)); } - - public void onDisable() { - - } +// +// public void onDisable() { +// +// } protected final void runSync(Runnable runnable) { getPlugin().getServer().getScheduler().runTask(getPlugin(), runnable); diff --git a/src/com/projectkorra/projectkorra/module/ModuleManager.java b/src/com/projectkorra/projectkorra/module/ModuleManager.java index db60c3c2..e809def1 100644 --- a/src/com/projectkorra/projectkorra/module/ModuleManager.java +++ b/src/com/projectkorra/projectkorra/module/ModuleManager.java @@ -24,23 +24,25 @@ public class ModuleManager { * @throws NullPointerException if moduleClass is null * @throws IllegalArgumentException if moduleClass has already been registered */ - public static void registerModule(Class moduleClass) { + public static T registerModule(Class moduleClass) { Preconditions.checkNotNull(moduleClass, "moduleClass cannot be null"); Preconditions.checkArgument(!MODULES.containsKey(moduleClass), "moduleClass has already been registered"); try { - Constructor constructor = moduleClass.getDeclaredConstructor(); + Constructor constructor = moduleClass.getDeclaredConstructor(); boolean accessible = constructor.isAccessible(); constructor.setAccessible(true); - Module module = constructor.newInstance(); + T module = constructor.newInstance(); MODULES.put(moduleClass, module); module.enable(); constructor.setAccessible(accessible); + return module; } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); + return null; } } @@ -54,7 +56,10 @@ public class ModuleManager { */ public static T getModule(Class moduleClass) { Preconditions.checkNotNull(moduleClass, "moduleClass cannot be null"); - Preconditions.checkArgument(MODULES.containsKey(moduleClass), "moduleClass has not been registered"); + + if (!MODULES.containsKey(moduleClass)) { + return registerModule(moduleClass); + } return moduleClass.cast(MODULES.get(moduleClass)); } @@ -63,6 +68,9 @@ public class ModuleManager { * Register all our core {@link Module}s onEnable. */ public static void startup() { + MODULES.values().forEach(Module::disable); + MODULES.clear(); + registerModule(DatabaseManager.class); registerModule(BendingPlayerManager.class); registerModule(ElementManager.class); @@ -74,12 +82,12 @@ public class ModuleManager { /** * Disable all our core {@link Module}s onDisable. */ - public static void shutdown() { - registerModule(CooldownManager.class); - registerModule(AbilityBindManager.class); - registerModule(AbilityManager.class); - registerModule(ElementManager.class); - getModule(BendingPlayerManager.class).disable(); - getModule(DatabaseManager.class).disable(); - } +// public static void shutdown() { +// registerModule(CooldownManager.class); +// registerModule(AbilityBindManager.class); +// registerModule(AbilityManager.class); +// registerModule(ElementManager.class); +// getModule(BendingPlayerManager.class).disable(); +// getModule(DatabaseManager.class).disable(); +// } } diff --git a/src/com/projectkorra/projectkorra/module/PlayerDatabaseModule.java b/src/com/projectkorra/projectkorra/module/PlayerDatabaseModule.java new file mode 100644 index 00000000..cb8ba5c4 --- /dev/null +++ b/src/com/projectkorra/projectkorra/module/PlayerDatabaseModule.java @@ -0,0 +1,31 @@ +package com.projectkorra.projectkorra.module; + +import com.projectkorra.projectkorra.database.DatabaseRepository; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public abstract class PlayerDatabaseModule extends DatabaseModule { + + private final Map playerData = new HashMap<>(); + + protected PlayerDatabaseModule(String name, T repository) { + super(name, repository); + } + + protected Data getData(Player player) { + return getData(player.getUniqueId()); + } + + protected Data getData(UUID uuid) { + return this.playerData.computeIfAbsent(uuid, this::addData); + } + + protected void setData(Player player, Data data) { + this.playerData.put(player.getUniqueId(), data); + } + + protected abstract Data addData(UUID uuid); +} diff --git a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java index 96483995..32ea09f7 100644 --- a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java +++ b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java @@ -18,7 +18,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.Ability; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.properties.GeneralPropertiesConfig; import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent; diff --git a/src/com/projectkorra/projectkorra/player/BendingPlayer.java b/src/com/projectkorra/projectkorra/player/BendingPlayer.java index c93c6e4c..a8dca3ca 100644 --- a/src/com/projectkorra/projectkorra/player/BendingPlayer.java +++ b/src/com/projectkorra/projectkorra/player/BendingPlayer.java @@ -4,10 +4,10 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.Ability; import com.projectkorra.projectkorra.ability.AbilityManager; import com.projectkorra.projectkorra.ability.PassiveAbilityManager; -import com.projectkorra.projectkorra.ability.api.ChiAbility; +import com.projectkorra.projectkorra.ability.legacy.ChiAbility; import com.projectkorra.projectkorra.ability.bind.AbilityBindManager; import com.projectkorra.projectkorra.ability.info.AbilityInfo; -import com.projectkorra.projectkorra.ability.info.AvatarAbilityInfo; +import com.projectkorra.projectkorra.ability.api.AvatarAbilityInfo; import com.projectkorra.projectkorra.cooldown.CooldownManager; import com.projectkorra.projectkorra.element.Element; import com.projectkorra.projectkorra.element.ElementManager; @@ -15,7 +15,9 @@ import com.projectkorra.projectkorra.element.SubElement; import com.projectkorra.projectkorra.module.ModuleManager; import org.bukkit.entity.Player; -import java.util.*; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; public class BendingPlayer { @@ -32,9 +34,7 @@ public class BendingPlayer { private final String playerName; private final long firstLogin; - private final Set elements; private final Set toggledElements; - private final String[] abilities; private ChiAbility stance; private boolean bendingPermanentlyRemoved; @@ -58,37 +58,31 @@ public class BendingPlayer { this.playerName = playerName; this.firstLogin = firstLogin; - this.elements = new HashSet<>(); this.toggledElements = new HashSet<>(); - this.abilities = new String[9]; } public Set getElements() { - return new HashSet<>(this.elements); + return this.elementManager.getElements(this.player); } - public boolean addElement(Element element) { - return this.elements.add(element); + protected boolean addElement(Element element) { + return this.elementManager.addElement(this.player, element); } - public boolean removeElement(Element element) { - return this.elements.remove(element); + protected boolean removeElement(Element element) { + return this.elementManager.removeElement(this.player, element); } - public void clearElements() { - this.elements.clear(); + protected void clearElements() { + this.elementManager.clearElements(this.player); } public boolean hasElement(Element element) { - if (element.equals(this.elementManager.getAvatar())) { - return this.player.hasPermission("bending.avatar"); - } - - return this.elements.contains(element); + return this.elementManager.hasElement(this.player, element); } public boolean canBloodbend() { - return this.elements.contains(this.elementManager.getBlood()); + return this.elementManager.hasElement(this.player, this.elementManager.getBlood()); } public boolean canBloodbendAtAnytime() { @@ -96,43 +90,43 @@ public class BendingPlayer { } public boolean canUseHealing() { - return this.elements.contains(this.elementManager.getHealing()); + return this.elementManager.hasElement(this.player, this.elementManager.getHealing()); } public boolean canIcebend() { - return this.elements.contains(this.elementManager.getIce()); + return this.elementManager.hasElement(this.player, this.elementManager.getIce()); } public boolean canPlantbend() { - return this.elements.contains(this.elementManager.getPlant()); + return this.elementManager.hasElement(this.player, this.elementManager.getPlant()); } public boolean canLavabend() { - return this.elements.contains(this.elementManager.getLava()); + return this.elementManager.hasElement(this.player, this.elementManager.getLava()); } public boolean canMetalbend() { - return this.elements.contains(this.elementManager.getMetal()); + return this.elementManager.hasElement(this.player, this.elementManager.getMetal()); } public boolean canSandbend() { - return this.elements.contains(this.elementManager.getSand()); + return this.elementManager.hasElement(this.player, this.elementManager.getSand()); } public boolean canCombustionbend() { - return this.elements.contains(this.elementManager.getCombustion()); + return this.elementManager.hasElement(this.player, this.elementManager.getCombustion()); } public boolean canUseLightning() { - return this.elements.contains(this.elementManager.getLightning()); + return this.elementManager.hasElement(this.player, this.elementManager.getLightning()); } public boolean canUseFlight() { - return this.elements.contains(this.elementManager.getFlight()); + return this.elementManager.hasElement(this.player, this.elementManager.getFlight()); } public boolean canUseSpiritual() { - return this.elements.contains(this.elementManager.getSpiritual()); + return this.elementManager.hasElement(this.player, this.elementManager.getSpiritual()); } public boolean isElementToggled(Element element) { @@ -148,16 +142,15 @@ public class BendingPlayer { } public String getBoundAbility() { - int slot = this.player.getInventory().getHeldItemSlot(); - return this.abilities[slot]; + return this.abilityBindManager.getBoundAbility(this.player); } public String getAbility(int slot) { - return this.abilities[slot]; + return this.abilityBindManager.getAbility(this.player, slot); } - public List getAbilities() { - return Arrays.asList(this.abilities); + public String[] getAbilities() { + return this.abilityBindManager.getAbilities(this.player); } public boolean canBind(AbilityInfo abilityInfo) { @@ -184,14 +177,6 @@ public class BendingPlayer { return true; } - public void setAbilities(String[] abilities) { - System.arraycopy(abilities, 0, this.abilities, 0, 9); - } - - public void setAbility(int slot, String abilityName) { - this.abilities[slot] = abilityName; - } - public long getCooldown(Ability ability) { return getCooldown(ability.getName()); } diff --git a/src/com/projectkorra/projectkorra/player/BendingPlayerManager.java b/src/com/projectkorra/projectkorra/player/BendingPlayerManager.java index 674dff89..12d4e588 100644 --- a/src/com/projectkorra/projectkorra/player/BendingPlayerManager.java +++ b/src/com/projectkorra/projectkorra/player/BendingPlayerManager.java @@ -1,6 +1,7 @@ package com.projectkorra.projectkorra.player; import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.event.PlayerChangeElementEvent; import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent; import com.projectkorra.projectkorra.module.DatabaseModule; import org.bukkit.OfflinePlayer; @@ -53,20 +54,40 @@ public class BendingPlayerManager extends DatabaseModule extends HashMap { + + private final Map, V> classMap = new HashMap<>(); + + public boolean containsKey(Class classKey) { + return this.classMap.containsKey(classKey); + } + + public V get(Class classKey) { + return this.classMap.get(classKey); + } + + public V getOrDefault(Class key, V defaultValue) { + return this.classMap.getOrDefault(key, defaultValue); + } + + @Override + public V put(K key, V value) { + this.classMap.put((Class) value.getClass(), value); + return super.put(key, value); + } + + @Override + public V remove(Object key) { + V value = super.remove(key); + + if (value != null) { + this.classMap.remove(value.getClass()); + } + + return value; + } + + @Override + public boolean remove(Object key, Object value) { + this.classMap.remove(value.getClass(), value); + return super.remove(key, value); + } + + @Override + public void putAll(Map m) { + Map, V> classMap = new HashMap<>(); + + for (Entry entry : m.entrySet()) { + classMap.put((Class) entry.getValue().getClass(), entry.getValue()); + } + + this.classMap.putAll(classMap); + super.putAll(m); + } + + @Override + public void clear() { + this.classMap.clear(); + super.clear(); + } + + @Override + public void replaceAll(BiFunction function) { + throw new UnsupportedOperationException(); + } + + @Override + public V putIfAbsent(K key, V value) { + throw new UnsupportedOperationException(); + } + + @Override + public V replace(K key, V value) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean replace(K key, V oldValue, V newValue) { + throw new UnsupportedOperationException(); + } + + @Override + public V computeIfAbsent(K key, Function mappingFunction) { + throw new UnsupportedOperationException(); + } + + @Override + public V computeIfPresent(K key, BiFunction remappingFunction) { + throw new UnsupportedOperationException(); + } + + @Override + public V compute(K key, BiFunction remappingFunction) { + throw new UnsupportedOperationException(); + } + + @Override + public V merge(K key, V value, BiFunction remappingFunction) { + throw new UnsupportedOperationException(); + } +} diff --git a/src/com/projectkorra/projectkorra/util/PassiveHandler.java b/src/com/projectkorra/projectkorra/util/PassiveHandler.java index 62128790..6cddcb77 100644 --- a/src/com/projectkorra/projectkorra/util/PassiveHandler.java +++ b/src/com/projectkorra/projectkorra/util/PassiveHandler.java @@ -1,7 +1,7 @@ package com.projectkorra.projectkorra.util; +import com.projectkorra.projectkorra.ability.AbilityHandler; import com.projectkorra.projectkorra.ability.PassiveAbilityManager; -import com.projectkorra.projectkorra.ability.loader.PassiveAbilityLoader; import com.projectkorra.projectkorra.airbending.passive.AirSaturation; import com.projectkorra.projectkorra.chiblocking.passive.ChiSaturation; import com.projectkorra.projectkorra.command.Commands; @@ -49,8 +49,8 @@ public class PassiveHandler extends Module { } public void checkExhaustionPassives(final Player player) { - PassiveAbilityLoader airsat = this.passiveAbilityManager.getPassiveAbility(AirSaturation.class); - PassiveAbilityLoader chisat = this.passiveAbilityManager.getPassiveAbility(ChiSaturation.class); + AbilityHandler airsat = this.passiveAbilityManager.getHandler(AirSaturation.AirSaturationHandler.class); + AbilityHandler chisat = this.passiveAbilityManager.getHandler(ChiSaturation.ChiSaturationHandler.class); if (airsat == null && chisat == null) { return; @@ -67,13 +67,11 @@ public class PassiveHandler extends Module { return; } - com.projectkorra.projectkorra.player.BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player); - - if (!this.passiveAbilityManager.canUsePassive(player, AirSaturation.class)) { + if (!this.passiveAbilityManager.canUsePassive(player, airsat)) { air = 0; } - if (!this.passiveAbilityManager.canUsePassive(player, ChiSaturation.class)) { + if (!this.passiveAbilityManager.canUsePassive(player, chisat)) { chi = 0; } diff --git a/src/com/projectkorra/projectkorra/util/RevertChecker.java b/src/com/projectkorra/projectkorra/util/RevertChecker.java index 4d3c2ffc..abd02611 100644 --- a/src/com/projectkorra/projectkorra/util/RevertChecker.java +++ b/src/com/projectkorra/projectkorra/util/RevertChecker.java @@ -13,7 +13,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.EarthAbility; +import com.projectkorra.projectkorra.ability.legacy.EarthAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.properties.EarthPropertiesConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java b/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java index 6968f8c9..4fca3c59 100644 --- a/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java +++ b/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java @@ -15,8 +15,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java b/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java index 93535c73..253dfa67 100644 --- a/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java +++ b/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java @@ -16,8 +16,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.SurgeConfig; import com.projectkorra.projectkorra.firebending.FireBlast; diff --git a/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java b/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java index 3673e62f..7898bb5a 100644 --- a/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java @@ -16,9 +16,9 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.command.Commands; diff --git a/src/com/projectkorra/projectkorra/waterbending/Torrent.java b/src/com/projectkorra/projectkorra/waterbending/Torrent.java index 890b8d56..25b10e38 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Torrent.java +++ b/src/com/projectkorra/projectkorra/waterbending/Torrent.java @@ -18,8 +18,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.command.Commands; diff --git a/src/com/projectkorra/projectkorra/waterbending/TorrentWave.java b/src/com/projectkorra/projectkorra/waterbending/TorrentWave.java index bf1e475d..5536bfb3 100644 --- a/src/com/projectkorra/projectkorra/waterbending/TorrentWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/TorrentWave.java @@ -14,7 +14,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.configs.abilities.water.TorrentConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java b/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java index e8212b00..ede36e31 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java @@ -15,8 +15,8 @@ import org.bukkit.block.data.Waterlogged; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.WaterBubbleConfig; import com.projectkorra.projectkorra.util.TempBlock; diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java b/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java index 2ad245d7..ce8bff2f 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java @@ -16,8 +16,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java b/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java index d26f6496..0fdd2329 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java @@ -13,8 +13,8 @@ import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffectType; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.WaterSpoutConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java b/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java index cd5d445c..3118eb10 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java @@ -22,8 +22,8 @@ import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java b/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java index bdd1c181..2462d274 100644 --- a/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java +++ b/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java @@ -18,8 +18,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.BloodAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.BloodAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.configuration.configs.abilities.water.BloodbendingConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java b/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java index b388118c..89f3169f 100644 --- a/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java +++ b/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java @@ -19,8 +19,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.IceAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.IceAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; diff --git a/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java b/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java index b663f5d5..b5c48b10 100644 --- a/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java @@ -9,7 +9,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.ability.api.ComboAbility; -import com.projectkorra.projectkorra.ability.api.IceAbility; +import com.projectkorra.projectkorra.ability.legacy.IceAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java b/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java index 80861ae8..50a742a7 100644 --- a/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java +++ b/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java @@ -15,9 +15,9 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.HealingAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.HealingAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.chiblocking.Smokescreen; import com.projectkorra.projectkorra.configuration.configs.abilities.water.HealingWatersConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java index ddd25dd9..e3f6e695 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java @@ -17,8 +17,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.IceAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.IceAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.IceBlastConfig; import com.projectkorra.projectkorra.util.BlockSource; diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java index e21b9f8a..3524c6ca 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java @@ -15,8 +15,8 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.IceAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.IceAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.IceSpikeConfig; import com.projectkorra.projectkorra.util.DamageHandler; diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java index da7ca899..cad7521a 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java @@ -17,10 +17,10 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.AirAbility; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.IceAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.AirAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.IceAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.IceSpikeConfig; import com.projectkorra.projectkorra.util.DamageHandler; diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java index 2081e156..dc5870b8 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java @@ -14,9 +14,9 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.IceAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.IceAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.IceSpikeConfig; import com.projectkorra.projectkorra.util.TempBlock; diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java b/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java index 1dcaa42e..69073ede 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java @@ -16,8 +16,8 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.IceAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.IceAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.PhaseChangeConfig; import com.projectkorra.projectkorra.util.TempBlock; diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java index fa272cb7..d5fc5481 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java @@ -15,9 +15,9 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.FireAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.FireAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.ability.util.MultiAbilityManager; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.configs.abilities.water.WaterArmsConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsFreeze.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsFreeze.java index ac41a524..34a2e89b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsFreeze.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsFreeze.java @@ -12,7 +12,7 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.IceAbility; +import com.projectkorra.projectkorra.ability.legacy.IceAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.configs.abilities.water.WaterArmsConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java index 5e854b57..89bce5a5 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java @@ -16,7 +16,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.ConfigManager; diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsWhip.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsWhip.java index d4b86cbb..dd2c116b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsWhip.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsWhip.java @@ -13,7 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.ability.util.MultiAbilityManager; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; diff --git a/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java b/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java index b384aea0..7da2cfd4 100644 --- a/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java +++ b/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.water.FastSwimConfig; import com.projectkorra.projectkorra.earthbending.EarthArmor; diff --git a/src/com/projectkorra/projectkorra/waterbending/passive/HydroSink.java b/src/com/projectkorra/projectkorra/waterbending/passive/HydroSink.java index f62252f0..37ff8771 100644 --- a/src/com/projectkorra/projectkorra/waterbending/passive/HydroSink.java +++ b/src/com/projectkorra/projectkorra/waterbending/passive/HydroSink.java @@ -6,9 +6,9 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; import com.projectkorra.projectkorra.ability.api.PassiveAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.water.HydroSinkConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/plant/PlantRegrowth.java b/src/com/projectkorra/projectkorra/waterbending/plant/PlantRegrowth.java index 46cfbf01..be7462da 100644 --- a/src/com/projectkorra/projectkorra/waterbending/plant/PlantRegrowth.java +++ b/src/com/projectkorra/projectkorra/waterbending/plant/PlantRegrowth.java @@ -8,8 +8,8 @@ import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.PlantAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.PlantAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.configs.abilities.EmptyAbilityConfig; import com.projectkorra.projectkorra.configuration.configs.properties.WaterPropertiesConfig; diff --git a/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java b/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java index 4322b496..de244306 100644 --- a/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java +++ b/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java @@ -14,7 +14,7 @@ import org.bukkit.potion.PotionType; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.configuration.configs.abilities.EmptyAbilityConfig; import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.TempBlock; diff --git a/src/com/projectkorra/projectkorra/waterbending/util/WaterSourceGrabber.java b/src/com/projectkorra/projectkorra/waterbending/util/WaterSourceGrabber.java index 86b4eb60..a3b03de0 100644 --- a/src/com/projectkorra/projectkorra/waterbending/util/WaterSourceGrabber.java +++ b/src/com/projectkorra/projectkorra/waterbending/util/WaterSourceGrabber.java @@ -13,8 +13,8 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.api.ElementalAbility; -import com.projectkorra.projectkorra.ability.api.WaterAbility; +import com.projectkorra.projectkorra.ability.legacy.ElementalAbility; +import com.projectkorra.projectkorra.ability.legacy.WaterAbility; import com.projectkorra.projectkorra.util.TempBlock; @SuppressWarnings("deprecation")