API Reference
API Reference
Section titled “API Reference”Technical reference for plugin developers. Provides programmatic access to the Lootbag system through the unified CoreAPI facade.
:::info Module
The CoreAPI is provided by kyuubisoft-core.jar. Ensure the Core mod is loaded before calling any API methods.
:::
Getting the API Instance
Section titled “Getting the API Instance”import com.kyuubisoft.core.api.CoreAPI;
// Availability check (recommended)if (CoreAPI.isAvailable()) { CoreAPI api = CoreAPI.getInstance(); // ...}
// Or direct (returns null if Core is not loaded)CoreAPI api = CoreAPI.getInstance();if (api == null) { // Core plugin not loaded return;}Lootbag Methods
Section titled “Lootbag Methods”| Method | Return Type | Description |
|---|---|---|
getLootbagDefinition(String id) | LootbagDefinition | Get a lootbag definition by ID, or null if not found |
lootbagExists(String id) | boolean | Check if a lootbag with the given ID exists |
getAllLootbags() | Map<String, LootbagDefinition> | Get all registered lootbag definitions |
grantLootbag(Player, String lootbagId) | boolean | Grant a lootbag to the player (resolves items and adds to inventory) |
LootbagDefinition Model
Section titled “LootbagDefinition Model”The LootbagDefinition class provides information about a lootbag template. Three modes are supported:
- Fixed Items — A static list of items
- Random Pool — Random selection from a weighted pool
- Hybrid — Guaranteed items plus random picks from a pool
import com.kyuubisoft.core.lootbag.LootbagDefinition;
// Key gettersdefinition.getId(); // String: Lootbag IDdefinition.getName(); // String: Display name (default: "Lootbag")definition.getDescription(); // String: Description textdefinition.getIcon(); // String: Icon item ID (default: "Chest_Wood")definition.getRarity(); // String: "common", "uncommon", "rare", "epic", "legendary"definition.getRarityColor(); // String: Hex color for the rarity tier
// Type checksdefinition.isFixedItems(); // Fixed item list onlydefinition.isRandomPool(); // Random pool onlydefinition.isHybrid(); // Guaranteed items + random pool
// Item datadefinition.getItems(); // List<LootItem>: Fixed itemsdefinition.getGuaranteedItems(); // List<LootItem>: Guaranteed items (hybrid mode)definition.getPool(); // List<PoolItem>: Weighted random pooldefinition.getPickCount(); // int: Number of random picks from pooldefinition.isAllowDuplicates(); // boolean: Allow duplicate picksUsage Examples
Section titled “Usage Examples”Check Lootbag Existence
Section titled “Check Lootbag Existence”CoreAPI api = CoreAPI.getInstance();
if (api.lootbagExists("rare_lootbag")) { LOGGER.info("Lootbag 'rare_lootbag' is registered");} else { LOGGER.warning("Lootbag 'rare_lootbag' not found");}Get Lootbag Details
Section titled “Get Lootbag Details”CoreAPI api = CoreAPI.getInstance();
LootbagDefinition def = api.getLootbagDefinition("starter_pack");if (def != null) { LOGGER.info("Lootbag: " + def.getName()); LOGGER.info("Rarity: " + def.getRarity()); LOGGER.info("Icon: " + def.getIcon());
if (def.isFixedItems()) { LOGGER.info("Contains " + def.getItems().size() + " fixed items"); } else if (def.isRandomPool()) { LOGGER.info("Random pool with " + def.getPickCount() + " picks"); } else if (def.isHybrid()) { LOGGER.info("Hybrid: " + def.getGuaranteedItems().size() + " guaranteed + " + def.getPickCount() + " random picks"); }}Grant a Lootbag to a Player
Section titled “Grant a Lootbag to a Player”CoreAPI api = CoreAPI.getInstance();
boolean success = api.grantLootbag(player, "rare_lootbag");if (success) { player.sendMessage("You received a Rare Lootbag!");} else { player.sendMessage("Could not grant lootbag (inventory full or lootbag not found).");}List All Available Lootbags
Section titled “List All Available Lootbags”CoreAPI api = CoreAPI.getInstance();
Map<String, LootbagDefinition> allBags = api.getAllLootbags();for (Map.Entry<String, LootbagDefinition> entry : allBags.entrySet()) { String id = entry.getKey(); LootbagDefinition def = entry.getValue(); LOGGER.info(id + " - " + def.getName() + " (" + def.getRarity() + ")");}Use Lootbag as a Reward in Custom Logic
Section titled “Use Lootbag as a Reward in Custom Logic”CoreAPI api = CoreAPI.getInstance();
// Example: Grant a lootbag when a player completes a custom challengepublic void onChallengeComplete(Player player, String challengeId) { String lootbagId = challengeRewards.get(challengeId); if (lootbagId != null && api.lootbagExists(lootbagId)) { api.grantLootbag(player, lootbagId); }}Thread Safety
Section titled “Thread Safety”getLootbagDefinition,lootbagExists, andgetAllLootbagsare read-only lookups and can be called from any threadgrantLootbaginvolves inventory operations and should ideally be called from the main thread or withinworld.execute()
Java Package Structure
Section titled “Java Package Structure”com.kyuubisoft.core.lootbag/├── LootbagService.java - Lootbag loading, resolution, and granting├── LootbagDefinition.java - Lootbag template model (with LootItem, PoolItem)├── LootbagConfig.java - Lootbag configuration loading└── LootbagAdminService.java - Admin CRUD operations