Hopperlib
Loading...
Searching...
No Matches
cc.mrcl.hopperlib.Menus.HopperLibMenu Class Referenceabstract
Inheritance diagram for cc.mrcl.hopperlib.Menus.HopperLibMenu:
cc.mrcl.hopperlib.Menus.HopperListMenu< T >

Public Member Functions

void initializeMenu ()

Protected Member Functions

 HopperLibMenu (Player player, boolean initializeImmediately)
Listener createListener ()
abstract int getMenuSize ()
abstract Component getMenuTitle ()
abstract void populateMenu ()
void addInteraction (ItemStack itemStack, int slot, @Nullable MenuInteractable interactable)
void addInteraction (ItemStack itemStack, int slot, SimpleMenuInteractable menuInteractable)
void addInteraction (ItemStack itemStack, int slot)
void stopMenu (boolean closes)
void stopMenu ()
int getSlot (int x, int y) throws IllegalArgumentException

Protected Attributes

final Player player
final Inventory inventory
int size
final Map< Integer, MenuInteractablebuttons = new HashMap<>()

Constructor & Destructor Documentation

◆ HopperLibMenu()

cc.mrcl.hopperlib.Menus.HopperLibMenu.HopperLibMenu ( Player player,
boolean initializeImmediately )
protected
Parameters
playerplayer to display the menu to.
initializeImmediatelywhether the menu will initialize in the constructor, use "false" if your implementation will contain parameters that need to not be null on menu creation and call "initializeMenu()" as the last method in the constructor.

Member Function Documentation

◆ addInteraction()

void cc.mrcl.hopperlib.Menus.HopperLibMenu.addInteraction ( ItemStack itemStack,
int slot,
@Nullable MenuInteractable interactable )
protected

Adds an item to the inventory and their interactions.

◆ createListener()

Listener cc.mrcl.hopperlib.Menus.HopperLibMenu.createListener ( )
protected

Method to override the listener if you want a very specific implementation.

◆ getMenuSize()

abstract int cc.mrcl.hopperlib.Menus.HopperLibMenu.getMenuSize ( )
abstractprotected
Returns
The size of the menu, must be a multiple of 9 and between 9-54 (inclusive)

◆ getMenuTitle()

abstract Component cc.mrcl.hopperlib.Menus.HopperLibMenu.getMenuTitle ( )
abstractprotected
Returns
The menu's title

◆ getSlot()

int cc.mrcl.hopperlib.Menus.HopperLibMenu.getSlot ( int x,
int y ) throws IllegalArgumentException
protected

Convenient method to get the correct slot in a square inventory. Index starting in the top-left corner of the inventory, x and y start at 1, not 0.

◆ initializeMenu()

void cc.mrcl.hopperlib.Menus.HopperLibMenu.initializeMenu ( )

Initializes the menu, usually you want this to be the last method you call in a constructor

◆ populateMenu()

abstract void cc.mrcl.hopperlib.Menus.HopperLibMenu.populateMenu ( )
abstractprotected

Method to add and populate the menu with interactions on creation through the "addInteraction" methods.

Reimplemented in cc.mrcl.hopperlib.Menus.HopperListMenu< T >.

◆ stopMenu()

void cc.mrcl.hopperlib.Menus.HopperLibMenu.stopMenu ( boolean closes)
protected

Stops the menu

Parameters
closesWhether the menu will close for the user. Useful to chain multiple menus together.

Member Data Documentation

◆ buttons

final Map<Integer,MenuInteractable> cc.mrcl.hopperlib.Menus.HopperLibMenu.buttons = new HashMap<>()
protected

Represents the items in the inventory and their actions. Key: The slot integer. Value: The runnables per action that will be executed when the item is clicked. May be null to not possess an interaction.


The documentation for this class was generated from the following file:
  • src/main/java/cc/mrcl/hopperlib/Menus/HopperLibMenu.java