Class ViewItem

java.lang.Object
me.agent.vgui.api.item.ViewItem

public final class ViewItem extends Object
An item shown in a view slot, optionally with a click handler. Immutable; safe to share between slots, views and players.
  • Method Summary

    Modifier and Type
    Method
    Description
    static ViewItem
    backButton(com.github.retrooper.packetevents.protocol.item.ItemStack item)
    An item that returns to the previous view (or closes if there is none) when clicked.
    static ViewItem
    clickable(com.github.retrooper.packetevents.protocol.item.ItemStack item, Consumer<ClickContext> onClick)
    An item that runs onClick when clicked.
    static ViewItem
    An item built from an ItemBuilder that runs onClick when clicked.
    static ViewItem
    closeButton(com.github.retrooper.packetevents.protocol.item.ItemStack item)
    An item that closes the view when clicked.
    void
    Runs the click handler, if any.
    boolean
    Whether this item has a click handler.
    com.github.retrooper.packetevents.protocol.item.ItemStack
    A defensive copy of the displayed item stack.
    static ViewItem
    of(com.github.retrooper.packetevents.protocol.item.ItemStack item)
    A display-only item without a click handler.
    static ViewItem
    of(ItemBuilder builder)
    A display-only item built from an ItemBuilder.
    static ViewItem
    opens(com.github.retrooper.packetevents.protocol.item.ItemStack item, Supplier<View> view)
    An item that opens a lazily-created view (pushing back-history) when clicked.
    static ViewItem
    opens(com.github.retrooper.packetevents.protocol.item.ItemStack item, View view)
    An item that opens another view (pushing back-history) when clicked.
    static ViewItem
    pageNext(com.github.retrooper.packetevents.protocol.item.ItemStack item)
    An item that advances the view's Pagination one page.
    static ViewItem
    pagePrevious(com.github.retrooper.packetevents.protocol.item.ItemStack item)
    An item that goes back one page in the view's Pagination.
    A copy of this item with a different click handler (null removes it).
    withItem(com.github.retrooper.packetevents.protocol.item.ItemStack item)
    A copy of this item with a different item stack.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • of

      public static ViewItem of(com.github.retrooper.packetevents.protocol.item.ItemStack item)
      A display-only item without a click handler.
    • of

      public static ViewItem of(ItemBuilder builder)
      A display-only item built from an ItemBuilder.
    • clickable

      public static ViewItem clickable(com.github.retrooper.packetevents.protocol.item.ItemStack item, Consumer<ClickContext> onClick)
      An item that runs onClick when clicked.
    • clickable

      public static ViewItem clickable(ItemBuilder builder, Consumer<ClickContext> onClick)
      An item built from an ItemBuilder that runs onClick when clicked.
    • closeButton

      public static ViewItem closeButton(com.github.retrooper.packetevents.protocol.item.ItemStack item)
      An item that closes the view when clicked.
    • backButton

      public static ViewItem backButton(com.github.retrooper.packetevents.protocol.item.ItemStack item)
      An item that returns to the previous view (or closes if there is none) when clicked.
    • pageNext

      public static ViewItem pageNext(com.github.retrooper.packetevents.protocol.item.ItemStack item)
      An item that advances the view's Pagination one page.
    • pagePrevious

      public static ViewItem pagePrevious(com.github.retrooper.packetevents.protocol.item.ItemStack item)
      An item that goes back one page in the view's Pagination.
    • opens

      public static ViewItem opens(com.github.retrooper.packetevents.protocol.item.ItemStack item, View view)
      An item that opens another view (pushing back-history) when clicked.
    • opens

      public static ViewItem opens(com.github.retrooper.packetevents.protocol.item.ItemStack item, Supplier<View> view)
      An item that opens a lazily-created view (pushing back-history) when clicked.
    • withClick

      public ViewItem withClick(Consumer<ClickContext> onClick)
      A copy of this item with a different click handler (null removes it).
    • withItem

      public ViewItem withItem(com.github.retrooper.packetevents.protocol.item.ItemStack item)
      A copy of this item with a different item stack.
    • item

      public com.github.retrooper.packetevents.protocol.item.ItemStack item()
      A defensive copy of the displayed item stack.
    • hasHandler

      public boolean hasHandler()
      Whether this item has a click handler.
    • handle

      public void handle(ClickContext ctx)
      Runs the click handler, if any.