Class Layout

java.lang.Object
ua.mcchickenstudio.opencreative.menus.AbstractMenu
ua.mcchickenstudio.opencreative.coding.menus.layouts.Layout
All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder, InventoryMenu
Direct Known Subclasses:
LayoutMaker

public abstract class Layout extends AbstractMenu

Layout

This class represents a inventory menu, that opens when player clicks on coding container to fill arguments.
See Also:
  • Field Details

  • Constructor Details

    • Layout

      public Layout(int rows, @NotNull @NotNull ActionType actionType, @NotNull @NotNull org.bukkit.block.Block containerBlock)
      Creates a coding container layout menu.
      Parameters:
      rows - amount of rows in layout.
      actionType - type of action, that has arguments.
      containerBlock - container block.
  • Method Details

    • fillItems

      public void fillItems(org.bukkit.entity.Player player)
      Specified by:
      fillItems in class AbstractMenu
    • fillArgumentItems

      protected abstract void fillArgumentItems()
      Fills menu with argument glasses and values.
      See Also:
    • getArgumentValueFromContainer

      @NotNull protected @NotNull org.bukkit.inventory.ItemStack getArgumentValueFromContainer(int slot)
      Returns argument value item from coding container.
      Parameters:
      slot - slot of item inside coding container.
      Returns:
      value item, or empty item.
    • onClick

      public void onClick(@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent event)
      Description copied from interface: InventoryMenu
      Executes when player clicks in inventory.
      Specified by:
      onClick in interface InventoryMenu
      Specified by:
      onClick in class AbstractMenu
      Parameters:
      event - event of click in inventory.
    • onOpen

      public void onOpen(@NotNull @NotNull org.bukkit.event.inventory.InventoryOpenEvent event)
      Description copied from interface: InventoryMenu
      Executes when player opens inventory and sees it first time. Useful for playing sounds or setting items.
      Specified by:
      onOpen in interface InventoryMenu
      Specified by:
      onOpen in class AbstractMenu
      Parameters:
      event - event of inventory open.
    • onClose

      public final void onClose(@NotNull @NotNull org.bukkit.event.inventory.InventoryCloseEvent event)
      Description copied from interface: InventoryMenu
      Executes when player closes inventory.

      NOTE: Menu should be unregistered after closing it.

      Parameters:
      event - event of inventory close.
      See Also:
    • setArgSlotVertical

      protected void setArgSlotVertical(int argNumber, int slot)
      Sets argument slot with vertical glass panes in slot.
      Parameters:
      argNumber - number of argument.
      slot - slot to put item.
    • setArgSlotHorizontal

      protected void setArgSlotHorizontal(int argNumber, int slot)
      Sets argument slot with horizontal glass panes in slot.
      Parameters:
      argNumber - number of argument.
      slot - slot to put item.
    • setArgSlotCross

      protected void setArgSlotCross(int argNumber, int slot)
      Sets argument slot with vertical and horizontal glass panes in slot.
      Parameters:
      argNumber - number of argument.
      slot - slot to put item.
    • setGlass

      protected void setGlass(int argNumber, int... slots)
      Sets glass pane in slot.
      Parameters:
      argNumber - number of argument.
      slots - slots to put glass pane.
    • setArgSlot

      protected void setArgSlot(int argNumber, int... slots)
      Sets argument slot in slot.
      Parameters:
      argNumber - number of argument.
      slots - slots to put argument slot.
    • getArgsSlots

      @NotNull public @NotNull List<Integer> getArgsSlots()
      Returns list of slots, items from will be saved into coding container after closing menu.
      Returns:
      list of slots with argument items.
    • createParamButton

      @NotNull protected @NotNull ParameterButton createParamButton(@NotNull @NotNull ParameterSlot parameter, Object value)
      Creates and returns parameter button.
      Parameters:
      parameter - parameter with info.
      value - current value.
      Returns:
      parameter button.
    • getCentredSlots

      @NotNull protected @NotNull List<Integer> getCentredSlots(int count, int row)
      Returns list of slots, that will be used to display a row of items in more beautiful place.
      Parameters:
      count - count of items in row (1-9)
      row - row (1-6)
      Returns:
      list of centered slots.
    • getViewers

      @NotNull public @NotNull Set<org.bukkit.entity.Player> getViewers()
      Returns set of players, who have opened this menu.
      Returns:
      set of menu viewers.