-
Notifications
You must be signed in to change notification settings - Fork 0
Anvil Input Menu
virtualWinter edited this page Aug 30, 2025
·
2 revisions
The AnvilInputMenu is a specialized menu that uses an anvil interface to get text input from a player. The player can type text by renaming the input item, and the result is captured when they click the output slot.
To get text input from a player, you can create an AnvilInputMenu and provide a callback to handle the submitted text.
AnvilInputMenu.create(player, "Enter your name", name -> {
player.sendMessage("Your name is: " + name);
}).open(player);-
AnvilInputMenu.create(Player player, String title, Consumer<String> inputHandler): Creates a simple anvil input menu with only an input handler. -
AnvilInputMenu.create(Player player, String title, Consumer<String> inputHandler, Consumer<Player> cancelHandler): Creates an anvil input menu with both input and cancel handlers. -
AnvilInputMenu.create(Player player, String title, ItemStack inputItem, Consumer<String> inputHandler): Creates an anvil input menu with a custom input item.
import club.catmc.utils.menu.AnvilInputMenu;
import org.bukkit.entity.Player;
public class MenuExamples {
public void openAnvilInputMenu(Player player) {
AnvilInputMenu.create(
player,
"Enter your name",
name -> {
player.sendMessage("Your name is: " + name);
},
p -> {
p.sendMessage("You cancelled the input.");
}
).open(player);
}
}© 2025 CatMC Network. This project is licensed under the ISC License.