All Known Implementing Classes:
MenuSizeRows, MenuSizeType

public sealed interface MenuSize permits MenuSizeRows, MenuSizeType
Represents the size of a menu.
Can either be a MenuSizeRows, or MenuSizeType.
  • Method Details

    • createInventory

      @NotNull @NotNull Inventory createInventory(@NotNull @NotNull InventoryHolder holder, @NotNull @NotNull String title)
      Creates a new Inventory with the given InventoryHolder and title.
      Uses this MenuSize to determine the size of the inventory.
    • getSlotInLastRow

      int getSlotInLastRow(int index)
      Returns the slot number for the slot in the last row with the given index in that row.
    • copy

      @NotNull @NotNull MenuSize copy()
      Deep copies this MenuSize into an identical object clone.
    • getNumberOfSlots

      int getNumberOfSlots()
      Returns:
      the 1-index number of slots in this menu size.
    • mapPositionToSlot

      int mapPositionToSlot(int row, int col) throws IllegalArgumentException, IllegalStateException
      Maps a position to a slot number. For example position (1, 1) maps to slot 0 (top-left) in a traditional inventory.
      Parameters:
      row - The row (top to bottom) of the position. (1-indexed)
      col - The column (left to right) of the position. (1-indexed)
      Returns:
      The bukkit slot number corresponding to the given position.
      Throws:
      IllegalArgumentException - if the given position is outside the bounds of this MenuSize.
      IllegalStateException - if this method is called on an unsupported MenuSize (including some MenuSizeTypes using non-standard InventoryType configurations.)