# 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: 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.walecloud.com/api-documentation/listener.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.
