# Developer API

## Installation

{% tabs %}
{% tab title="Maven" %}

```xml
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

<dependency>
    <groupId>com.github.cerus-mc</groupId>
    <artifactId>map-ads</artifactId>
    <version>Tag</version>
</dependency>
```

{% endtab %}

{% tab title="Gradle" %}

```groovy
allprojects {
    repositories {
        ...
	maven { url 'https://jitpack.io' }
    }
}

dependencies {
        implementation 'com.github.cerus-mc:map-ads:Tag'
}
```

{% endtab %}
{% endtabs %}

## Events

Map-Ads currently has two events: `AdvertCreateEvent` and `AdvertReviewEvent`. Both events can be cancelled.

The `AdvertCreateEvent` is called when a player tries to create an ad.

The `AdvertReviewEvent` is called when a staff member tries to review an ad.

## Transitions

Map-Ads allows you to create your own transitions. Just make a new class and implement the `Transition` interface:

```java
public class MyTransition implements Transition {

    @Override
    public void makeTransition(final @NotNull MapScreen screen, @Nullable final MapImage oldImg, final @NotNull MapImage newImg, final @NotNull TransitionRecorder recorder) {
        recorder.start(screen);
        
        // Make your transition here
        screen.getGraphics().fillComplete(ColorCache.rgbToMap(255, 255, 255));
        recorder.record(screen);
        screen.getGraphics().fillComplete(ColorCache.rgbToMap(0, 0, 0));
        recorder.record(screen);
        
        recorder.end(screen);
    
}
```

After that you can register the transition by calling `TransitionRegistry.register("my_transition", new MyTransition());`.

I encourage you to take a look at the [existing transitions](https://github.com/cerus-mc/map-ads/tree/main/plugin/src/main/java/dev/cerus/mapads/image/transition) to see how they work.

## Services

You can get an instance of the following services using the Bukkit service manager (`Bukkit.getServicesManager().getRegistration(ServiceClass.class).getProvider()` - You'll have to replace ServiceClass.class with the class of the service):

* AdvertStorage
* AdScreenStorage
* ImageStorage
* DefaultImageController
* ImageConverter
* ImageRetriever


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cerus.dev/map-ads/developer-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
