Interface MenuSize

All Known Implementing Classes:
MenuSizeRows, MenuSizeType

@NonExtendable public interface MenuSize
Represents the size of a menu.
Can either be a MenuSizeRows, or MenuSizeType.

Do not implement this outside KamiCommon. This was a sealed hierarchy until spigot-utils dropped to Java 8 so that 1.8.x servers could load it; sealed is Java 17 and has no Java 8 spelling. The closed set is still enforced within the library by the verifySealedHierarchies build task, which fails if an implementation appears that is not on the permitted list (MenuSizeRows, MenuSizeType). Nothing can enforce it in your code, hence this annotation.

  • Method Details

    • createInventory

      @NotNull @NotNull Inventory createInventory(@NotNull @NotNull InventoryHolder owner, @NotNull @NotNull VersionedComponent 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.)