# Developer API

### 1) Add the Dependency

Don't forget to change always the version!

<div align="left"><figure><img src="https://img.shields.io/maven-metadata/v.svg?label=CreditsAPI&#x26;metadataUrl=https://repo.mongenscave.com/releases/com/mongenscave/mc-CreditsAPI/maven-metadata.xml" alt=""><figcaption></figcaption></figure></div>

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

<pre class="language-xml" data-full-width="true"><code class="lang-xml"><strong>&#x3C;repository>
</strong>  &#x3C;id>MonGens-Cave&#x3C;/id>
  &#x3C;url>https://repo.mongenscave.com/releases&#x3C;repository>&#x3C;/url>
&#x3C;/repository>

&#x3C;dependency>
  &#x3C;groupId>com.mongenscave&#x3C;/groupId>
  &#x3C;artifactId>mc-Treasure&#x3C;/artifactId>
  &#x3C;version>[VERSION]&#x3C;/version>
&#x3C;/dependency>
</code></pre>

{% endtab %}

{% tab title="Gradle" %}

```groovy
maven { url "https://repo.mongenscave.com/releases" }

implementation "com.mongenscave:mc-Treasure:[VERSION]"
```

{% endtab %}
{% endtabs %}

### 2) Add mc-Credits to plugin.yml

{% tabs %}
{% tab title="as depend" %}

```yaml
depend:
  - mc-Treasure
```

{% endtab %}

{% tab title="as softdepend" %}

```yaml
softdepend:
  - mc-Treasure
```

{% endtab %}
{% endtabs %}

### 3) Example how to use the TreasureAPI

```java
import com.mongenscave.mctreasure.api.McTreasureAPI;
import com.mongenscave.mctreasure.api.model.ITreasureChest;

public class TreasureExample {
    
    public void handleTreasure(Player player, String treasureId) {
        // 🔍 Get treasure by ID
        ITreasureChest treasure = McTreasureAPI.getTreasure(treasureId);
        
        if (treasure == null) {
            player.sendMessage("§c❌ Treasure not found!");
            return;
        }
        
        // ✅ Check if player can open
        if (McTreasureAPI.canPlayerOpen(player, treasure)) {
            player.sendMessage("§a🎉 Opening treasure: " + treasure.getName());
        } else {
            player.sendMessage("§c🔒 You cannot open this treasure!");
        }
    }
    
    // 🗺️ Find treasures near location
    public List<ITreasureChest> findNearbyTreasures(Location center, double radius) {
        return McTreasureAPI.getAllTreasures().stream()
            .filter(treasure -> treasure.getLocation() != null)
            .filter(treasure -> treasure.getLocation().distance(center) <= radius)
            .collect(Collectors.toList());
    }
}
```


---

# 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.mongenscave.com/free-products/treasure/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.
