> For the complete documentation index, see [llms.txt](https://mossuh.gitbook.io/projects/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mossuh.gitbook.io/projects/plugins/moboosters/api.md).

# API

## Main Class:&#x20;

```
BoostersAPI
```

## Events

### ActivatePermanentBoosterEvent

Called when a permanent booster is activated.

```java
// This event is cancellable

@EventHandler
public boosterEvent(ActivatePermanentBoosterEvent event) {
    Booster booster = event.getBooster();
    event.setBooster(Booster booster);
    
    PermanentBoost boost = event.getBoost();
    event.setBoost(PermanentBoost boost);
    
    PermanentBoost oldBoost = event.getOldBoost();
}
```

### ActivateTemporaryBoosterEvent

Called when a temporary booster is activated.

```java
// This event is cancellable

@EventHandler
public boosterEvent(ActivateTemporaryBoosterEvent event) {
    Booster booster = event.getBooster();
    event.setBooster(Booster booster);
    
    TemporaryBoost boost = event.getBoost();
    event.setBoost(TemporaryBoost boost);
    
    TemporaryBoost oldBoost = event.getOldBoost();
}
```

### ClaimItemBoosterEvent

Called when a booster item is claimed.

```java
// This event is cancellable

@EventHandler
public boosterEvent(ClaimItemBoosterEvent event) {
    Player player = event.getPlayer();
    BoosterItem item = event.getBoosterItem();
}
```

### EndsTemporaryBoosterEvent

Called when a temporary booster ends.

```java
// This event is not cancellable

@EventHandler
public boosterEvent(EndsTemporaryBoosterEvent event) {
    Booster booster = event.getBooster()
    TemporaryBoost boost = event.getBoost();
}
```

### IncreaseBoostBoosterEvent

Called when a booster boost increases.

```java
// This event is cancellable

@EventHandler
public boosterEvent(IncreaseBoostBoosterEvent event) {
    DurationType duration = event.getDurationType();
    Booster booster = event.getBooster();
    double boost = event.getBoost();
    
    event.setBooster(Booster event);
    event.setBoost(double boost);
}
```

### IncreaseTimeBoosterEvent

Called when booster time increases.

```java
// This event is cancellable

@EventHandler
public boosterEvent(IncreaseTimeBoosterEvent event) {
    Booster booster = event.getBooster();
    long time = event.getTime();
    
    event.setBooster(Booster event);
    event.setTime(long durationInSeconds);
}
```

### RemoveBoostBoosterEvent

Called when a booster boost is removed.

```java
// This event is cancellable

@EventHandler
public boosterEvent(RemoveBoostBoosterEvent event) {
    DurationType duration = event.getDurationType();
    Booster booster = event.getBooster();
    double boost = event.getBoost();
    
    event.setBooster(Booster event);
    event.setBoost(double boost);
}
```

### RemoveTimeBoosterEvent

Called when booster time is removed.

```java
// This event is cancellable

@EventHandler
public boosterEvent(RemoveTimeBoosterEvent event) {
    Booster booster = event.getBooster();
    long time = event.getTime();
    
    event.setBooster(Booster event);
    event.setTime(long durationInSeconds);
}
```

### PlayerApplyBoostEvent

Called when a booster boost is applied.

{% hint style="warning" %}
This event only will be called when the Applicator is a `EventApplicatorHook`.
{% endhint %}

```java
// This event is cancellable

@EventHandler
public boosterEvent(PlayerApplyBoostEvent event) {
    UUID uuid = event.getUUID(); 
    double boost = event.getBoost();
    ApplicatorType applicator = event.getApplicatorType();
    String boosted = event.getBooster()
    
    event.setBoost(double boost);
    event.addBoost(double boost);
}
```

## Your own Applicator

### Create your Applicator

{% hint style="warning" %}
This example is of a Booster that is already registered with MoBoosters.
{% endhint %}

```java
/*
 * Create a class where you will define the events in which the boost will be applied.
 * This class must extend EventApplicatorModule and implement Listener (for your events).
 */
public class MinecraftBoost extends EventApplicatorHook implements Listener {

    /*
     * Create a constructor that calls the super constructor with the
     * ApplicatorType to which your events will belong.
     *
     * MoBoosters provides several default ApplicatorTypes that you can use.
     * However, you can also create your own custom ApplicatorType by using:
     *
     *     ApplicatorType.convert("APPLICATOR_NAME")
     *
     * The name must not contain spaces.
     *
     * NOTE:
     * - The ApplicatorType defines the system or category where the booster is applied.
     * - The "boosted" parameter defines the specific value affected by the booster.
     *
     * You can use multiple boosted values with the same ApplicatorType.
     */
    public MinecraftBoost() {
        super(ApplicatorType.MINECRAFT);
        // super(ApplicatorType.convert("MINECRAFT"));
    }

    @EventHandler
    public void miningXP(BlockBreakEvent event) {
        String name = event.getBlock().getType().name();
        if (!name.endsWith("_ORE")) return;

        Player player = event.getPlayer();

        /*
         * To obtain a boost, use:
         *
         *     resolveBoost(UUID uuid, String identifier, String boosted)
         *
         * This method allows you to retrieve the boost for a specific identifier.
         *
         * For example, if you have boosters with the identifiers "PetsBoost"
         * and "ArmorBoost", in addition to the default identifier, you can
         * retrieve the boost from only one of them:
         *
         *     resolveBoost(player.getUniqueId(), "PetsBoost", "mining_xp");
         *
         * If you want to retrieve the total boost from all identifiers,
         * simply pass null as the identifier:
         *
         *     resolveBoost(player.getUniqueId(), null, "mining_xp");
         *
         * IMPORTANT:
         * resolveBoost() returns 0 when no applicable booster is found,
         * or when the PlayerApplyBoostEvent is cancelled.
         *
         * Therefore, we check whether the resulting boost is greater than 0
         * before applying it.
         */
        double boost = resolveBoost(player.getUniqueId(), null, "mining_xp");
        if (boost <= 0) return;

        /*
         * This is where the boost is actually applied.
         *
         * The resolved boost represents only the additional boost amount;
         * the base value is not included.
         *
         * Therefore, when using a setter method instead of an "add" method,
         * you must include the base value (+1) in the calculation.
         *
         * Example:
         *   boost = 0.50 -> 50% additional XP
         *   boost + 1 (base) = 1.50 -> 150% of the original XP
         *              -> 100% (base) + 50% (extra XP)
         */
        event.setExpToDrop((int) (event.getExpToDrop() * (boost + 1)));
    }
}
```

### Register the Applicator

```java
/*
 * To register your custom applicator, use the registerApplicator() method
 * when your plugin is enabled.
 *
 * This method automatically registers the applicator and its event listeners,
 * so you do not need to register the events separately.
 *
 * The instance of your JavaPlugin is required to register the applicator
 * and its events.
 *
 * Method:
 *
 *     BoostersAPI.registerApplicator(JavaPlugin plugin, ApplicatorHook... hooks);
 *
 * The first parameter is the instance of your plugin, while the second parameter
 * is one or more applicator modules that you want to register.
 */

@Override
public void onEnable() {

    /*
     * Register your custom applicator.
     *
     * MinecraftBoost is the custom EventApplicatorHook created previously.
     * Its events will be registered automatically by MoBoosters.
     */
    BoostersAPI.registerApplicator(this, new MinecraftBoost());
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://mossuh.gitbook.io/projects/plugins/moboosters/api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
