Package dev.cwhead.GravesX.api.addon
Class AddonAPI
java.lang.Object
dev.cwhead.GravesX.api.addon.AddonAPI
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.
-
Constructor Details
-
AddonAPI
Creates a newAddonAPI
bound to the given Graves plugin.- Parameters:
plugin
- the owning Graves plugin (must not benull
)- Throws:
NullPointerException
- ifplugin
isnull
-
-
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 benull
)- Throws:
NullPointerException
- ifaddon
isnull
-
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 benull
)- Returns:
- the number of files exported (0 if none)
- Throws:
NullPointerException
- ifaddon
isnull
-
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 benull
)replaceIfExists
- iftrue
, existing files will be overwritten- Returns:
- the number of files exported (0 if none)
- Throws:
NullPointerException
- ifaddon
isnull
-