> For the complete documentation index, see [llms.txt](https://wiki.helpch.at/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.helpch.at/helpchat-plugins/chatchat/api/events.md).

# Events

Events fired by ChatChat and the changes listeners can make.

## Public chat

`ChatChatEvent` is fired while a public message is processed and before it is delivered. It is cancellable. A listener can inspect or change the sender, channel, format, message, and recipient set.

## Private messages

`PMSendEvent` is fired before a local private message is sent. It is cancellable and exposes the sender, recipient, message, reply state, and sender and recipient formats.

`CrossServerPMSendEvent` is fired after ChatChat finds a remote recipient and before it forwards a cross-server private message. It is cancellable and exposes the recipient UUID and name, reply state, message, and sender, recipient, and social-spy formats.

## Mentions

`MentionEvent` is the base event for a mention processed in a public message. It is cancellable and exposes the sender, target, channel, and whether the mention sound should play.

* `PersonalMentionEvent` is fired for a direct player mention.
* `ChannelMentionEvent` is fired for a channel-wide mention such as `@here`, `@everyone`, or `@channel`.

## Example

Cancel a public message from a selected player:

```java
import at.helpch.chatchat.api.event.ChatChatEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public final class ChatListener implements Listener {
    @EventHandler(ignoreCancelled = true)
    public void onChatChat(final ChatChatEvent event) {
        if (event.user().player().map(player -> player.getName().equals("Example")).orElse(false)) {
            event.setCancelled(true);
        }
    }
}
```

`ChatChatEvent` follows Bukkit's synchronous or asynchronous event contract based on the chat processing context. Listeners should handle it on the appropriate thread.


---

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wiki.helpch.at/helpchat-plugins/chatchat/api/events.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
