Class Menu.Builder<T extends Menu.Builder<T>>

java.lang.Object
me.tayebyassine.homestead.gui.Menu.Builder<T>
Enclosing class:
Menu

public static class Menu.Builder<T extends Menu.Builder<T>> extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Map<Integer, BiConsumer<org.bukkit.entity.Player, org.bukkit.event.inventory.InventoryClickEvent>>
     
    protected org.bukkit.inventory.ItemStack
     
    protected final Map<Integer, org.bukkit.inventory.ItemStack>
     
    protected String
     
    protected boolean
     
    protected final int
     
    protected String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Builder(String menuKey, int size)
     
    protected
    Builder(String menuKey, int size, boolean passthrough)
     
    protected
    Builder(String menuKey, Placeholder placeholder, int size)
     
    protected
    Builder(String menuKey, Placeholder placeholder, int size, boolean passthrough)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Builds and returns a new Menu instance from this builder's configuration.
    button(int slot, org.bukkit.inventory.ItemStack item, BiConsumer<org.bukkit.entity.Player, org.bukkit.event.inventory.InventoryClickEvent> callback)
    Places a clickable button in the specified slot with an associated callback.
    Configures the menu to fill all empty slots with the default empty slot item on build.
    fillEmptySlots(org.bukkit.inventory.ItemStack filler)
    Configures the menu to fill all empty slots with the given filler item on build.
    item(int slot, org.bukkit.inventory.ItemStack item)
    Places an item in the specified slot.
    passthrough(boolean passthrough)
    Sets whether clicks in this menu pass through to the player's inventory.
    protected T
     

    Methods inherited from class Object

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

    • size

      protected final int size
    • items

      protected final Map<Integer, org.bukkit.inventory.ItemStack> items
    • buttons

      protected final Map<Integer, BiConsumer<org.bukkit.entity.Player, org.bukkit.event.inventory.InventoryClickEvent>> buttons
    • title

      protected String title
    • passthrough

      protected boolean passthrough
    • filler

      protected org.bukkit.inventory.ItemStack filler
  • Constructor Details

    • Builder

      protected Builder(String menuKey, int size)
    • Builder

      protected Builder(String menuKey, Placeholder placeholder, int size)
    • Builder

      protected Builder(String menuKey, int size, boolean passthrough)
    • Builder

      protected Builder(String menuKey, Placeholder placeholder, int size, boolean passthrough)
  • Method Details

    • self

      protected T self()
    • passthrough

      public T passthrough(boolean passthrough)
      Sets whether clicks in this menu pass through to the player's inventory.
      Parameters:
      passthrough - true to allow clicks to pass through
      Returns:
      this builder for chaining
    • item

      public T item(int slot, org.bukkit.inventory.ItemStack item)
      Places an item in the specified slot.
      Parameters:
      slot - the slot index to place the item in
      item - the item to place
      Returns:
      this builder for chaining
    • button

      public T button(int slot, org.bukkit.inventory.ItemStack item, BiConsumer<org.bukkit.entity.Player, org.bukkit.event.inventory.InventoryClickEvent> callback)
      Places a clickable button in the specified slot with an associated callback.
      Parameters:
      slot - the slot index for the button
      item - the item to display
      callback - the action to execute when the button is clicked, or null for no action
      Returns:
      this builder for chaining
    • fillEmptySlots

      public T fillEmptySlots(org.bukkit.inventory.ItemStack filler)
      Configures the menu to fill all empty slots with the given filler item on build.
      Parameters:
      filler - the item to fill empty slots with
      Returns:
      this builder for chaining
    • fillEmptySlots

      public T fillEmptySlots()
      Configures the menu to fill all empty slots with the default empty slot item on build.
      Returns:
      this builder for chaining
    • build

      public Menu build()
      Builds and returns a new Menu instance from this builder's configuration.
      Returns:
      a fully constructed Menu