mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Updated ability util classes
This commit is contained in:
parent
d44077f99b
commit
9c15e20924
29 changed files with 198 additions and 380 deletions
|
@ -52,6 +52,7 @@ public abstract class Ability<Info extends AbilityInfo, Config extends AbilityCo
|
||||||
private static int idCounter;
|
private static int idCounter;
|
||||||
|
|
||||||
protected final AbilityManager manager = ModuleManager.getModule(AbilityManager.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 Config config = ConfigManager.getConfig(((Class<Config>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]));
|
||||||
|
|
||||||
protected Player player;
|
protected Player player;
|
||||||
|
@ -101,7 +102,7 @@ public abstract class Ability<Info extends AbilityInfo, Config extends AbilityCo
|
||||||
* @param player the non-null player that created this instance
|
* @param player the non-null player that created this instance
|
||||||
* @see #start()
|
* @see #start()
|
||||||
*/
|
*/
|
||||||
public Ability(final Config config, final Player player) {
|
public Ability(final Player player) {
|
||||||
this();
|
this();
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
@ -206,6 +207,10 @@ public abstract class Ability<Info extends AbilityInfo, Config extends AbilityCo
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Info getInfo() {
|
||||||
|
return this.info;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract Class<Config> getConfigType();
|
public abstract Class<Config> getConfigType();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.projectkorra.projectkorra.ability;
|
||||||
|
|
||||||
import co.aikar.timings.lib.MCTiming;
|
import co.aikar.timings.lib.MCTiming;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.api.PassiveAbility;
|
|
||||||
import com.projectkorra.projectkorra.ability.info.*;
|
import com.projectkorra.projectkorra.ability.info.*;
|
||||||
import com.projectkorra.projectkorra.ability.util.AbilityRegistry;
|
import com.projectkorra.projectkorra.ability.util.AbilityRegistry;
|
||||||
import com.projectkorra.projectkorra.ability.util.AddonAbilityRegistry;
|
import com.projectkorra.projectkorra.ability.util.AddonAbilityRegistry;
|
||||||
|
@ -32,6 +31,7 @@ public class AbilityManager extends Module {
|
||||||
private final PassiveAbilityManager passiveAbilityManager;
|
private final PassiveAbilityManager passiveAbilityManager;
|
||||||
|
|
||||||
private final Map<String, AbilityInfo> abilities = new HashMap<>();
|
private final Map<String, AbilityInfo> abilities = new HashMap<>();
|
||||||
|
private final Map<Class<? extends Ability>, AbilityInfo> abilityInfoMap = new HashMap<>();
|
||||||
|
|
||||||
private final Set<Ability> playerAbilitySet = new HashSet<>();
|
private final Set<Ability> playerAbilitySet = new HashSet<>();
|
||||||
private final Map<UUID, Map<Class<? extends Ability>, LinkedList<Ability>>> playerAbilityMap = new HashMap<>();
|
private final Map<UUID, Map<Class<? extends Ability>, LinkedList<Ability>>> playerAbilityMap = new HashMap<>();
|
||||||
|
@ -47,8 +47,8 @@ public class AbilityManager extends Module {
|
||||||
|
|
||||||
runTimer(() -> {
|
runTimer(() -> {
|
||||||
for (Ability ability : playerAbilitySet) {
|
for (Ability ability : playerAbilitySet) {
|
||||||
if (ability instanceof PassiveAbility) {
|
if (ability.getInfo() instanceof PassiveAbilityInfo) {
|
||||||
if (!((PassiveAbility) ability).isProgressable()) {
|
if (!((PassiveAbilityInfo) ability).isProgressable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public class AbilityManager extends Module {
|
||||||
* @param plugin a JavaPlugin containing Ability class files
|
* @param plugin a JavaPlugin containing Ability class files
|
||||||
* @param packageBase a prefix of the package name, used to increase
|
* @param packageBase a prefix of the package name, used to increase
|
||||||
* performance
|
* performance
|
||||||
* @see #getAbilities()
|
* @see #getAllAbilityInfo()
|
||||||
* @see #getAbility(String)
|
* @see #getAbility(String)
|
||||||
*/
|
*/
|
||||||
public void registerPluginAbilities(String packageBase) {
|
public void registerPluginAbilities(String packageBase) {
|
||||||
|
@ -141,7 +141,7 @@ public class AbilityManager extends Module {
|
||||||
* all of the Ability class files that were found.
|
* all of the Ability class files that were found.
|
||||||
*
|
*
|
||||||
* @param folder the name of the folder to scan
|
* @param folder the name of the folder to scan
|
||||||
* @see #getAbilities()
|
* @see #getAllAbilityInfo()
|
||||||
* @see #getAbility(String)
|
* @see #getAbility(String)
|
||||||
*/
|
*/
|
||||||
public void registerAddonAbilities(String folder) {
|
public void registerAddonAbilities(String folder) {
|
||||||
|
@ -214,14 +214,6 @@ public class AbilityManager extends Module {
|
||||||
this.abilities.put(abilityInfo.getName(), abilityInfo);
|
this.abilities.put(abilityInfo.getName(), abilityInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbilityInfo getAbilityInfo(Class<? extends Ability> abilityClass) throws AbilityException {
|
|
||||||
try {
|
|
||||||
return ((Class<? extends AbilityInfo>) ((ParameterizedType) abilityClass.getGenericSuperclass()).getActualTypeArguments()[0]).newInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new AbilityException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private AbilityConfig getAbilityConfig(Class<? extends Ability> abilityClass) throws AbilityException {
|
private AbilityConfig getAbilityConfig(Class<? extends Ability> abilityClass) throws AbilityException {
|
||||||
try {
|
try {
|
||||||
return ConfigManager.getConfig(((Class<? extends AbilityConfig>) ((ParameterizedType) abilityClass.getGenericSuperclass()).getActualTypeArguments()[1]));
|
return ConfigManager.getConfig(((Class<? extends AbilityConfig>) ((ParameterizedType) abilityClass.getGenericSuperclass()).getActualTypeArguments()[1]));
|
||||||
|
@ -308,6 +300,26 @@ public class AbilityManager extends Module {
|
||||||
return abilities.get(abilities).stream().map(ability::cast).collect(Collectors.toList());
|
return abilities.get(abilities).stream().map(ability::cast).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbilityInfo getAbilityInfo(String abilityName) {
|
||||||
|
return this.abilities.get(abilityName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbilityInfo getAbilityInfo(Class<? extends Ability> abilityClass) {
|
||||||
|
return this.abilityInfoMap.computeIfAbsent(abilityClass, k ->
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return ((Class<? extends AbilityInfo>) ((ParameterizedType) abilityClass.getGenericSuperclass()).getActualTypeArguments()[0]).newInstance();
|
||||||
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AbilityInfo> getAbilityInfo() {
|
||||||
|
return new ArrayList<>(this.abilities.values());
|
||||||
|
}
|
||||||
|
|
||||||
public <T extends Ability> LinkedList<T> getAbilities(Class<T> abilityClass) {
|
public <T extends Ability> LinkedList<T> getAbilities(Class<T> abilityClass) {
|
||||||
LinkedList<T> abilities = new LinkedList<>();
|
LinkedList<T> abilities = new LinkedList<>();
|
||||||
|
|
||||||
|
@ -318,12 +330,8 @@ public class AbilityManager extends Module {
|
||||||
return abilities;
|
return abilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbilityInfo getAbilityInfo(String abilityName) {
|
public List<Ability> getAbilities() {
|
||||||
return this.abilities.get(abilityName);
|
return new ArrayList<>(this.playerAbilitySet);
|
||||||
}
|
|
||||||
|
|
||||||
public List<AbilityInfo> getAbilities() {
|
|
||||||
return new ArrayList<>(this.abilities.values());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AbilityInfo> getAbilities(Element element) {
|
public List<AbilityInfo> getAbilities(Element element) {
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
|
||||||
|
|
||||||
public interface AddonAbility {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the ability is loaded by PK. This is where the developer
|
|
||||||
* registers Listeners and Permissions.
|
|
||||||
*/
|
|
||||||
public void load();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called whenever ProjectKorra stops and the ability is unloaded. This
|
|
||||||
* method is useful for cleaning up leftover objects such as frozen blocks.
|
|
||||||
* Any CoreAbility instances do not need to be cleaned up by stop method, as
|
|
||||||
* they will be cleaned up by {@link CoreAbility#removeAll()}.
|
|
||||||
*/
|
|
||||||
public void stop();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name of the author of this AddonAbility
|
|
||||||
*/
|
|
||||||
public String getAuthor();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The version of the ability as a String.
|
|
||||||
*/
|
|
||||||
public String getVersion();
|
|
||||||
}
|
|
|
@ -20,8 +20,8 @@ import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||||
|
|
||||||
public abstract class AirAbility<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
public abstract class AirAbility<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||||
|
|
||||||
public AirAbility(final C config, final Player player) {
|
public AirAbility(final Player player) {
|
||||||
super(config, player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.avatar.AvatarStateConfig;
|
import com.projectkorra.projectkorra.configuration.configs.abilities.avatar.AvatarStateConfig;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public abstract class AvatarAbility<C extends AbilityConfig> extends ElementalAbility<C> {
|
public abstract class AvatarAbility<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||||
|
|
||||||
public AvatarAbility(final C config, final Player player) {
|
public AvatarAbility(final Player player) {
|
||||||
super(config, player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,25 +23,10 @@ public abstract class AvatarAbility<C extends AbilityConfig> extends ElementalAb
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Element getElement() {
|
|
||||||
return Element.AVATAR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playAvatarSound(final Location loc) {
|
public static void playAvatarSound(final Location loc) {
|
||||||
AvatarStateConfig avatar = ConfigManager.getConfig(AvatarStateConfig.class);
|
AvatarStateConfig avatar = ConfigManager.getConfig(AvatarStateConfig.class);
|
||||||
if (avatar.PlaySound) {
|
if (avatar.PlaySound) {
|
||||||
loc.getWorld().playSound(loc, avatar.SoundType, avatar.SoundVolume, avatar.SoundPitch);
|
loc.getWorld().playSound(loc, avatar.SoundType, avatar.SoundVolume, avatar.SoundPitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the ability requires the user to be an avatar in order
|
|
||||||
* to be able to use it. Set this to <tt>false</tt> for moves that should be
|
|
||||||
* able to be used without players needing to have the avatar element
|
|
||||||
*/
|
|
||||||
public boolean requireAvatar() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
import com.projectkorra.projectkorra.Element;
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
|
|
||||||
public abstract class BloodAbility<C extends AbilityConfig> extends WaterAbility<C> implements SubAbility {
|
public abstract class BloodAbility<Info extends AbilityInfo, C extends AbilityConfig> extends WaterAbility<Info, C> implements SubAbility {
|
||||||
|
|
||||||
public BloodAbility(final C config, final Player player) {
|
public BloodAbility(final Player player) {
|
||||||
super(config, player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
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;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class ChiAbility<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class ChiAbility<C extends AbilityConfig> extends ElementalAbility<C> {
|
public ChiAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public ChiAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,10 +19,4 @@ public abstract class ChiAbility<C extends AbilityConfig> extends ElementalAbili
|
||||||
public boolean isExplosiveAbility() {
|
public boolean isExplosiveAbility() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.CHI;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
|
|
||||||
|
|
||||||
public interface ComboAbility {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance of this combo type with default config
|
|
||||||
*/
|
|
||||||
public abstract Object createNewComboInstance(Player player);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the list of abilities which constitute the combo.
|
|
||||||
*
|
|
||||||
* @return An ArrayList containing the combo's steps.
|
|
||||||
*/
|
|
||||||
public abstract ArrayList<AbilityInformation> getCombination();
|
|
||||||
}
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class CombustionAbility<Info extends AbilityInfo, C extends AbilityConfig> extends FireAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class CombustionAbility<C extends AbilityConfig> extends FireAbility<C> implements SubAbility {
|
public CombustionAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public CombustionAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return FireAbility.class;
|
return FireAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.COMBUSTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import java.util.HashSet;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import java.util.Map;
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||||
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.properties.EarthPropertiesConfig;
|
||||||
|
import com.projectkorra.projectkorra.earthbending.RaiseEarth;
|
||||||
|
import com.projectkorra.projectkorra.earthbending.lava.LavaFlow;
|
||||||
|
import com.projectkorra.projectkorra.earthbending.passive.DensityShift;
|
||||||
|
import com.projectkorra.projectkorra.util.BlockSource;
|
||||||
|
import com.projectkorra.projectkorra.util.Information;
|
||||||
|
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||||
|
import com.projectkorra.projectkorra.util.TempBlock;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -17,30 +26,20 @@ import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import java.util.ArrayList;
|
||||||
import com.projectkorra.projectkorra.Element;
|
import java.util.HashSet;
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import java.util.Map;
|
||||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
import com.projectkorra.projectkorra.configuration.configs.properties.EarthPropertiesConfig;
|
|
||||||
import com.projectkorra.projectkorra.earthbending.RaiseEarth;
|
|
||||||
import com.projectkorra.projectkorra.earthbending.lava.LavaFlow;
|
|
||||||
import com.projectkorra.projectkorra.earthbending.passive.DensityShift;
|
|
||||||
import com.projectkorra.projectkorra.util.BlockSource;
|
|
||||||
import com.projectkorra.projectkorra.util.Information;
|
|
||||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
|
||||||
import com.projectkorra.projectkorra.util.TempBlock;
|
|
||||||
|
|
||||||
public abstract class EarthAbility<C extends AbilityConfig> extends ElementalAbility<C> {
|
public abstract class EarthAbility<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||||
|
|
||||||
private static final HashSet<Block> PREVENT_EARTHBENDING = new HashSet<Block>();
|
private static final HashSet<Block> PREVENT_EARTHBENDING = new HashSet<Block>();
|
||||||
private static final Map<Block, Information> MOVED_EARTH = new ConcurrentHashMap<Block, Information>();
|
private static final Map<Block, Information> MOVED_EARTH = new ConcurrentHashMap<Block, Information>();
|
||||||
private static final Map<Integer, Information> TEMP_AIR_LOCATIONS = new ConcurrentHashMap<Integer, Information>();
|
private static final Map<Integer, Information> TEMP_AIR_LOCATIONS = new ConcurrentHashMap<Integer, Information>();
|
||||||
private static final ArrayList<Block> PREVENT_PHYSICS = new ArrayList<Block>();
|
private static final ArrayList<Block> PREVENT_PHYSICS = new ArrayList<Block>();
|
||||||
|
|
||||||
public EarthAbility(final C config, final Player player) {
|
public EarthAbility(final Player player) {
|
||||||
super(config, player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEarthbendableBlocksLength(final Block block, Vector direction, final int maxlength) {
|
public int getEarthbendableBlocksLength(final Block block, Vector direction, final int maxlength) {
|
||||||
|
@ -59,11 +58,6 @@ public abstract class EarthAbility<C extends AbilityConfig> extends ElementalAbi
|
||||||
return getEarthSourceBlock(this.player, this.getName(), range);
|
return getEarthSourceBlock(this.player, this.getName(), range);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.EARTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getLavaSourceBlock(final double range) {
|
public Block getLavaSourceBlock(final double range) {
|
||||||
return getLavaSourceBlock(this.player, this.getName(), range);
|
return getLavaSourceBlock(this.player, this.getName(), range);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ public abstract class ElementalAbility<Info extends AbilityInfo, C extends Abili
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElementalAbility(final C config, final Player player) {
|
public ElementalAbility(Player player) {
|
||||||
super(config, player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTransparent(final Block block) {
|
public boolean isTransparent(final Block block) {
|
||||||
|
|
|
@ -1,21 +1,7 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
|
@ -23,13 +9,22 @@ import com.projectkorra.projectkorra.configuration.configs.properties.FireProper
|
||||||
import com.projectkorra.projectkorra.firebending.BlazeArc;
|
import com.projectkorra.projectkorra.firebending.BlazeArc;
|
||||||
import com.projectkorra.projectkorra.util.Information;
|
import com.projectkorra.projectkorra.util.Information;
|
||||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public abstract class FireAbility<C extends AbilityConfig> extends ElementalAbility<C> {
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public abstract class FireAbility<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||||
|
|
||||||
private static final Map<Location, Information> TEMP_FIRE = new ConcurrentHashMap<Location, Information>();
|
private static final Map<Location, Information> TEMP_FIRE = new ConcurrentHashMap<Location, Information>();
|
||||||
|
|
||||||
public FireAbility(final C config, final Player player) {
|
public FireAbility(final Player player) {
|
||||||
super(config, player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,11 +37,6 @@ public abstract class FireAbility<C extends AbilityConfig> extends ElementalAbil
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.FIRE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCollision(final Collision collision) {
|
public void handleCollision(final Collision collision) {
|
||||||
super.handleCollision(collision);
|
super.handleCollision(collision);
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class FlightAbility<Info extends AbilityInfo, C extends AbilityConfig> extends AirAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class FlightAbility<C extends AbilityConfig> extends AirAbility<C> implements SubAbility {
|
public FlightAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public FlightAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return AirAbility.class;
|
return AirAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.FLIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class HealingAbility<Info extends AbilityInfo, C extends AbilityConfig> extends WaterAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class HealingAbility<C extends AbilityConfig> extends WaterAbility<C> implements SubAbility {
|
public HealingAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public HealingAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return WaterAbility.class;
|
return WaterAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.HEALING;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class IceAbility<Info extends AbilityInfo, C extends AbilityConfig> extends WaterAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class IceAbility<C extends AbilityConfig> extends WaterAbility<C> implements SubAbility {
|
public IceAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public IceAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return WaterAbility.class;
|
return WaterAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.ICE;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class LavaAbility<Info extends AbilityInfo, C extends AbilityConfig> extends EarthAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class LavaAbility<C extends AbilityConfig> extends EarthAbility<C> implements SubAbility {
|
public LavaAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public LavaAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return EarthAbility.class;
|
return EarthAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.LAVA;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class LightningAbility<Info extends AbilityInfo, C extends AbilityConfig> extends FireAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class LightningAbility<C extends AbilityConfig> extends FireAbility<C> implements SubAbility {
|
public LightningAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public LightningAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return FireAbility.class;
|
return FireAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.LIGHTNING;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class MetalAbility<Info extends AbilityInfo, C extends AbilityConfig> extends EarthAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class MetalAbility<C extends AbilityConfig> extends EarthAbility<C> implements SubAbility {
|
public MetalAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public MetalAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return EarthAbility.class;
|
return EarthAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.METAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager.MultiAbilityInfoSub;
|
|
||||||
|
|
||||||
public interface MultiAbility {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the sub abilities of a MultiAbility. For example:
|
|
||||||
* <p>
|
|
||||||
* {@code new
|
|
||||||
* MultiAbilitySub("SubAbility", Element.LIGHTNING);}
|
|
||||||
*
|
|
||||||
* @return a list of sub MultiAbilities
|
|
||||||
*/
|
|
||||||
public abstract ArrayList<MultiAbilityInfoSub> getMultiAbilities();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
|
||||||
|
|
||||||
public interface PassiveAbility {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a check to see if the passive requires some form of activation,
|
|
||||||
* such as sneaking, clicking, etc. <br>
|
|
||||||
* <b>If false, the passive should not call start!</b>
|
|
||||||
*
|
|
||||||
* @return false if this passive should always be on
|
|
||||||
*/
|
|
||||||
public boolean isInstantiable();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is used if the passive should progress
|
|
||||||
*
|
|
||||||
* @return false if progress() shouldn't be called;
|
|
||||||
*/
|
|
||||||
public boolean isProgressable();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class PlantAbility<Info extends AbilityInfo, C extends AbilityConfig> extends WaterAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class PlantAbility<C extends AbilityConfig> extends WaterAbility<C> implements SubAbility {
|
public PlantAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public PlantAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return WaterAbility.class;
|
return WaterAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.PLANT;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class SandAbility<Info extends AbilityInfo, C extends AbilityConfig> extends EarthAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class SandAbility<C extends AbilityConfig> extends EarthAbility<C> implements SubAbility {
|
public SandAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public SandAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return EarthAbility.class;
|
return EarthAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.SAND;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.Element;
|
public abstract class SpiritualAbility<Info extends AbilityInfo, C extends AbilityConfig> extends AirAbility<Info, C> implements SubAbility {
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
|
||||||
|
|
||||||
public abstract class SpiritualAbility<C extends AbilityConfig> extends AirAbility<C> implements SubAbility {
|
public SpiritualAbility(final Player player) {
|
||||||
|
super(player);
|
||||||
public SpiritualAbility(final C config, final Player player) {
|
|
||||||
super(config, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Ability> getParentAbility() {
|
public Class<? extends Ability> getParentAbility() {
|
||||||
return AirAbility.class;
|
return AirAbility.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getElement() {
|
|
||||||
return Element.SPIRITUAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
|
|
||||||
public interface SubAbility {
|
public interface SubAbility {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,21 +1,8 @@
|
||||||
package com.projectkorra.projectkorra.ability.api;
|
package com.projectkorra.projectkorra.ability.api;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Tag;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.data.Levelled;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Element;
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||||
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
import com.projectkorra.projectkorra.configuration.configs.abilities.AbilityConfig;
|
||||||
|
@ -30,16 +17,23 @@ import com.projectkorra.projectkorra.waterbending.Torrent;
|
||||||
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
||||||
import com.projectkorra.projectkorra.waterbending.ice.PhaseChange;
|
import com.projectkorra.projectkorra.waterbending.ice.PhaseChange;
|
||||||
import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
|
import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Tag;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.data.Levelled;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public abstract class WaterAbility<C extends AbilityConfig> extends ElementalAbility<C> {
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public WaterAbility(final C config, final Player player) {
|
public abstract class WaterAbility<Info extends AbilityInfo, C extends AbilityConfig> extends ElementalAbility<Info, C> {
|
||||||
super(config, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public WaterAbility(final Player player) {
|
||||||
public Element getElement() {
|
super(player);
|
||||||
return Element.WATER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getIceSourceBlock(final double range) {
|
public Block getIceSourceBlock(final double range) {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package com.projectkorra.projectkorra.ability.util;
|
package com.projectkorra.projectkorra.ability.util;
|
||||||
|
|
||||||
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Collision is used to represent the collision between two CoreAbility
|
* A Collision is used to represent the collision between two CoreAbility
|
||||||
* objects.
|
* objects.
|
||||||
|
@ -16,14 +15,14 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class Collision {
|
public class Collision {
|
||||||
private CoreAbility abilityFirst;
|
private Ability abilityFirst;
|
||||||
private CoreAbility abilitySecond;
|
private Ability abilitySecond;
|
||||||
private boolean removingFirst;
|
private boolean removingFirst;
|
||||||
private boolean removingSecond;
|
private boolean removingSecond;
|
||||||
private Location locationFirst;
|
private Location locationFirst;
|
||||||
private Location locationSecond;
|
private Location locationSecond;
|
||||||
|
|
||||||
public Collision(final CoreAbility abilityFirst, final CoreAbility abilitySecond, final boolean removingFirst, final boolean removingSecond, final Location locationFirst, final Location locationSecond) {
|
public Collision(final Ability abilityFirst, final Ability abilitySecond, final boolean removingFirst, final boolean removingSecond, final Location locationFirst, final Location locationSecond) {
|
||||||
if (abilityFirst == null || abilitySecond == null) {
|
if (abilityFirst == null || abilitySecond == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,23 +35,23 @@ public class Collision {
|
||||||
this.locationSecond = locationSecond;
|
this.locationSecond = locationSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collision(final CoreAbility abilityFirst, final CoreAbility abilitySecond, final boolean removingFirst, final boolean removingSecond) {
|
public Collision(final Ability abilityFirst, final Ability abilitySecond, final boolean removingFirst, final boolean removingSecond) {
|
||||||
this(abilityFirst, abilitySecond, removingFirst, removingSecond, null, null);
|
this(abilityFirst, abilitySecond, removingFirst, removingSecond, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreAbility getAbilityFirst() {
|
public Ability getAbilityFirst() {
|
||||||
return this.abilityFirst;
|
return this.abilityFirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbilityFirst(final CoreAbility abilityFirst) {
|
public void setAbilityFirst(final Ability abilityFirst) {
|
||||||
this.abilityFirst = abilityFirst;
|
this.abilityFirst = abilityFirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreAbility getAbilitySecond() {
|
public Ability getAbilitySecond() {
|
||||||
return this.abilitySecond;
|
return this.abilitySecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbilitySecond(final CoreAbility abilitySecond) {
|
public void setAbilitySecond(final Ability abilitySecond) {
|
||||||
this.abilitySecond = abilitySecond;
|
this.abilitySecond = abilitySecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
package com.projectkorra.projectkorra.ability.util;
|
package com.projectkorra.projectkorra.ability.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import java.util.Collection;
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
import java.util.HashMap;
|
import com.projectkorra.projectkorra.ability.AbilityManager;
|
||||||
import java.util.HashSet;
|
import com.projectkorra.projectkorra.ability.info.PassiveAbilityInfo;
|
||||||
import java.util.List;
|
import com.projectkorra.projectkorra.event.AbilityCollisionEvent;
|
||||||
|
import com.projectkorra.projectkorra.module.ModuleManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import java.util.*;
|
||||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
|
||||||
import com.projectkorra.projectkorra.ability.api.PassiveAbility;
|
|
||||||
import com.projectkorra.projectkorra.event.AbilityCollisionEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A CollisionManager is used to monitor possible collisions between all
|
* A CollisionManager is used to monitor possible collisions between all
|
||||||
|
@ -24,9 +21,9 @@ import com.projectkorra.projectkorra.event.AbilityCollisionEvent;
|
||||||
* ProjectKorra.getCollisionInitializer().addCollision(myCoreAbility)
|
* ProjectKorra.getCollisionInitializer().addCollision(myCoreAbility)
|
||||||
* ProjectKorra.getCollisionInitializer().addSmallAbility(myCoreAbility)
|
* ProjectKorra.getCollisionInitializer().addSmallAbility(myCoreAbility)
|
||||||
* <p>
|
* <p>
|
||||||
* For a CoreAbility to collide properly, the {@link CoreAbility#isCollidable()}
|
* For a CoreAbility to collide properly, the {@link Ability#isCollidable()}
|
||||||
* , {@link CoreAbility#getCollisionRadius()},
|
* , {@link Ability#getCollisionRadius()},
|
||||||
* {@link CoreAbility#getLocations()}, and {@link CoreAbility#handleCollision()}
|
* {@link Ability#getLocations()}, and {@link Ability#handleCollision()}
|
||||||
* should be overridden if necessary.
|
* should be overridden if necessary.
|
||||||
* <p>
|
* <p>
|
||||||
* During a Collision the {@link AbilityCollisionEvent} is called, then if not
|
* During a Collision the {@link AbilityCollisionEvent} is called, then if not
|
||||||
|
@ -36,6 +33,8 @@ import com.projectkorra.projectkorra.event.AbilityCollisionEvent;
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class CollisionManager {
|
public class CollisionManager {
|
||||||
|
|
||||||
|
private final AbilityManager abilityManager = ModuleManager.getModule(AbilityManager.class);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If true an ability instance can remove multiple other instances on a
|
* If true an ability instance can remove multiple other instances on a
|
||||||
* single tick. e.g. 3 Colliding WaterManipulations can all be removed
|
* single tick. e.g. 3 Colliding WaterManipulations can all be removed
|
||||||
|
@ -70,8 +69,8 @@ public class CollisionManager {
|
||||||
private void detectCollisions() {
|
private void detectCollisions() {
|
||||||
int activeInstanceCount = 0;
|
int activeInstanceCount = 0;
|
||||||
|
|
||||||
for (final CoreAbility ability : CoreAbility.getAbilitiesByInstances()) {
|
for (final Ability ability : this.abilityManager.getAbilities()) {
|
||||||
if (!(ability instanceof PassiveAbility)) {
|
if (!(ability.getInfo() instanceof PassiveAbilityInfo)) {
|
||||||
if (++activeInstanceCount > 1) {
|
if (++activeInstanceCount > 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -82,21 +81,21 @@ public class CollisionManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashMap<CoreAbility, List<Location>> locationsCache = new HashMap<>();
|
final HashMap<Ability, List<Location>> locationsCache = new HashMap<>();
|
||||||
|
|
||||||
for (final Collision collision : this.collisions) {
|
for (final Collision collision : this.collisions) {
|
||||||
final Collection<? extends CoreAbility> instancesFirst = CoreAbility.getAbilities(collision.getAbilityFirst().getClass());
|
final Collection<? extends Ability> instancesFirst = this.abilityManager.getAbilities(collision.getAbilityFirst().getClass());
|
||||||
if (instancesFirst.isEmpty()) {
|
if (instancesFirst.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Collection<? extends CoreAbility> instancesSecond = CoreAbility.getAbilities(collision.getAbilitySecond().getClass());
|
final Collection<? extends Ability> instancesSecond = this.abilityManager.getAbilities(collision.getAbilitySecond().getClass());
|
||||||
if (instancesSecond.isEmpty()) {
|
if (instancesSecond.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final HashSet<CoreAbility> alreadyCollided = new HashSet<CoreAbility>();
|
final HashSet<Ability> alreadyCollided = new HashSet<>();
|
||||||
final double certainNoCollisionDistSquared = Math.pow(this.certainNoCollisionDistance, 2);
|
final double certainNoCollisionDistSquared = Math.pow(this.certainNoCollisionDistance, 2);
|
||||||
|
|
||||||
for (final CoreAbility abilityFirst : instancesFirst) {
|
for (final Ability abilityFirst : instancesFirst) {
|
||||||
if (abilityFirst.getPlayer() == null || alreadyCollided.contains(abilityFirst) || !abilityFirst.isCollidable()) {
|
if (abilityFirst.getPlayer() == null || alreadyCollided.contains(abilityFirst) || !abilityFirst.isCollidable()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +108,7 @@ public class CollisionManager {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final CoreAbility abilitySecond : instancesSecond) {
|
for (final Ability abilitySecond : instancesSecond) {
|
||||||
if (abilitySecond.getPlayer() == null || alreadyCollided.contains(abilitySecond) || !abilitySecond.isCollidable()) {
|
if (abilitySecond.getPlayer() == null || alreadyCollided.contains(abilitySecond) || !abilitySecond.isCollidable()) {
|
||||||
continue;
|
continue;
|
||||||
} else if (abilityFirst.getPlayer().equals(abilitySecond.getPlayer())) {
|
} else if (abilityFirst.getPlayer().equals(abilitySecond.getPlayer())) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.projectkorra.projectkorra.command;
|
package com.projectkorra.projectkorra.command;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ability.AbilityInfo;
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||||
import com.projectkorra.projectkorra.configuration.configs.commands.BindCommandConfig;
|
import com.projectkorra.projectkorra.configuration.configs.commands.BindCommandConfig;
|
||||||
import com.projectkorra.projectkorra.element.Element;
|
import com.projectkorra.projectkorra.element.Element;
|
||||||
|
@ -154,7 +154,7 @@ public class BindCommand extends PKCommand<BindCommandConfig> {
|
||||||
|
|
||||||
Set<String> abilitySet = new HashSet<>();
|
Set<String> abilitySet = new HashSet<>();
|
||||||
|
|
||||||
for (AbilityInfo abilityInfo : this.abilityManager.getAbilities()) {
|
for (AbilityInfo abilityInfo : this.abilityManager.getAbilityInfo()) {
|
||||||
// if (!coreAbil.isHiddenAbility() && bPlayer.canBind(coreAbil) && !(coreAbil instanceof PassiveAbility || coreAbil instanceof ComboAbility) && !abilities.contains(coreAbil.getName())) {
|
// if (!coreAbil.isHiddenAbility() && bPlayer.canBind(coreAbil) && !(coreAbil instanceof PassiveAbility || coreAbil instanceof ComboAbility) && !abilities.contains(coreAbil.getName())) {
|
||||||
|
|
||||||
if (bendingPlayer.canBind(abilityInfo)) {
|
if (bendingPlayer.canBind(abilityInfo)) {
|
||||||
|
|
|
@ -2,13 +2,12 @@ package com.projectkorra.projectkorra.player;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ability.Ability;
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
import com.projectkorra.projectkorra.ability.AbilityInfo;
|
|
||||||
import com.projectkorra.projectkorra.ability.AbilityManager;
|
import com.projectkorra.projectkorra.ability.AbilityManager;
|
||||||
import com.projectkorra.projectkorra.ability.PassiveAbilityManager;
|
import com.projectkorra.projectkorra.ability.PassiveAbilityManager;
|
||||||
import com.projectkorra.projectkorra.ability.api.ChiAbility;
|
import com.projectkorra.projectkorra.ability.api.ChiAbility;
|
||||||
import com.projectkorra.projectkorra.ability.bind.AbilityBindManager;
|
import com.projectkorra.projectkorra.ability.bind.AbilityBindManager;
|
||||||
import com.projectkorra.projectkorra.ability.loader.AbilityLoader;
|
import com.projectkorra.projectkorra.ability.info.AbilityInfo;
|
||||||
import com.projectkorra.projectkorra.ability.loader.AvatarAbilityLoader;
|
import com.projectkorra.projectkorra.ability.info.AvatarAbilityInfo;
|
||||||
import com.projectkorra.projectkorra.cooldown.CooldownManager;
|
import com.projectkorra.projectkorra.cooldown.CooldownManager;
|
||||||
import com.projectkorra.projectkorra.element.Element;
|
import com.projectkorra.projectkorra.element.Element;
|
||||||
import com.projectkorra.projectkorra.element.ElementManager;
|
import com.projectkorra.projectkorra.element.ElementManager;
|
||||||
|
@ -166,10 +165,9 @@ public class BendingPlayer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbilityLoader abilityLoader = abilityInfo.getLoader();
|
|
||||||
Element element = abilityInfo.getElement();
|
Element element = abilityInfo.getElement();
|
||||||
|
|
||||||
if (!hasElement(element) && !(abilityLoader instanceof AvatarAbilityLoader && !((AvatarAbilityLoader) abilityLoader).requireAvatar())) {
|
if (!hasElement(element) && !(abilityInfo instanceof AvatarAbilityInfo && !((AvatarAbilityInfo) abilityInfo).requireAvatar())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue