Interface View

All Known Implementing Classes:
AnvilInputView, ChestView

public interface View
A server-controlled inventory screen rendered entirely at the proxy.

Implementations should be stateless and reusable across players: per-player state lives in the ViewContents passed to onOpen(ViewContents) and the ViewContext attached to it. Prefer building views with VGui.chest(int) / ViewBuilder unless you need a class.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Whether client click transactions are cancelled so items can never be taken out of (or put into) the GUI.
    default long
    Minimum milliseconds between processed non-drag clicks per player.
    default void
    onAnvilInput(String text, ViewContents contents)
    Called when the player types in an anvil rename field (only for ViewType.ANVIL views), once per keystroke with the full current text.
    default void
    Called for every click inside the window (GUI half and player-inventory half).
    default void
    onClose(com.velocitypowered.api.proxy.Player player, CloseReason reason, ViewContext context)
    Called exactly once when the view stops being shown, with the reason and the per-open context.
    default void
    onOpen(ViewContents contents)
    Called right after the window opens (and again if the view is re-opened via back-navigation).
    net.kyori.adventure.text.Component
    Title shown on the container.
    The window type (determines slot count and shape).
  • Method Details

    • title

      net.kyori.adventure.text.Component title()
      Title shown on the container.
    • type

      ViewType type()
      The window type (determines slot count and shape).
    • onOpen

      default void onOpen(ViewContents contents)
      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.
    • onClick

      default void onClick(ClickContext click)
      Called for every click inside the window (GUI half and player-inventory half). Item-level handlers registered via ViewItem.clickable(ItemStack, Consumer) run before this.
    • onClose

      default void onClose(com.velocitypowered.api.proxy.Player player, CloseReason reason, ViewContext context)
      Called exactly once when the view stops being shown, with the reason and the per-open context.
    • onAnvilInput

      default void onAnvilInput(String text, ViewContents contents)
      Called when the player types in an anvil rename field (only for ViewType.ANVIL views), once per keystroke with the full current text.
    • cancelClientTransactions

      default boolean cancelClientTransactions()
      Whether client click transactions are cancelled so items can never be taken out of (or put into) the GUI. Default true; return false only if you know what you are doing. The proxy cannot apply inventory changes for you.
    • clickCooldownMillis

      default long clickCooldownMillis()
      Minimum milliseconds between processed non-drag clicks per player. Clicks arriving faster are cancelled and corrected without invoking handlers. Drag phases are never throttled so a configured cooldown cannot break quick-craft sequences. Return 0 to disable (the default).