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.
Example
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!"));
}
});Last updated