> For the complete documentation index, see [llms.txt](https://wiki.ericlmao.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.ericlmao.com/projects/alumina/inputlistener.md).

# InputListener

This utility is a great way to capture a player's next chat message and execute logic based on it. This type of feature is typically used for "confirmation" messages where the user will have to say a certain word or message to confirm or cancel a certain action.

<details>

<summary>Example</summary>

```java
UUID uuid = UUID.randomUUID(); // should be a player's uuid!
InputListener.listen(uuid, event -> {
    if (!(event.originalMessage() instanceof TextComponent text)) return;

    String message = text.content();

    Player player = event.getPlayer();
            
    if (message.equalsIgnoreCase("hi")) {
        player.sendMessage(Component.text("Hello!"));
    }
});
```

</details>
