Class HeirloomAPI
java.lang.Object
ke.ric.api.HeirloomAPI
Main API entry point for Heirloom addons.
Addons should get this instance via:
HeirloomAPI api = HeirloomAPI.getInstance();Or during plugin enable:
Plugin heirloom = getServer().getPluginManager().getPlugin("Heirloom");
if (heirloom != null && heirloom.isEnabled()) {
HeirloomAPI api = HeirloomAPI.getInstance();
// Register your addon
api.registerAddon(this, new MyAddon());
}
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionGet the owner-scoped native advancement registration API.aging()Get the owner-scoped staged aging registration API.org.bukkit.inventory.ItemStackcreateItem(String itemId) Create a custom item by ID.org.bukkit.inventory.ItemStackcreateItem(String itemId, int amount) Create a custom item with a specific amount.crops()Get the crop registration API.foodFacts(org.bukkit.inventory.ItemStack item) Read immutable, versioned dietary provenance from an item stack.foodFactsV2(org.bukkit.inventory.ItemStack item) Read source-qualified ingredient and dietary evidence without modifying the item.Get a registered addon by ID.getCustomItemId(org.bukkit.inventory.ItemStack item) Get the custom item ID from an ItemStack.static HeirloomAPIGet the HeirloomAPI instance.guides()Get the owner-scoped immutable addon guide registration API.booleanisAddonRegistered(String addonId) Check if an addon is registered.booleanisCustomItem(org.bukkit.inventory.ItemStack item) Check if an ItemStack is a Heirloom custom item.booleanisReady()Check whether Heirloom is enabled and registrations/lookups are ready for use.items()Get the item registration API.Get the dietary property registration API.recipes()Get the recipe registration API.voidPublish registry changes to every read-only content view after an external transaction has committed.voidregisterAddon(String addonId, String version, org.bukkit.plugin.Plugin owningPlugin, Consumer<HeirloomAPI> registrationCallback) Register an addon with Heirloom using a callback.voidregisterAddon(String addonId, String version, org.bukkit.plugin.Plugin owningPlugin, Consumer<HeirloomAPI> registrationCallback, Runnable reloadCallback) Register an addon with Heirloom using callbacks for enable and reload.voidregisterAddon(String addonId, String version, org.bukkit.plugin.Plugin owningPlugin, Consumer<HeirloomAPI> registrationCallback, Runnable reloadCallback, Runnable disableCallback) Callback variant including owner cleanup when the addon is removed independently of its plugin.voidregisterAddon(org.bukkit.plugin.Plugin owningPlugin, HeirloomAddon addon) Register an addon with Heirloom (legacy method - for backwards compatibility).voidregisterReloadState(String addonId, Supplier<Runnable> snapshot) Include a small addon-owned rule snapshot in the existing registration transaction.voidReload all registered addons and refresh recipe browser state.Additive seed packet, grass-drop, and chest-loot registration for addons.Snapshot every registry exposed to addon callbacks.voidunregisterAddon(String addonId) Unregister an addon.voidwithAddonRegistrationContext(String addonId, Runnable registration) Run an explicitly requested addon refresh through all existing owner-scoped registries.
-
Method Details
-
registerReloadState
-
getInstance
Get the HeirloomAPI instance.- Returns:
- The singleton
HeirloomAPIinstance (checkisReady()before invoking runtime helpers)
-
isReady
public boolean isReady()Check whether Heirloom is enabled and registrations/lookups are ready for use.- Returns:
truewhen Heirloom has initialized its managers and is enabled
-
foodFacts
Read immutable, versioned dietary provenance from an item stack. -
foodFactsV2
Read source-qualified ingredient and dietary evidence without modifying the item. -
registerAddon
public void registerAddon(String addonId, String version, org.bukkit.plugin.Plugin owningPlugin, Consumer<HeirloomAPI> registrationCallback) Register an addon with Heirloom using a callback. This method avoids classloader issues by not requiring the addon to implement HeirloomAddon.- Parameters:
addonId- Unique addon identifier (e.g., "distillery")version- Addon version stringowningPlugin- The plugin that owns the addonregistrationCallback- Called to register addon content (receives HeirloomAPI)
-
registerAddon
public void registerAddon(String addonId, String version, org.bukkit.plugin.Plugin owningPlugin, Consumer<HeirloomAPI> registrationCallback, Runnable reloadCallback) Register an addon with Heirloom using callbacks for enable and reload.- Parameters:
addonId- Unique addon identifierversion- Addon version stringowningPlugin- The plugin that owns the addonregistrationCallback- Called to register addon contentreloadCallback- Called when Heirloom reloads
-
registerAddon
-
reloadAddons
public void reloadAddons()Reload all registered addons and refresh recipe browser state. External callers retain the historical refresh behavior. -
snapshotReloadRegistrations
Snapshot every registry exposed to addon callbacks. The snapshot must be taken before core managers reload because those reloads also replace main indexes containing addon registrations. -
registerAddon
Register an addon with Heirloom (legacy method - for backwards compatibility). NOTE: This requires the addon class to implement HeirloomAddon, which can cause classloader issues. Prefer registerAddon(id, version, plugin, callback) instead.- Parameters:
owningPlugin- The plugin that owns the addonaddon- The addon implementation
-
unregisterAddon
Unregister an addon. -
refreshContentViewsAfterCommit
public void refreshContentViewsAfterCommit()Publish registry changes to every read-only content view after an external transaction has committed. Refresh failures cannot roll back an already committed registry; each view keeps its prior coherent snapshot instead. -
withAddonRegistrationContext
-
getAddon
Get a registered addon by ID. -
isAddonRegistered
Check if an addon is registered. -
items
Get the item registration API. Use this to register custom items programmatically. -
crops
Get the crop registration API. Use this to register custom crops programmatically. -
seedAcquisition
Additive seed packet, grass-drop, and chest-loot registration for addons. -
properties
Get the dietary property registration API. Use this to register custom dietary properties. -
recipes
Get the recipe registration API. Use this to register custom recipes for your addon. -
aging
Get the owner-scoped staged aging registration API. -
advancements
Get the owner-scoped native advancement registration API. -
guides
Get the owner-scoped immutable addon guide registration API. -
createItem
Create a custom item by ID.- Parameters:
itemId- The custom item ID- Returns:
- The ItemStack, or null if not found
-
createItem
Create a custom item with a specific amount. -
isCustomItem
public boolean isCustomItem(org.bukkit.inventory.ItemStack item) Check if an ItemStack is a Heirloom custom item. -
getCustomItemId
Get the custom item ID from an ItemStack.
-