# Developer API

## Setting Up

### If you have not puchased GrantX

Go to <https://github.com/Demeng7215/GrantX-API> and import the latest release (or the release you want) into your IDE or build configuration.

### If you purchased GrantX

Simply import the actual plugin (GrantX's JAR) into your IDE or build configuration.

{% hint style="warning" %}
You cannot shade the API or compile it into your own JAR. The API is already provided in the actual plugin.
{% endhint %}

## Usage

### Events

There are currently 3 events in the API:

* [dev.demeng.grantx.api.event.GrantActivateEvent](https://github.com/Demeng7215/GrantX-API/blob/master/src/main/java/dev/demeng/grantx/api/event/GrantActivateEvent.java) - Called after a grant is confirmed.
* [dev.demeng.grantx.api.event.GrantExpireEvent](https://github.com/Demeng7215/GrantX-API/blob/master/src/main/java/dev/demeng/grantx/api/event/GrantExpireEvent.java) - Called after a grant expires.
* [dev.demeng.grantx.api.event.GrantRevokeEvent](https://github.com/Demeng7215/GrantX-API/blob/master/src/main/java/dev/demeng/grantx/api/event/GrantRevokeEvent.java) - Called after a grant revocation is confirmed.<br>

You can use these as you would with vanilla Bukkit events, as such:

```
public class MyAddonEvent implements Listener {
  @EventHandler
  public void onGrantActivate(GrantActivateEvent e) {
    // Code here
  }
}
```

As with normal events, you need to register the event in your onEnable method.

```
Bukkit.getPluginManager().registerListeners(new MyAddonEvent(), this);
```

Each of these events are called with a [dev.demeng.grantx.api.Grant](https://github.com/Demeng7215/GrantX-API/blob/master/src/main/java/dev/demeng/grantx/api/Grant.java) object, which contains information about the grant that has been activated, expired, or revoked. Access this object by using #getGrant(). Methods in this class are documented ([click here](https://github.com/Demeng7215/GrantX-API/blob/master/src/main/java/dev/demeng/grantx/api/Grant.java)).


---

# 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.demeng.dev/grantx/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.
