Class AddonAPI

java.lang.Object
dev.cwhead.GravesX.api.addon.AddonAPI

public final class AddonAPI extends Object
Addon helper API.

Provides convenience methods for common addon lifecycle actions such as ensuring the addon data folder exists and exporting default configuration files.

Usage: construct once with the owning Graves plugin and call the helper methods from your addon during startup.

Since:
4.9
  • Constructor Summary

    Constructors
    Constructor
    Description
    AddonAPI(Graves plugin)
    Creates a new AddonAPI bound to the given Graves plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    ensureAddonFolder(org.bukkit.plugin.Plugin addon)
    Ensures creation of an addon folder.
    int
    exportAddonConfigs(org.bukkit.plugin.Plugin addon)
    Exports the addon's default configuration files if they do not already exist.
    int
    exportAddonConfigs(org.bukkit.plugin.Plugin addon, boolean replaceIfExists)
    Exports the addon's default configuration files with optional replacement.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AddonAPI

      public AddonAPI(Graves plugin)
      Creates a new AddonAPI bound to the given Graves plugin.
      Parameters:
      plugin - the owning Graves plugin (must not be null)
      Throws:
      NullPointerException - if plugin is null
  • Method Details

    • ensureAddonFolder

      public void ensureAddonFolder(org.bukkit.plugin.Plugin addon)
      Ensures creation of an addon folder.

      If the folder does not exist, it will be created under the Graves addon root using the addon's plugin name.

      Parameters:
      addon - the addon plugin requesting the folder (must not be null)
      Throws:
      NullPointerException - if addon is null
    • exportAddonConfigs

      public int exportAddonConfigs(org.bukkit.plugin.Plugin addon)
      Exports the addon's default configuration files if they do not already exist.

      Existing files are preserved.

      Parameters:
      addon - the addon plugin whose configs should be exported (must not be null)
      Returns:
      the number of files exported (0 if none)
      Throws:
      NullPointerException - if addon is null
    • exportAddonConfigs

      public int exportAddonConfigs(org.bukkit.plugin.Plugin addon, boolean replaceIfExists)
      Exports the addon's default configuration files with optional replacement.
      Parameters:
      addon - the addon plugin whose configs should be exported (must not be null)
      replaceIfExists - if true, existing files will be overwritten
      Returns:
      the number of files exported (0 if none)
      Throws:
      NullPointerException - if addon is null