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
    Constructor
    Description
     
    SkillAPI(org.bukkit.plugin.java.JavaPluginLoader loader, org.bukkit.plugin.PluginDescriptionFile description, File dataFolder, File file)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addClass(RPGClass rpgClass)
    Registers a new class with SkillAPI.
    void
    addClasses(RPGClass... classes)
    Registers a new class with SkillAPI.
    void
    Adds a dynamic class which ignores validation.
    void
    This adds a dynamic skill to the skill list.
    void
    addSkill(Skill skill)
    Registers a new skill with SkillAPI.
    void
    addSkills(Skill... skills)
    Registers multiple new skills with SkillAPI.
    Retrieves the attribute manager for SkillAPI
    Retrieves a list of base classes that don't profess from another class
    static RPGClass
    Retrieves a class by name.
    Retrieves the registered class data for SkillAPI.
    Retrieves the manager for click cast combos
    static mc.promcteam.engine.mccore.config.CommentedConfig
    Grabs a config for SkillAPI
    static List<String>
    Retrieves the list of active class groups used by registered classes
    static mc.promcteam.engine.mccore.config.CommentedLanguageConfig
    Retrieves the language file data for SkillAPI
    static Object
    getMeta(org.bukkit.metadata.Metadatable target, String key)
    Retrieves metadata from an entity
    static double
    getMetaDouble(org.bukkit.metadata.Metadatable target, String key)
    Retrieves metadata from an entity
    static int
    getMetaInt(org.bukkit.metadata.Metadatable target, String key)
    Retrieves metadata from an entity
    Retrieves all the player data of SkillAPI.
    getPlayerAccountData(org.bukkit.OfflinePlayer player)
    Retrieves all class data for the player.
    static PlayerData
    getPlayerData(org.bukkit.OfflinePlayer player)
    Retrieves the active class data for the player.
    static Settings
    Retrieves the settings data controlling SkillAPI
    static Skill
    Retrieves a skill by name.
    Retrieves the registered skill data for SkillAPI.
    static boolean
    hasPlayerData(org.bukkit.OfflinePlayer player)
    Checks whether SkillAPI currently has loaded data for the given player.
    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.
    static SkillAPI
     
    static boolean
    Checks whether a class is registered.
    static boolean
    Checks whether a class is registered.
    static boolean
    Checks whether a class is registered.
    static boolean
    Checks whether SkillAPI has all its data loaded and running.
    static boolean
    Checks whether a skill is registered
    static boolean
    Checks whether a skill is registered
    static boolean
    Checks whether a skill is registered.
    void
    listen(SkillAPIListener listener, boolean enabled)
     
    loadPlayerData(org.bukkit.OfflinePlayer player)
    Loads the data for a player when they join the server.
    void
    Disables SkillAPI, saving data before unloading everything and disconnecting listeners.
    void
    Enables SkillAPI, setting up listeners, managers, and loading data.
    void
     
    static void
    Reloads the plugin
    static void
    reloadPlayerData(org.bukkit.entity.Player player)
    Do not use this method outside onJoin.
    static void
    removeMeta(org.bukkit.metadata.Metadatable target, String key)
    Removes metadata from an entity
    static void
    Saves all player data to the configs.
    static org.bukkit.scheduler.BukkitTask
    schedule(Runnable runnable, int delay)
    Schedules a delayed task
    static org.bukkit.scheduler.BukkitTask
    schedule(org.bukkit.scheduler.BukkitRunnable runnable, int delay)
    Schedules a delayed task
    static org.bukkit.scheduler.BukkitTask
    schedule(org.bukkit.scheduler.BukkitRunnable runnable, int delay, int period)
    Schedules a repeating task
    static void
    setMeta(org.bukkit.metadata.Metadatable target, String key, Object value)
    Sets a value to an entity's metadata
    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.
    static void
    unloadPlayerData(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, toString

    Methods inherited from class org.bukkit.plugin.PluginBase

    equals, getName, hashCode

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SkillAPI

      public SkillAPI()
    • SkillAPI

      public SkillAPI(org.bukkit.plugin.java.JavaPluginLoader loader, org.bukkit.plugin.PluginDescriptionFile description, File dataFolder, File file)
  • 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

      public static SkillAPI inst()
      Returns:
      SkillAPI singleton if available
      Throws:
      SkillAPINotEnabledException - if SkillAPI isn't enabled
    • getSettings

      public static Settings 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

      public static ComboManager getComboManager()
      Retrieves the manager for click cast combos
      Returns:
      click combo manager
    • getAttributeManager

      public static AttributeManager getAttributeManager()
      Retrieves the attribute manager for SkillAPI
      Returns:
      attribute manager
    • getSkill

      public static Skill getSkill(String name)
      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

      public static HashMap<String,Skill> 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

      public static boolean isSkillRegistered(String name)
      Checks whether a skill is registered.
      Parameters:
      name - name of the skill
      Returns:
      true if registered, false otherwise
    • isSkillRegistered

      public static boolean isSkillRegistered(PlayerSkill skill)
      Checks whether a skill is registered
      Parameters:
      skill - the skill to check
      Returns:
      true if registered, false otherwise
    • isSkillRegistered

      public static boolean isSkillRegistered(Skill skill)
      Checks whether a skill is registered
      Parameters:
      skill - the skill to check
      Returns:
      true if registered, false otherwise
    • getClass

      public static RPGClass getClass(String name)
      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

      public static HashMap<String,RPGClass> 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

      public static ArrayList<RPGClass> getBaseClasses(String group)
      Retrieves a list of base classes that don't profess from another class
      Returns:
      the list of base classes
    • isClassRegistered

      public static boolean isClassRegistered(String name)
      Checks whether a class is registered.
      Parameters:
      name - name of the class
      Returns:
      true if registered, false otherwise
    • isClassRegistered

      public static boolean isClassRegistered(PlayerClass playerClass)
      Checks whether a class is registered.
      Parameters:
      playerClass - the class to check
      Returns:
      true if registered, false otherwise
    • isClassRegistered

      public static boolean isClassRegistered(RPGClass rpgClass)
      Checks whether a class is registered.
      Parameters:
      rpgClass - the class to check
      Returns:
      true if registered, false otherwise
    • getPlayerData

      public static PlayerData getPlayerData(org.bukkit.OfflinePlayer player)
      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

      public static PlayerAccounts loadPlayerData(org.bukkit.OfflinePlayer player)
      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

      public static PlayerAccounts getPlayerAccountData(org.bukkit.OfflinePlayer player)
      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

      public static HashMap<String,PlayerAccounts> 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

      public static List<String> 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 schedule
      delay - the delay in ticks
    • schedule

      public static org.bukkit.scheduler.BukkitTask schedule(Runnable runnable, int delay)
      Schedules a delayed task
      Parameters:
      runnable - the task to schedule
      delay - 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 schedule
      delay - the delay in ticks before the first tick
      period - how often to run in ticks
    • setMeta

      public static void setMeta(org.bukkit.metadata.Metadatable target, String key, Object value)
      Sets a value to an entity's metadata
      Parameters:
      target - entity to set to
      key - key to store under
      value - value to store
    • getMeta

      public static Object getMeta(org.bukkit.metadata.Metadatable target, String key)
      Retrieves metadata from an entity
      Parameters:
      target - entity to retrieve from
      key - key the value was stored under
      Returns:
      the stored value
    • getMetaInt

      public static int getMetaInt(org.bukkit.metadata.Metadatable target, String key)
      Retrieves metadata from an entity
      Parameters:
      target - entity to retrieve from
      key - key the value was stored under
      Returns:
      the stored value
    • getMetaDouble

      public static double getMetaDouble(org.bukkit.metadata.Metadatable target, String key)
      Retrieves metadata from an entity
      Parameters:
      target - entity to retrieve from
      key - key the value was stored under
      Returns:
      the stored value
    • removeMeta

      public static void removeMeta(org.bukkit.metadata.Metadatable target, String key)
      Removes metadata from an entity
      Parameters:
      target - entity to remove from
      key - key metadata was stored under
    • getConfig

      public static mc.promcteam.engine.mccore.config.CommentedConfig getConfig(String name)
      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:
      onLoad in interface org.bukkit.plugin.Plugin
      Overrides:
      onLoad in class org.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:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.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:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.bukkit.plugin.java.JavaPlugin
    • listen

      public void listen(SkillAPIListener listener, boolean enabled)
    • addDynamicSkill

      public void addDynamicSkill(DynamicSkill skill)
      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

      public void addSkill(Skill skill)
      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

      public void addSkills(Skill... skills)
      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

      public void addClass(RPGClass rpgClass)
      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

      public void addDynamicClass(DynamicClass rpgClass)
      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

      public void addClasses(RPGClass... classes)
      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