Class AnvilInputView

java.lang.Object
me.agent.vgui.api.input.AnvilInputView
All Implemented Interfaces:
View

public final class AnvilInputView extends Object implements View
A text-input prompt rendered as an anvil window: the player types in the rename field and clicks the output slot to confirm.
AnvilInputView.builder()
    .title(Component.text("Choose a nickname"))
    .initialText("Steve")
    .onConfirm((player, text) -> setNickname(player, text))
    .open(player);

For a future-based one-liner use VGui.prompt(Player, Component).

  • Field Details

    • TEXT

      public static final ViewKey<String> TEXT
      Context key holding the text currently typed into the rename field.
  • Method Details

    • builder

      public static AnvilInputView.Builder builder()
      Starts building an anvil input prompt.
    • title

      public net.kyori.adventure.text.Component title()
      Description copied from interface: View
      Title shown on the container.
      Specified by:
      title in interface View
    • type

      public ViewType type()
      Description copied from interface: View
      The window type (determines slot count and shape).
      Specified by:
      type in interface View
    • onOpen

      public void onOpen(ViewContents contents)
      Description copied from interface: View
      Called right after the window opens (and again if the view is re-opened via back-navigation). Populate contents here; mutations made inside this callback are sent as one batch.
      Specified by:
      onOpen in interface View
    • onAnvilInput

      public void onAnvilInput(String text, ViewContents contents)
      Description copied from interface: View
      Called when the player types in an anvil rename field (only for ViewType.ANVIL views), once per keystroke with the full current text.
      Specified by:
      onAnvilInput in interface View
    • onClose

      public void onClose(com.velocitypowered.api.proxy.Player player, CloseReason reason, ViewContext context)
      Description copied from interface: View
      Called exactly once when the view stops being shown, with the reason and the per-open context.
      Specified by:
      onClose in interface View