Skip to content

Developer‐API

Keine Secrets edited this page Feb 5, 2025 · 1 revision

Developer API

SimpleLootbox has a developer API that allows you to create custom lootboxes and rewards programmatically. Below are the details of the main API methods available:

LootboxesAPI

The LootboxesAPI class is the main entry point for interacting with the plugin's API. It provides access to various configurations and managers.

Methods

  • static LootboxesAPI instance() - Gets the current instance of LootboxesAPI.
  • DatabaseConfiguration databaseConfiguration() - Gets the database configuration.
  • MessagesConfiguration messagesConfiguration() - Gets the messages configuration.
  • GeneralConfiguration generalConfiguration() - Gets the general configuration.
  • RarityConfiguration rarityConfiguration() - Gets the rarity configuration.
  • DatabaseManager databaseManager() - Gets the database manager.
  • LiveDropManager liveDropManager() - Gets the live drop manager.

Utility

The Utility class provides utility methods for common operations.

Methods

  • static boolean inRange(Number value, Number min, Number max) - Check if a value is in a range.

DatabaseManager

The DatabaseManager interface provides methods to manage the database.

Methods

  • LootboxManager lootboxManager() - Gets the lootbox manager.

Example Usage

Here is an example of how to use the API to create a lootbox:

LootboxesAPI api = LootboxesAPI.instance();
DatabaseConfiguration dbConfig = api.databaseConfiguration();
MessagesConfiguration msgConfig = api.messagesConfiguration();
GeneralConfiguration genConfig = api.generalConfiguration();
RarityConfiguration rarConfig = api.rarityConfiguration();
DatabaseManager dbManager = api.databaseManager();
LiveDropManager liveDropManager = api.liveDropManager();

// Create a new lootbox
Lootbox newLootbox = new Lootbox("exampleLootbox", Component.text("Example Lootbox"), Material.CHEST, new ArrayList<>());
dbManager.lootboxManager().save(newLootbox);

How to import

To import the SimpleLootbox API into your project, add the following dependency to your build.gradle file:

repositories {
    maven { url = "https://jitpack.io/" }
}
dependencies {
    implementation 'com.github.whynotmax.SimpleLootbox:api:-SNAPSHOT'
}

Clone this wiki locally