> For the complete documentation index, see [llms.txt](https://docs.walecloud.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.walecloud.com/api-documentation/listener.md).

# Listener

### How do I create a listener?

```java
public class YourListenerName implements EventListener {

    // The @Eventable annoation must be used
    @Eventable
    public void handle(ChannelMessageEvent event) {
        // Handle the event
    }
}
```

### How do I register a listener?

We recommend registering the listeners when loading the plugins.

{% hint style="warning" %}
**Attention**: Your plugin **must** be loaded **after** the **Wale plugin** if you are using events or the API when loading your plugin. Here is an example for the p*lugin.ym*l and *bungee.yml*

```yaml
# spigot.yml or bungee.yml (same method)
depend:
  - Wale
```

{% endhint %}

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

```java
public class Test extends JavaPlugin {
    
    @Override
    public void onEnable() {
        EventDispatcher.addListener(new ListenerWale());
    }
}
```

{% endtab %}

{% tab title="BungeeCord" %}

```java
public class Test extends Plugin {
    
    @Override
    public void onEnable() {
        EventDispatcher.addListener(new YourListenerName());
    }
}
```

{% endtab %}
{% endtabs %}


---

# 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 dynamically by asking a question.

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

```
GET https://docs.walecloud.com/api-documentation/listener.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
