public abstract class CoreAbility extends java.lang.Object implements Ability
JavaPlugin
, or located in an
external JarFile
.Constructor and Description |
---|
CoreAbility()
The default constructor is needed to create a fake instance of each
CoreAbility via reflection in
registerAbilities() . |
CoreAbility(org.bukkit.entity.Player player)
Creates a new CoreAbility instance but does not start it.
|
Modifier and Type | Method and Description |
---|---|
static java.util.ArrayList<CoreAbility> |
getAbilities()
Returns a list of "fake" instances for each ability that was loaded by
registerAbilities() |
static <T extends CoreAbility> |
getAbilities(java.lang.Class<T> clazz)
Returns a Collection of all of the player created instances for a
specific type of CoreAbility.
|
static <T extends CoreAbility> |
getAbilities(org.bukkit.entity.Player player,
java.lang.Class<T> clazz)
Returns a Collection of specific CoreAbility instances that were created
by the specified player.
|
static java.util.List<CoreAbility> |
getAbilitiesByElement(Element element)
Returns an List of fake instances that were loaded by
registerAbilities() filtered by Element. |
static <T extends CoreAbility> |
getAbility(org.bukkit.entity.Player player,
java.lang.Class<T> clazz)
Returns any T CoreAbility that has been started and not yet removed.
|
static CoreAbility |
getAbility(java.lang.String abilityName)
Returns a "fake" instance for the CoreAbility represented by abilityName.
|
BendingPlayer |
getBendingPlayer() |
static org.bukkit.configuration.file.FileConfiguration |
getConfig() |
static java.lang.String |
getDebugString()
Returns a String used to debug potential CoreAbility memory that can be
caused by a developer forgetting to call
remove() |
java.lang.String |
getDescription()
The description of an ability is a few sentences used to describe how the
player can fully utilize the ability.
|
int |
getId() |
static org.bukkit.configuration.file.FileConfiguration |
getLanguageConfig() |
org.bukkit.entity.Player |
getPlayer()
Returns the player that caused this ability to be initiated.
|
static java.util.Set<org.bukkit.entity.Player> |
getPlayers(java.lang.Class<? extends CoreAbility> clazz)
Returns a Set of all of the players that currently have an active
instance of clazz.
|
long |
getStartTime() |
static <T extends CoreAbility> |
hasAbility(org.bukkit.entity.Player player,
java.lang.Class<T> clazz)
Returns true if the player has an active CoreAbility instance of type T.
|
boolean |
isEnabled()
Returns true if the ability is enabled through the config.yml.
|
boolean |
isHiddenAbility()
A hidden ability is an ability that should not be shown by commands such
as /bending display and /bending help.
|
boolean |
isRemoved() |
boolean |
isStarted() |
static void |
progressAll()
Causes
Ability.progress() to be called on every CoreAbility instance
that has been started and has not been removed. |
static void |
registerAbilities()
Scans and loads plugin CoreAbilities, and Addon CoreAbilities that are
located in a Jar file inside of the /ProjectKorra/Abilities/ folder.
|
static void |
registerAddonAbilities(java.lang.String folder)
Scans all of the Jar files inside of /ProjectKorra/folder and registers
all of the CoreAbility class files that were found.
|
static void |
registerPluginAbilities(org.bukkit.plugin.java.JavaPlugin plugin,
java.lang.String packagePrefix)
Scans a JavaPlugin and registers CoreAbility class files.
|
void |
remove()
Causes this CoreAbility instance to be removed, and
Ability.progress()
will no longer be called every tick. |
static void |
removeAll()
Removes every CoreAbility instance that has been started but not yet
removed.
|
void |
start()
Causes the ability to begin updating every tick by calling
Ability.progress() until remove() is called. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCooldown, getElement, getLocation, getName, isExplosiveAbility, isHarmlessAbility, isIgniteAbility, isSneakAbility, progress
public CoreAbility()
registerAbilities()
. More
specifically, registerPluginAbilities(org.bukkit.plugin.java.JavaPlugin, java.lang.String)
calls
getDeclaredConstructor which is only usable with a public default
constructor. Reflection lets us create a list of all of the plugin's
abilities when the plugin first loads.ABILITIES_BY_NAME
,
getAbility(String)
public CoreAbility(org.bukkit.entity.Player player)
player
- the non-null player that created this instancestart()
public final void start()
Ability.progress()
until remove()
is called. This method cannot
be overridden, and any code that needs to be performed before start
should be handled in the constructor.getStartTime()
,
isStarted()
,
isRemoved()
public void remove()
Ability.progress()
will no longer be called every tick. If this method is overridden then
the new method must call super.remove().
Causes the ability to be removed from existence.remove
in interface Ability
isRemoved()
public static void progressAll()
Ability.progress()
to be called on every CoreAbility instance
that has been started and has not been removed.public static void removeAll()
public static <T extends CoreAbility> T getAbility(org.bukkit.entity.Player player, java.lang.Class<T> clazz)
player
- the player that created the CoreAbility instanceclazz
- the class of the type of CoreAbilitypublic static CoreAbility getAbility(java.lang.String abilityName)
registerAbilities()
when the plugin was first
loaded.
These "fake" instances have a null player, but methods such as
Ability.getName()
, and Ability.getElement()
will still
work, as will checking the type of the ability with instanceof.
CoreAbility coreAbil = getAbility(someString);
if (coreAbil instanceof FireAbility && coreAbil.isSneakAbility())
abilityName
- the name of a loaded CoreAbilitypublic static java.util.ArrayList<CoreAbility> getAbilities()
registerAbilities()
public static <T extends CoreAbility> java.util.Collection<T> getAbilities(java.lang.Class<T> clazz)
clazz
- the class for the type of CoreAbilitiespublic static <T extends CoreAbility> java.util.Collection<T> getAbilities(org.bukkit.entity.Player player, java.lang.Class<T> clazz)
player
- the player that created the instancesclazz
- the class for the type of CoreAbilitiespublic static java.util.List<CoreAbility> getAbilitiesByElement(Element element)
registerAbilities()
filtered by Element.element
- the Element of the loaded abilitiespublic static <T extends CoreAbility> boolean hasAbility(org.bukkit.entity.Player player, java.lang.Class<T> clazz)
player
- the player that created the T instanceclazz
- the class for the type of CoreAbilitypublic static java.util.Set<org.bukkit.entity.Player> getPlayers(java.lang.Class<? extends CoreAbility> clazz)
clazz
- the clazz for the type of CoreAbilitypublic static void registerAbilities()
public static void registerPluginAbilities(org.bukkit.plugin.java.JavaPlugin plugin, java.lang.String packagePrefix)
plugin
- a JavaPlugin containing CoreAbility class filespackagePrefix
- a prefix of the package name, used to increase performancegetAbilities()
,
getAbility(String)
public static void registerAddonAbilities(java.lang.String folder)
folder
- the name of the folder to scangetAbilities()
,
getAbility(String)
public long getStartTime()
public boolean isStarted()
public boolean isRemoved()
public BendingPlayer getBendingPlayer()
public int getId()
public boolean isHiddenAbility()
Ability
isHiddenAbility
in interface Ability
public boolean isEnabled()
Ability
public java.lang.String getDescription()
Ability
getConfig()
.getDescription
in interface Ability
HelpCommand
,
getDescription()
public org.bukkit.entity.Player getPlayer()
Ability
getAbility(String)
, or if an ability decided to set
player to null.public static org.bukkit.configuration.file.FileConfiguration getConfig()
public static org.bukkit.configuration.file.FileConfiguration getLanguageConfig()
public static java.lang.String getDebugString()
remove()