Class AbstractMenu<M extends AbstractMenu<M>>

java.lang.Object
com.kamikazejam.kamicommon.menu.api.MenuHolder
com.kamikazejam.kamicommon.menu.AbstractMenu<M>
All Implemented Interfaces:
UpdatingMenu, Menu<M>, InventoryHolder
Direct Known Subclasses:
OneClickMenu, PaginatedMenu, SimpleMenu

public abstract sealed class AbstractMenu<M extends AbstractMenu<M>> extends MenuHolder implements Menu<M>, UpdatingMenu permits SimpleMenu, PaginatedMenu, OneClickMenu
  • Field Details

  • Constructor Details

  • Method Details

    • reopenMenu

      public void reopenMenu()
      Description copied from interface: Menu
      Attempt to reopen the menu for the given player. Depending on the menu type, this may not be possible for all possible
      By default, this method will NOT reset the tick counter.
      See Menu.reopenMenu(boolean) for reopening with reset.
      Specified by:
      reopenMenu in interface Menu<M extends AbstractMenu<M>>
    • reopenMenu

      public void reopenMenu(boolean resetTickCounter)
      Description copied from interface: Menu
      Attempt to reopen the menu for the given player. Depending on the menu type, this may not be possible for all possible
      Specified by:
      reopenMenu in interface Menu<M extends AbstractMenu<M>>
      Parameters:
      resetTickCounter - If true, the tick counter will be reset to 0. This is useful for menus that are not paginated, and
    • open

      @Nullable public @Nullable InventoryView open()
      Open the Inventory for the Player that this menu was created for.
      Returns:
      The InventoryView for the new menu, or null if the player was not online to open the menu for.
    • open

      @Nullable public @Nullable InventoryView open(boolean resetTickCounter)
      Open the Inventory for the Player that this menu was created for.
      Parameters:
      resetTickCounter - If true, the tick counter will be reset to 0 when opening the menu.
      Returns:
      The InventoryView for the new menu, or null if the player was not online to open the menu for.
    • close

      public boolean close()
      Close the Inventory for the Player that this menu was created for.
      Identical to calling HumanEntity.closeInventory().
      Returns:
      If the inventory was successfully closed. False if the player is no longer valid (not online).
    • setSize

      public void setSize(@NotNull @NotNull MenuSize size)
    • resizeMenu

      public void resizeMenu(@NotNull @NotNull MenuSize size)
    • modifyIcons

      @NotNull public M modifyIcons(@NotNull @NotNull Consumer<IMenuIconsAccess<M>> consumer)
    • getMenuIcons

      @NotNull public @NotNull Map<String,MenuIcon<M>> getMenuIcons()
      Specified by:
      getMenuIcons in interface Menu<M extends AbstractMenu<M>>
    • getMenuIconsAccess

      @NotNull public @NotNull IMenuIconsAccess<M> getMenuIconsAccess()
      Specified by:
      getMenuIconsAccess in interface Menu<M extends AbstractMenu<M>>
    • getFillerIcon

      @Nullable public @Nullable MenuIcon<M> getFillerIcon()
      Specified by:
      getFillerIcon in interface Menu<M extends AbstractMenu<M>>
    • updateOneTick

      @Internal public void updateOneTick()
      Specified by:
      updateOneTick in interface UpdatingMenu
    • placeIcons

      public void placeIcons(@Nullable @Nullable Predicate<MenuIcon<M>> needsUpdate)
      Manually trigger an update for all icons matching this predicate.
      If the predicate is passed, the icon will be re-built and set in the inventory.
      If the predicate is null, it will always update all icons.
      Parameters:
      needsUpdate - An optional predicate to filter which icons need new builders.
    • placeFiller

      protected void placeFiller(Map<Integer,@Nullable ItemStack> newMenuState, Set<Integer> slots, int tick)