# Event Subscriber

## Example

Example code:

```java
HCore.registerEvent(PlayerJoinEvent.class) //registers PlayerJoinEvent
        .priority(EventPriority.HIGHEST) //sets priority as HIGHEST
        .expire(10, TimeUnit.HOURS) //this event will expire in 10 hours
        .filter(event -> event.getPlayer().hasPermission("example.permission")) //adds filter to work this listener
        .limit(10) //after 10 usage, this listener will unregister (Events that fail the filter do not affects the limit!)
        .consume(event -> { //when the event is triggered, consume will work
            event.getPlayer().sendMessage("test");
            event.getPlayer().sendMessage("test");
            event.getPlayer().sendMessage("test");
        });
```


---

# 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://hcore.gitbook.io/wiki/others/event-subscriber.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.
