Package com.kamikazejam.kamicommon.menu
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final MenuEvents
<M> protected final @NotNull PrioritizedMenuIconMap
<M> protected final MenuOptions
<M> protected final Player
Fields inherited from class com.kamikazejam.kamicommon.menu.api.MenuHolder
inventory, size, title
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractMenu
(@NotNull AbstractMenuBuilder<M, ?> builder, @NotNull Player player) -
Method Summary
Modifier and TypeMethodDescriptionboolean
close()
Close theInventory
for thePlayer
that this menu was created for.
Identical to callingHumanEntity.closeInventory()
.@NotNull IMenuIconsAccess
<M> modifyIcons
(@NotNull Consumer<IMenuIconsAccess<M>> consumer) @Nullable InventoryView
open()
@Nullable InventoryView
open
(boolean resetTickCounter) protected void
void
placeIcons
(@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.void
Attempt to reopen the menu for the given player.void
reopenMenu
(boolean resetTickCounter) Attempt to reopen the menu for the given player.void
resizeMenu
(@NotNull MenuSize size) void
void
Methods inherited from class com.kamikazejam.kamicommon.menu.api.MenuHolder
clear, closeAll, deleteInventory, equals, firstEmpty, firstEmpty, firstEmpty, getHolder, getInventory, getItem, getMenuSize, getRawInventory, getSize, getViewers, hashCode, replaceTitle, setItem, setItem
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.kamikazejam.kamicommon.menu.Menu
buildClickData, buildPlayerClickData, getEvents, getMenuSize, getOptions
Methods inherited from interface com.kamikazejam.kamicommon.menu.api.icons.interfaces.UpdatingMenu
getInventory
-
Field Details
-
player
-
events
-
options
-
-
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.
SeeMenu.reopenMenu(boolean)
for reopening with reset.- Specified by:
reopenMenu
in interfaceMenu<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 interfaceMenu<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
- Returns:
- The
InventoryView
for the new menu, or null if the player was not online to open the menu for.
-
open
- 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 theInventory
for thePlayer
that this menu was created for.
Identical to callingHumanEntity.closeInventory()
.- Returns:
- If the inventory was successfully closed. False if the player is no longer valid (not online).
-
modifyIcons
-
getMenuIcons
- Specified by:
getMenuIcons
in interfaceMenu<M extends AbstractMenu<M>>
-
getMenuIconsAccess
- Specified by:
getMenuIconsAccess
in interfaceMenu<M extends AbstractMenu<M>>
-
getFillerIcon
- Specified by:
getFillerIcon
in interfaceMenu<M extends AbstractMenu<M>>
-
updateOneTick
@Internal public void updateOneTick()- Specified by:
updateOneTick
in interfaceUpdatingMenu
-
placeIcons
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
-