Class ListGui<T>

java.lang.Object
dev.piglin.piglinworldapi.gui.CustomGui
dev.piglin.piglinworldapi.gui.ListGui<T>
Type Parameters:
T - List element type

public abstract class ListGui<T> extends CustomGui
List gui with prev/next buttons and clickable elements
  • Nested Class Summary

    Nested classes/interfaces inherited from class dev.piglin.piglinworldapi.gui.CustomGui

    CustomGui.ClickResult, CustomGui.ClickResultAnotherGui, CustomGui.ClickResultNone
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected HashMap<org.bukkit.inventory.Inventory,​List<T>>
     
    protected List<Integer>
     
    protected String
     
    protected org.bukkit.inventory.ItemStack
     
    protected int
     
    protected org.bukkit.inventory.ItemStack
     
    protected org.bukkit.inventory.ItemStack
     
    protected HashMap<org.bukkit.inventory.Inventory,​Integer>
     
    protected org.bukkit.inventory.ItemStack
     
    protected int
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ListGui​(List<Integer> listSlots, int prev, int next, org.bukkit.inventory.ItemStack prevItem, org.bukkit.inventory.ItemStack nextItem, org.bukkit.inventory.ItemStack noPrevItem, org.bukkit.inventory.ItemStack noNextItem, String name, org.bukkit.plugin.Plugin plugin)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.bukkit.inventory.ItemStack
    display​(org.bukkit.entity.Player player, T t)
    Makes an ItemStack representation of an item for the player
    abstract List<T>
    getItems​(org.bukkit.entity.Player player)
    Get all available items
    onClick​(T t, org.bukkit.entity.Player player, org.bukkit.inventory.Inventory inventory, org.bukkit.event.inventory.ClickType type)
    Handle item click
    void
    onClose​(org.bukkit.event.inventory.InventoryCloseEvent event)
    Handle inventory close
    onItemClick​(org.bukkit.event.inventory.InventoryClickEvent event)
    Handle clicks
    onItemClickInInventory​(org.bukkit.event.inventory.InventoryClickEvent event)
    Handle clicks in player's inventory but when your inventory is open
    void
    onItemDrag​(org.bukkit.event.inventory.InventoryDragEvent event)
    Handle item drag
    org.bukkit.inventory.Inventory
    open​(org.bukkit.entity.Player player)
    Create an inventory and open it.

    Methods inherited from class java.lang.Object

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

    • rows

      protected final int rows
    • name

      protected final String name
    • listSlots

      protected final List<Integer> listSlots
    • prevSlot

      protected final int prevSlot
    • nextSlot

      protected final int nextSlot
    • prevItem

      protected final org.bukkit.inventory.ItemStack prevItem
    • nextItem

      protected final org.bukkit.inventory.ItemStack nextItem
    • noPrevItem

      protected final org.bukkit.inventory.ItemStack noPrevItem
    • noNextItem

      protected final org.bukkit.inventory.ItemStack noNextItem
    • lists

      protected final HashMap<org.bukkit.inventory.Inventory,​List<T>> lists
    • pages

      protected final HashMap<org.bukkit.inventory.Inventory,​Integer> pages
  • Constructor Details

    • ListGui

      public ListGui(List<Integer> listSlots, int prev, int next, org.bukkit.inventory.ItemStack prevItem, org.bukkit.inventory.ItemStack nextItem, org.bukkit.inventory.ItemStack noPrevItem, org.bukkit.inventory.ItemStack noNextItem, String name, org.bukkit.plugin.Plugin plugin)
      Parameters:
      listSlots - Slots for the items
      prev - Slot for "previous page" button
      next - Slot for "next page" button
      prevItem - ItemStack for "previous page" button
      nextItem - ItemStack for "next page" button
      noPrevItem - ItemStack for "previous page" button when it's first page
      noNextItem - ItemStack for "next page" button when it's last page
      name - Gui title
      plugin - Your plugin
  • Method Details

    • onItemClick

      public CustomGui.ClickResult onItemClick(org.bukkit.event.inventory.InventoryClickEvent event)
      Description copied from class: CustomGui
      Handle clicks
      Specified by:
      onItemClick in class CustomGui
      Parameters:
      event - The event
      Returns:
      Result of this interaction
    • onItemClickInInventory

      public CustomGui.ClickResult onItemClickInInventory(org.bukkit.event.inventory.InventoryClickEvent event)
      Description copied from class: CustomGui
      Handle clicks in player's inventory but when your inventory is open
      Specified by:
      onItemClickInInventory in class CustomGui
      Parameters:
      event - The event
      Returns:
      Result of this interaction
    • onItemDrag

      public void onItemDrag(org.bukkit.event.inventory.InventoryDragEvent event)
      Description copied from class: CustomGui
      Handle item drag
      Specified by:
      onItemDrag in class CustomGui
      Parameters:
      event - The event
    • open

      public org.bukkit.inventory.Inventory open(org.bukkit.entity.Player player)
      Description copied from class: CustomGui
      Create an inventory and open it. Usually this method's implementation looks like this:
       
       var inventory = Bukkit.createInventory(null, inventorySize, "Name");
       // Some Inventory#setItem calls
       // Maybe GuiUtils.fillWithBarriers(plugin, inventory);
       player.openInventory(inventory);
       return inventory;
       
       
      Specified by:
      open in class CustomGui
      Parameters:
      player - The player
      Returns:
      The inventory
    • onClose

      public void onClose(org.bukkit.event.inventory.InventoryCloseEvent event)
      Description copied from class: CustomGui
      Handle inventory close
      Specified by:
      onClose in class CustomGui
      Parameters:
      event - The event
    • getItems

      public abstract List<T> getItems(org.bukkit.entity.Player player)
      Get all available items
      Parameters:
      player - The player
      Returns:
      List of all available items
    • display

      public abstract org.bukkit.inventory.ItemStack display(org.bukkit.entity.Player player, T t)
      Makes an ItemStack representation of an item for the player
      Parameters:
      player - The player
      t - The item
      Returns:
      ItemStack representation of the item
    • onClick

      public abstract CustomGui.ClickResult onClick(T t, org.bukkit.entity.Player player, org.bukkit.inventory.Inventory inventory, org.bukkit.event.inventory.ClickType type)
      Handle item click
      Parameters:
      t - The item
      player - The player who clicked
      inventory - The inventory
      type - Click type
      Returns:
      Result of this interaction