mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Setup ability handler system
This commit is contained in:
parent
fc29b27808
commit
c6d56bd9ce
160 changed files with 1223 additions and 1116 deletions
|
@ -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<World, Boolean> times = new HashMap<World, Boolean>(); // 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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Element> elements = new ArrayList<>();
|
||||
final List<SubElement> 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<ItemStack> 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<AbilityInformation> 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<Element> 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<Element> 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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Info extends AbilityInfo, Config extends AbilityConfig> {
|
||||
public abstract class Ability<Handler extends AbilityHandler> {
|
||||
|
||||
private static final double DEFAULT_COLLISION_RADIUS = 0.3;
|
||||
private static final Map<Class<? extends Ability>, Map<String, Field>> ATTRIBUTE_FIELDS = new HashMap<>();
|
||||
|
@ -54,9 +53,10 @@ public abstract class Ability<Info extends AbilityInfo, Config extends AbilityCo
|
|||
|
||||
protected final BendingPlayerManager bendingPlayerManager = ModuleManager.getModule(BendingPlayerManager.class);
|
||||
protected final AbilityManager manager = ModuleManager.getModule(AbilityManager.class);
|
||||
protected final Info info = (Info) this.manager.getAbilityInfo(getClass());
|
||||
protected final Config config = ConfigManager.getConfig(((Class<Config>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]));
|
||||
// protected final Info info = (Info) this.manager.getAbilityInfo(getClass());
|
||||
// protected final Config config = ConfigManager.getConfig(((Class<Config>) ((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<Info extends AbilityInfo, Config extends AbilityCo
|
|||
* @param player the non-null player that created this instance
|
||||
* @see #start()
|
||||
*/
|
||||
public Ability(final Player player) {
|
||||
public Ability(Handler abilityHandler, Player player) {
|
||||
this();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.abilityHandler = abilityHandler;
|
||||
this.player = player;
|
||||
this.bendingPlayer = this.bendingPlayerManager.getBendingPlayer(player);
|
||||
this.flightHandler = Manager.getManager(FlightHandler.class);
|
||||
|
@ -210,11 +211,9 @@ public abstract class Ability<Info extends AbilityInfo, Config extends AbilityCo
|
|||
return this.id;
|
||||
}
|
||||
|
||||
public Info getInfo() {
|
||||
return this.info;
|
||||
public Handler getHandler() {
|
||||
return this.abilityHandler;
|
||||
}
|
||||
|
||||
public abstract Class<Config> getConfigType();
|
||||
|
||||
// public String getMovePreview(final Player player) {
|
||||
// final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
|
|
|
@ -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<T extends Ability, U extends AbilityConfig> implements Listener {
|
||||
|
||||
private final Class<T> abilityClass;
|
||||
private final Class<U> configClass;
|
||||
|
||||
public AbilityHandler(Class<T> abilityClass, Class<U> configClass) {
|
||||
this.abilityClass = abilityClass;
|
||||
this.configClass = configClass;
|
||||
}
|
||||
|
||||
public T newInstance(Player player) {
|
||||
try {
|
||||
Constructor<T> constructor = abilityClass.getDeclaredConstructor(Player.class);
|
||||
|
||||
return constructor.newInstance(player);
|
||||
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new AbilityException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Class<T> getAbility() {
|
||||
return this.abilityClass;
|
||||
}
|
||||
|
||||
public U getConfig() {
|
||||
return ConfigManager.getConfig(this.configClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the ability is used for commands such as <b>/bending
|
||||
* display</b> and <b>/bending help</b>. 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;
|
||||
}
|
||||
}
|
|
@ -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<String, AbilityInfo> abilityInfoByName = new HashMap<>();
|
||||
private final Map<Class<? extends Ability>, AbilityInfo> abilityInfoByClass = new HashMap<>();
|
||||
private final MultiKeyMap<String, AbilityHandler> handlerMap = new MultiKeyMap<>();
|
||||
|
||||
private final Set<Ability> playerAbilitySet = new HashSet<>();
|
||||
private final Map<UUID, Map<Class<? extends Ability>, LinkedList<Ability>>> playerAbilityMap = new HashMap<>();
|
||||
private final Set<Ability> abilities = new HashSet<>();
|
||||
private final Map<UUID, Map<Class<? extends Ability>, LinkedList<Ability>>> abilityMap = new HashMap<>();
|
||||
|
||||
private final MCTiming timing = ProjectKorra.timing("AbilityManager");
|
||||
private final Set<String> 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<Ability> abilityRegistry = new AbilityRegistry<>(getPlugin(), packageBase);
|
||||
List<Class<Ability>> 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<Ability> abilityRegistry = new AbilityRegistry<>(plugin, packageBase);
|
||||
// List<Class<Ability>> loadedAbilities = abilityRegistry.load(Ability.class, Ability.class);
|
||||
//
|
||||
// String entry = getPlugin().getName() + "::" + packageBase;
|
||||
// this.addonPlugins.add(entry);
|
||||
//
|
||||
// for (Class<Ability> 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<Ability> abilityRegistery = new AddonAbilityRegistry<>(getPlugin(), file);
|
||||
// List<Class<Ability>> loadedAbilities = abilityRegistery.load(Ability.class, Ability.class);
|
||||
//
|
||||
// for (Class<Ability> 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<Ability> 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 <T extends AbilityHandler> void registerAbility(T abilityHandler) throws AbilityException {
|
||||
if (abilityHandler == null) {
|
||||
throw new AbilityException("abilityHandler is null");
|
||||
}
|
||||
|
||||
AddonAbilityRegistry<Ability> abilityRegistery = new AddonAbilityRegistry<>(getPlugin(), file);
|
||||
List<Class<Ability>> loadedAbilities = abilityRegistery.load(Ability.class, Ability.class);
|
||||
|
||||
for (Class<Ability> abilityClass : loadedAbilities) {
|
||||
AbilityInfo abilityInfo = getAbilityInfo(abilityClass);
|
||||
|
||||
if (!(abilityInfo instanceof AddonAbilityInfo)) {
|
||||
throw new AbilityException(abilityClass.getName() + " must have an AddonAbilityInfo");
|
||||
}
|
||||
|
||||
registerAbility(abilityClass, abilityInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends Ability> void registerAbility(Class<T> 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<? extends Ability> abilityClass) throws AbilityException {
|
||||
|
@ -223,23 +224,13 @@ public class AbilityManager extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
public <T extends Ability> T createAbility(Player player, Class<T> abilityClass) throws AbilityException {
|
||||
try {
|
||||
Constructor<T> 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 <T extends Ability> boolean hasAbility(Player player, Class<T> ability) {
|
||||
Map<Class<? extends Ability>, LinkedList<Ability>> abilities = this.playerAbilityMap.get(player.getUniqueId());
|
||||
Map<Class<? extends Ability>, LinkedList<Ability>> 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 extends Ability> T getAbility(Player player, Class<T> ability) {
|
||||
Map<Class<? extends Ability>, LinkedList<Ability>> abilities = this.playerAbilityMap.get(player.getUniqueId());
|
||||
Map<Class<? extends Ability>, LinkedList<Ability>> abilities = this.abilityMap.get(player.getUniqueId());
|
||||
|
||||
if (abilities == null || !abilities.containsKey(ability)) {
|
||||
return null;
|
||||
|
@ -292,7 +283,7 @@ public class AbilityManager extends Module {
|
|||
}
|
||||
|
||||
public <T extends Ability> Collection<T> getAbilities(Player player, Class<T> ability) {
|
||||
Map<Class<? extends Ability>, LinkedList<Ability>> abilities = this.playerAbilityMap.get(player.getUniqueId());
|
||||
Map<Class<? extends Ability>, LinkedList<Ability>> 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<? extends Ability> abilityClass) {
|
||||
return this.abilityInfoByClass.get(abilityClass);
|
||||
public AbilityHandler getHandler(Class<? extends AbilityHandler> handlerClass) {
|
||||
return this.handlerMap.get(handlerClass);
|
||||
}
|
||||
|
||||
public List<AbilityInfo> getAbilityInfo() {
|
||||
return new ArrayList<>(this.abilityInfoByName.values());
|
||||
public List<AbilityHandler> getHandlers() {
|
||||
return new ArrayList<>(this.handlerMap.values());
|
||||
}
|
||||
|
||||
public <T extends Ability> LinkedList<T> getAbilities(Class<T> abilityClass) {
|
||||
LinkedList<T> 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<Ability> getAbilities() {
|
||||
return new ArrayList<>(this.playerAbilitySet);
|
||||
return new ArrayList<>(this.abilities);
|
||||
}
|
||||
|
||||
public List<AbilityInfo> getAbilities(Element element) {
|
||||
return this.abilityInfoByName.values().stream()
|
||||
public List<AbilityHandler> 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<String> getAddonPlugins() {
|
||||
return this.addonPlugins;
|
||||
public List<String> getAddonPlugins() {
|
||||
return new ArrayList<>(this.addonPlugins);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, ComboAbilityInfo> abilities = new HashMap<>();
|
||||
private final List<ComboAbility> comboAbilities = new ArrayList<>();
|
||||
private final MultiKeyMap<String, AbilityHandler> handlerMap = new MultiKeyMap<>();
|
||||
|
||||
private final List<ComboAbilityInfo> comboAbilities = new ArrayList<>();
|
||||
|
||||
private final Map<UUID, LinkedList<Combination>> 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<? extends Ability> 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<Combination> recentlyUsed) {
|
||||
for (ComboAbility comboAbility : this.comboAbilities) {
|
||||
int comboSize = comboAbility.combinations.size();
|
||||
private ComboAbilityInfo getAbility(LinkedList<Combination> 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<ComboAbilityInfo> getAbilities(Element element) {
|
||||
return this.abilities.values().stream()
|
||||
public AbilityHandler getHandler(Class<? extends AbilityHandler> handlerClass) {
|
||||
return this.handlerMap.get(handlerClass);
|
||||
}
|
||||
|
||||
public List<AbilityHandler> 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<? extends Ability> abilityClass;
|
||||
private final String abilityName;
|
||||
private final List<Combination> combinations;
|
||||
private class ComboAbilityInfo {
|
||||
private final AbilityHandler abilityHandler;
|
||||
private final List<Combination> combinationList;
|
||||
|
||||
ComboAbility(Class<? extends Ability> abilityClass, String abilityName, List<Combination> combinations) {
|
||||
this.abilityClass = abilityClass;
|
||||
this.abilityName = abilityName;
|
||||
this.combinations = combinations;
|
||||
ComboAbilityInfo(AbilityHandler abilityHandler, List<Combination> combinationList) {
|
||||
this.abilityHandler = abilityHandler;
|
||||
this.combinationList = combinationList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, MultiAbility> abilities = new HashMap<>();
|
||||
private final Map<String, Class<? extends Ability>> multiAbilities = new HashMap<>();
|
||||
// private final Map<String, MultiAbility> abilities = new HashMap<>();
|
||||
// private final Map<String, Class<? extends Ability>> multiAbilities = new HashMap<>();
|
||||
|
||||
private final Map<String, MultiAbilityInfo> multiAbilityMap = new HashMap<>();
|
||||
private final Map<String, AbilityHandler> handlerMap = new HashMap<>();
|
||||
|
||||
private final Map<UUID, Class<? extends Ability>> playerMultiAbility = new HashMap<>();
|
||||
private final Map<UUID, List<String>> playerAbilities = new HashMap<>();
|
||||
private final Map<UUID, String[]> 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<? extends Ability> abilityClass, MultiAbilityInfo multiAbilityInfo) {
|
||||
List<Class<? extends Ability>> abilities = multiAbilityInfo.getAbilities();
|
||||
public void registerAbility(AbilityHandler abilityHandler) {
|
||||
MultiAbility multiAbility = (MultiAbility) abilityHandler;
|
||||
|
||||
Map<String, Class<? extends Ability>> abilitiesByName = new HashMap<>();
|
||||
Map<String, AbilityHandler> handlerMap = multiAbility.getAbilities().stream().collect(Collectors.toMap(AbilityHandler::getName, h -> h));
|
||||
|
||||
for (Class<? extends Ability> 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<? extends Ability> 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<? extends Ability> multiAbility = this.playerMultiAbility.get(player.getUniqueId());
|
||||
|
||||
|
@ -105,9 +115,9 @@ public class MultiAbilityManager extends Module {
|
|||
}
|
||||
|
||||
this.playerMultiAbility.remove(player.getUniqueId());
|
||||
List<String> 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<? extends Ability> abilityClass;
|
||||
private final String abilityName;
|
||||
private final Set<String> abilities;
|
||||
public class MultiAbilityInfo {
|
||||
private final AbilityHandler abilityHandler;
|
||||
private final List<String> abilities;
|
||||
|
||||
MultiAbility(Class<? extends Ability> abilityClass, String abilityName, Set<String> abilities) {
|
||||
this.abilityClass = abilityClass;
|
||||
this.abilityName = abilityName;
|
||||
MultiAbilityInfo(AbilityHandler abilityHandler, List<String> abilities) {
|
||||
this.abilityHandler = abilityHandler;
|
||||
this.abilities = abilities;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Class<? extends Ability>, PassiveAbilityInfo> abilities = new HashMap<>();
|
||||
private final MultiKeyMap<String, AbilityHandler> 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<? extends Ability> 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<? extends Ability> 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<? extends Ability> abilityClass) {
|
||||
return this.abilities.get(abilityClass);
|
||||
public AbilityHandler getHandler(String abbilityName) {
|
||||
return this.handlerMap.get(abbilityName);
|
||||
}
|
||||
|
||||
public List<PassiveAbilityInfo> getPassives(Element element) {
|
||||
List<PassiveAbilityInfo> abilities = new ArrayList<>();
|
||||
public AbilityHandler getHandler(Class<? extends AbilityHandler> handlerClass) {
|
||||
return this.handlerMap.get(handlerClass);
|
||||
}
|
||||
|
||||
this.abilities.values().forEach(passiveAbilityInfo -> {
|
||||
public List<AbilityHandler> getPassives(Element element) {
|
||||
List<AbilityHandler> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -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<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||
|
||||
public ChiAbility(final Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgniteAbility() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExplosiveAbility() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -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.
|
|
@ -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<Class<? extends Ability>> getAbilities();
|
||||
List<AbilityHandler> getAbilities();
|
||||
}
|
|
@ -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,
|
|
@ -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<AbilityBindRepository> {
|
||||
public class AbilityBindManager extends PlayerDatabaseModule<String[], AbilityBindRepository> {
|
||||
|
||||
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<AbilityBindRepository> {
|
|||
|
||||
@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<AbilityBindRepository> {
|
|||
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<AbilityBindRepository> {
|
|||
return Result.CANCELLED;
|
||||
}
|
||||
|
||||
bendingPlayer.setAbility(slot, null);
|
||||
getData(player)[slot] = null;
|
||||
|
||||
runAsync(() -> {
|
||||
try {
|
||||
|
@ -101,7 +130,7 @@ public class AbilityBindManager extends DatabaseModule<AbilityBindRepository> {
|
|||
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<AbilityBindRepository> {
|
|||
return Result.CANCELLED;
|
||||
}
|
||||
|
||||
bendingPlayer.setAbilities(new String[9]);
|
||||
Arrays.fill(getData(player), null);
|
||||
|
||||
runAsync(() -> {
|
||||
try {
|
||||
|
@ -124,6 +153,69 @@ public class AbilityBindManager extends DatabaseModule<AbilityBindRepository> {
|
|||
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
|
||||
}
|
||||
|
|
|
@ -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 <b>/bending
|
||||
* display</b> and <b>/bending help</b>. 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;
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
package com.projectkorra.projectkorra.ability.info;
|
||||
|
||||
public interface AvatarAbilityInfo extends AbilityInfo {
|
||||
|
||||
boolean requireAvatar();
|
||||
}
|
|
@ -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<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AirAbility<C extends AbilityConfig> extends ElementalAbility<C> {
|
||||
|
||||
public AirAbility(final Player player) {
|
||||
super(player);
|
|
@ -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<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
|
@ -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<Handler extends AbilityHandler> extends ElementalAbility<Handler> {
|
||||
|
||||
public ChiAbility(final Handler abilityHandler, final Player player) {
|
||||
super(abilityHandler, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgniteAbility() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExplosiveAbility() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -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;
|
|
@ -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;
|
|
@ -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<Info extends AbilityInfo, C extends AbilityConfig> extends Ability<Info, C> {
|
||||
public abstract class ElementalAbility<Handler extends AbilityHandler> extends Ability<Handler> {
|
||||
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<Info extends AbilityInfo, C extends Abili
|
|||
}
|
||||
}
|
||||
|
||||
public ElementalAbility(Player player) {
|
||||
super(player);
|
||||
public ElementalAbility(Handler abilityHandler, Player player) {
|
||||
super(abilityHandler, player);
|
||||
}
|
||||
|
||||
public boolean isTransparent(final Block block) {
|
|
@ -1,4 +1,4 @@
|
|||
package com.projectkorra.projectkorra.ability.api;
|
||||
package com.projectkorra.projectkorra.ability.legacy;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -1,4 +1,4 @@
|
|||
package com.projectkorra.projectkorra.ability.api;
|
||||
package com.projectkorra.projectkorra.ability.legacy;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.Ability;
|
||||
|
|
@ -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;
|
|
@ -3,7 +3,7 @@ package com.projectkorra.projectkorra.ability.util;
|
|||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.Ability;
|
||||
import com.projectkorra.projectkorra.ability.AbilityManager;
|
||||
import com.projectkorra.projectkorra.ability.info.PassiveAbilityInfo;
|
||||
import com.projectkorra.projectkorra.ability.api.PassiveAbilityInfo;
|
||||
import com.projectkorra.projectkorra.event.AbilityCollisionEvent;
|
||||
import com.projectkorra.projectkorra.module.ModuleManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
|
|
@ -28,7 +28,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.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.api.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.configuration.configs.abilities.air.AirBlastConfig;
|
||||
|
|
|
@ -15,8 +15,8 @@ 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.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.ElementalAbility;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.configuration.configs.abilities.air.AirScooterConfig;
|
||||
|
||||
|
|
|
@ -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.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.avatar.AvatarState;
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.bukkit.block.BlockFace;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.api.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.ElementalAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.ElementalAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.configuration.configs.abilities.air.AirSpoutConfig;
|
||||
|
|
|
@ -18,7 +18,7 @@ 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.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
|
|
|
@ -18,9 +18,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.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.ElementalAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.ElementalAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.api.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.configuration.configs.abilities.air.SuffocateConfig;
|
||||
import com.projectkorra.projectkorra.util.DamageHandler;
|
||||
|
|
|
@ -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.ElementalAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
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.air.TornadoConfig;
|
||||
|
|
|
@ -10,7 +10,7 @@ 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.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.ComboAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
|
|
|
@ -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.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.ComboAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
|
||||
|
|
|
@ -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.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.ComboAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
|
|
|
@ -20,7 +20,7 @@ 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.FlightAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.FlightAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.MultiAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager;
|
||||
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager.MultiAbilityInfoSub;
|
||||
|
|
|
@ -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.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.api.PassiveAbility;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.configuration.configs.abilities.air.AirAgilityConfig;
|
||||
|
|
|
@ -1,13 +1,36 @@
|
|||
package com.projectkorra.projectkorra.airbending.passive;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.api.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.AbilityHandler;
|
||||
import com.projectkorra.projectkorra.ability.api.PassiveAbility;
|
||||
import com.projectkorra.projectkorra.ability.legacy.AirAbility;
|
||||
import com.projectkorra.projectkorra.airbending.util.AirPassiveAbilityInfo;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.configuration.configs.abilities.air.AirSaturationConfig;
|
||||
import com.projectkorra.projectkorra.element.Element;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AirSaturation extends AirAbility<AirSaturationInfo, AirSaturationConfig> {
|
||||
public class AirSaturation extends AirAbility<AirSaturationConfig> {
|
||||
@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<AirSaturationInfo, AirSaturationCo
|
|||
@Override
|
||||
public void progress() {}
|
||||
|
||||
@Override
|
||||
public boolean isSneakAbility() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHarmlessAbility() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCooldown() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "AirSaturation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return this.player.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<AirSaturationConfig> 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<AirSaturation, AirSaturationConfig> implements PassiveAbility {
|
||||
|
||||
public AirSaturationHandler(Class<AirSaturation> abilityClass, Class<AirSaturationConfig> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<ChiSaturationConfig> implements PassiveAbility {
|
||||
public ChiSaturation(final ChiSaturationConfig config, final Player player) {
|
||||
super(config, player);
|
||||
public class ChiSaturation extends ChiAbility<ChiSaturation.ChiSaturationHandler> 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<ChiSaturationConfig> implements Pa
|
|||
public boolean isProgressable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ChiSaturationConfig> getConfigType() {
|
||||
return ChiSaturationConfig.class;
|
||||
|
||||
public static class ChiSaturationHandler extends AbilityHandler<ChiSaturation, ChiSaturationConfig> implements PassiveAbility {
|
||||
|
||||
public ChiSaturationHandler(Class<ChiSaturation> abilityClass, Class<ChiSaturationConfig> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<AddCommandConfig> {
|
|||
}
|
||||
|
||||
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<AddCommandConfig> {
|
|||
|
||||
this.elementManager.addElement(target, elem);
|
||||
added.add(elem);
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, elem, Result.ADD));
|
||||
}
|
||||
|
||||
if (added.isEmpty()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ClearCommand extends PKCommand<ClearCommandConfig> {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<DisplayCommandConfig> {
|
|||
/**
|
||||
* 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);
|
||||
|
|
|
@ -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.*;
|
||||
|
|
|
@ -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<PermaremoveCommandConfig> {
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<RemoveCommandConfig> {
|
|||
|
||||
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<RemoveCommandConfig> {
|
|||
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<RemoveCommandConfig> {
|
|||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue