Package com.sucy.skill
Class SkillAPI
java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
com.sucy.skill.SkillAPI
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter,org.bukkit.command.TabExecutor,org.bukkit.plugin.Plugin
public class SkillAPI
extends org.bukkit.plugin.java.JavaPlugin
The main class of the plugin which has the accessor methods into most of the API.
You can retrieve a reference to this through Bukkit the same way as any other plugin.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a new class with SkillAPI.voidaddClasses(RPGClass... classes) Registers a new class with SkillAPI.voidaddDynamicClass(DynamicClass rpgClass) Adds a dynamic class which ignores validation.voidaddDynamicSkill(DynamicSkill skill) This adds a dynamic skill to the skill list.voidRegisters a new skill with SkillAPI.voidRegisters multiple new skills with SkillAPI.static AttributeManagerRetrieves the attribute manager for SkillAPIgetBaseClasses(String group) Retrieves a list of base classes that don't profess from another classstatic RPGClassRetrieves a class by name.Retrieves the registered class data for SkillAPI.static ComboManagerRetrieves the manager for click cast combosstatic mc.promcteam.engine.mccore.config.CommentedConfigGrabs a config for SkillAPIRetrieves the list of active class groups used by registered classesstatic mc.promcteam.engine.mccore.config.CommentedLanguageConfigRetrieves the language file data for SkillAPIstatic ObjectRetrieves metadata from an entitystatic doublegetMetaDouble(org.bukkit.metadata.Metadatable target, String key) Retrieves metadata from an entitystatic intgetMetaInt(org.bukkit.metadata.Metadatable target, String key) Retrieves metadata from an entitystatic HashMap<String,PlayerAccounts> Retrieves all the player data of SkillAPI.static PlayerAccountsgetPlayerAccountData(org.bukkit.OfflinePlayer player) Retrieves all class data for the player.static PlayerDatagetPlayerData(org.bukkit.OfflinePlayer player) Retrieves the active class data for the player.static SettingsRetrieves the settings data controlling SkillAPIstatic SkillRetrieves a skill by name.Retrieves the registered skill data for SkillAPI.static booleanhasPlayerData(org.bukkit.OfflinePlayer player) Checks whether SkillAPI currently has loaded data for the given player.static voidinitFakeData(org.bukkit.OfflinePlayer player) Used to fake player data until SQL data is loaded when both SQL and the SQL delay are enabled.static SkillAPIinst()static booleanisClassRegistered(RPGClass rpgClass) Checks whether a class is registered.static booleanisClassRegistered(PlayerClass playerClass) Checks whether a class is registered.static booleanisClassRegistered(String name) Checks whether a class is registered.static booleanisLoaded()Checks whether SkillAPI has all its data loaded and running.static booleanisSkillRegistered(PlayerSkill skill) Checks whether a skill is registeredstatic booleanisSkillRegistered(Skill skill) Checks whether a skill is registeredstatic booleanisSkillRegistered(String name) Checks whether a skill is registered.voidlisten(SkillAPIListener listener, boolean enabled) static PlayerAccountsloadPlayerData(org.bukkit.OfflinePlayer player) Loads the data for a player when they join the server.voidDisables SkillAPI, saving data before unloading everything and disconnecting listeners.voidonEnable()Enables SkillAPI, setting up listeners, managers, and loading data.voidonLoad()static voidreload()Reloads the pluginstatic voidreloadPlayerData(org.bukkit.entity.Player player) Do not use this method outside onJoin.static voidremoveMeta(org.bukkit.metadata.Metadatable target, String key) Removes metadata from an entitystatic voidsaveData()Saves all player data to the configs.static org.bukkit.scheduler.BukkitTaskSchedules a delayed taskstatic org.bukkit.scheduler.BukkitTaskschedule(org.bukkit.scheduler.BukkitRunnable runnable, int delay) Schedules a delayed taskstatic org.bukkit.scheduler.BukkitTaskschedule(org.bukkit.scheduler.BukkitRunnable runnable, int delay, int period) Schedules a repeating taskstatic voidSets a value to an entity's metadatastatic voidunloadPlayerData(org.bukkit.OfflinePlayer player) Unloads player data from memory, saving it to the config first and then removing it from the map.static voidunloadPlayerData(org.bukkit.OfflinePlayer player, boolean skipSaving) Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getConfig, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLogger, getPlugin, getPluginLoader, getProvidingPlugin, getResource, getServer, getTextResource, isEnabled, isNaggable, onCommand, onTabComplete, reloadConfig, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode
-
Constructor Details
-
SkillAPI
public SkillAPI() -
SkillAPI
-
-
Method Details
-
isLoaded
public static boolean isLoaded()Checks whether SkillAPI has all its data loaded and running.- Returns:
- true if loaded and set up, false otherwise
-
inst
- Returns:
- SkillAPI singleton if available
- Throws:
SkillAPINotEnabledException- if SkillAPI isn't enabled
-
getSettings
Retrieves the settings data controlling SkillAPI- Returns:
- SkillAPI settings data
-
getLanguage
public static mc.promcteam.engine.mccore.config.CommentedLanguageConfig getLanguage()Retrieves the language file data for SkillAPI- Returns:
- SkillAPI language file data
-
getComboManager
Retrieves the manager for click cast combos- Returns:
- click combo manager
-
getAttributeManager
Retrieves the attribute manager for SkillAPI- Returns:
- attribute manager
-
getSkill
Retrieves a skill by name. If no skill is found with the name, null is returned instead.- Parameters:
name- name of the skill- Returns:
- skill with the name or null if not found
-
getSkills
Retrieves the registered skill data for SkillAPI. It is recommended that you don't edit this map. Instead, use "addSkill" and "addSkills" instead.- Returns:
- the map of registered skills
-
isSkillRegistered
Checks whether a skill is registered.- Parameters:
name- name of the skill- Returns:
- true if registered, false otherwise
-
isSkillRegistered
Checks whether a skill is registered- Parameters:
skill- the skill to check- Returns:
- true if registered, false otherwise
-
isSkillRegistered
Checks whether a skill is registered- Parameters:
skill- the skill to check- Returns:
- true if registered, false otherwise
-
getClass
Retrieves a class by name. If no skill is found with the name, null is returned instead.- Parameters:
name- name of the class- Returns:
- class with the name or null if not found
-
getClasses
Retrieves the registered class data for SkillAPI. It is recommended that you don't edit this map. Instead, use "addClass" and "addClasses" instead.- Returns:
- the map of registered skills
-
getBaseClasses
Retrieves a list of base classes that don't profess from another class- Returns:
- the list of base classes
-
isClassRegistered
Checks whether a class is registered.- Parameters:
name- name of the class- Returns:
- true if registered, false otherwise
-
isClassRegistered
Checks whether a class is registered.- Parameters:
playerClass- the class to check- Returns:
- true if registered, false otherwise
-
isClassRegistered
Checks whether a class is registered.- Parameters:
rpgClass- the class to check- Returns:
- true if registered, false otherwise
-
getPlayerData
Retrieves the active class data for the player. If no data is found for the player, a new set of data will be created and returned.- Parameters:
player- player to get the data for- Returns:
- the class data of the player
-
loadPlayerData
Loads the data for a player when they join the server. This is handled by the API and doesn't need to be used elsewhere unless you want to load a player's data without them logging on. This should be run asynchronously since it is loading configuration files.- Parameters:
player- player to load the data for
-
initFakeData
public static void initFakeData(org.bukkit.OfflinePlayer player) Used to fake player data until SQL data is loaded when both SQL and the SQL delay are enabled. This should not be used by other plugins. If the player data already exists, this does nothing.- Parameters:
player- player to fake data for
-
reloadPlayerData
public static void reloadPlayerData(org.bukkit.entity.Player player) Do not use this method outside onJoin. This will delete any progress a player has made since joining. -
saveData
public static void saveData()Saves all player data to the configs. This should be called asynchronously to avoid problems with the main server loop. -
hasPlayerData
public static boolean hasPlayerData(org.bukkit.OfflinePlayer player) Checks whether SkillAPI currently has loaded data for the given player. This returning false doesn't necessarily mean the player doesn't have any data at all, just not data that is currently loaded.- Parameters:
player- player to check for- Returns:
- true if data has loaded, false otherwise
-
unloadPlayerData
public static void unloadPlayerData(org.bukkit.OfflinePlayer player) Unloads player data from memory, saving it to the config first and then removing it from the map.- Parameters:
player- player to unload data for
-
unloadPlayerData
public static void unloadPlayerData(org.bukkit.OfflinePlayer player, boolean skipSaving) -
getPlayerAccountData
Retrieves all class data for the player. This includes the active and all inactive accounts the player has. If no data is found, a new set of data will be created and returned.- Parameters:
player- player to get the data for- Returns:
- the class data of the player
-
getPlayerAccountData
Retrieves all the player data of SkillAPI. It is recommended not to modify this map. Instead, use helper methods within individual player data.- Returns:
- all SkillAPI player data
-
getGroups
Retrieves the list of active class groups used by registered classes- Returns:
- list of active class groups
-
schedule
public static org.bukkit.scheduler.BukkitTask schedule(org.bukkit.scheduler.BukkitRunnable runnable, int delay) Schedules a delayed task- Parameters:
runnable- the task to scheduledelay- the delay in ticks
-
schedule
Schedules a delayed task- Parameters:
runnable- the task to scheduledelay- the delay in ticks
-
schedule
public static org.bukkit.scheduler.BukkitTask schedule(org.bukkit.scheduler.BukkitRunnable runnable, int delay, int period) Schedules a repeating task- Parameters:
runnable- the task to scheduledelay- the delay in ticks before the first tickperiod- how often to run in ticks
-
setMeta
Sets a value to an entity's metadata- Parameters:
target- entity to set tokey- key to store undervalue- value to store
-
getMeta
Retrieves metadata from an entity- Parameters:
target- entity to retrieve fromkey- key the value was stored under- Returns:
- the stored value
-
getMetaInt
Retrieves metadata from an entity- Parameters:
target- entity to retrieve fromkey- key the value was stored under- Returns:
- the stored value
-
getMetaDouble
Retrieves metadata from an entity- Parameters:
target- entity to retrieve fromkey- key the value was stored under- Returns:
- the stored value
-
removeMeta
Removes metadata from an entity- Parameters:
target- entity to remove fromkey- key metadata was stored under
-
getConfig
Grabs a config for SkillAPI- Parameters:
name- config file name- Returns:
- config data
-
reload
public static void reload()Reloads the plugin -
onLoad
public void onLoad()- Specified by:
onLoadin interfaceorg.bukkit.plugin.Plugin- Overrides:
onLoadin classorg.bukkit.plugin.java.JavaPlugin
-
onDisable
public void onDisable()Disables SkillAPI, saving data before unloading everything and disconnecting listeners. This should not be called by other plugins.
- Specified by:
onDisablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onDisablein classorg.bukkit.plugin.java.JavaPlugin
-
onEnable
public void onEnable()Enables SkillAPI, setting up listeners, managers, and loading data. This should not be called by other plugins.
- Specified by:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.bukkit.plugin.java.JavaPlugin
-
listen
-
addDynamicSkill
This adds a dynamic skill to the skill list. This should not be called by other plugins.- Parameters:
skill- the dynamic skill to register
-
addSkill
Registers a new skill with SkillAPI. If this is called outside the method provided in SkillPlugin, this will throw an error. You should implement SkillPlugin in your main class and call this from the provided "registerSkills" method.- Parameters:
skill- skill to register
-
addSkills
Registers multiple new skills with SkillAPI. If this is called outside the method provided in SkillPlugin, this will throw an error. You should implement SkillPlugin in your main class and call this from the provided "registerSkills" method.- Parameters:
skills- skills to register
-
addClass
Registers a new class with SkillAPI. If this is called outside the method provided in SkillPlugin, this will throw an error. You should implement SkillPlugin in your main class and call this from the provided "registerClasses" method.- Parameters:
rpgClass- class to register
-
addDynamicClass
Adds a dynamic class which ignores validation. This should only be used by the API as other plugins should use the regular addClass.- Parameters:
rpgClass- dynamic class to add
-
addClasses
Registers a new class with SkillAPI. If this is called outside the method provided in SkillPlugin, this will throw an error. You should implement SkillPlugin in your main class and call this from the provided "registerClasses" method.- Parameters:
classes- classes to register
-