Package net.tnemc.menu.core.manager
Class MenuManager
java.lang.Object
net.tnemc.menu.core.manager.MenuManager
MenuManager class is responsible for managing menus and menu viewers.
-
Field Summary
Modifier and TypeFieldDescriptionprivate net.tnemc.item.providers.HelperMethods
private static final MenuManager
Singleton instance of the MenuManager.The collection to store menus, where the key is the menu name and the value is the menu itself.static final int
private final Map<UUID,
MenuViewer> Represents a collection of MenuViewers associated with unique UUIDs. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a menu to the collection.void
addViewer
(MenuViewer viewer) Adds a MenuViewer to the collection.Finds a menu by its name and returns it as an Optional.findViewer
(UUID id) Finds a MenuViewer by its UUID and returns it as an Optional.net.tnemc.item.providers.HelperMethods
Returns the HelperMethods object associated with this MenuManager.boolean
static MenuManager
instance()
Returns the singleton instance of the MenuManager.void
open
(String menu, int page, MenuPlayer player) void
removeViewer
(UUID identifier) Removes a MenuViewer associated with the given UUID from the viewers map.void
setHelper
(net.tnemc.item.providers.HelperMethods helper) Sets the HelperMethods object associated with this MenuManager.void
updateViewer
(UUID identifier, String menu, int page) Updates the menu and page for a MenuViewer identified by the given UUID.void
updateViewer
(UUID identifier, ViewerStatus status)
-
Field Details
-
ROW_SIZE
public static final int ROW_SIZE- See Also:
-
viewers
Represents a collection of MenuViewers associated with unique UUIDs. -
instance
Singleton instance of the MenuManager. -
helper
private net.tnemc.item.providers.HelperMethods helper
-
-
Constructor Details
-
MenuManager
private MenuManager()
-
-
Method Details
-
findMenu
Finds a menu by its name and returns it as an Optional.- Parameters:
name
- The name of the menu to find.- Returns:
- An Optional containing the found menu, or an empty Optional if not found.
-
inMenu
-
findViewer
Finds a MenuViewer by its UUID and returns it as an Optional.- Parameters:
id
- The UUID of the MenuViewer to find.- Returns:
- An Optional containing the found MenuViewer, or an empty Optional if not found.
-
updateViewer
Updates the menu and page for a MenuViewer identified by the given UUID.- Parameters:
identifier
- The UUID identifying the player associated with the MenuViewer.menu
- The new menu to set for the MenuViewer.page
- The new page to set for the MenuViewer.
-
removeViewer
Removes a MenuViewer associated with the given UUID from the viewers map.- Parameters:
identifier
- The UUID identifying the player whoseviewer data
should be removed.
-
getHelper
public net.tnemc.item.providers.HelperMethods getHelper()Returns the HelperMethods object associated with this MenuManager.- Returns:
- The HelperMethods object associated with this MenuManager.
-
setHelper
public void setHelper(net.tnemc.item.providers.HelperMethods helper) Sets the HelperMethods object associated with this MenuManager.- Parameters:
helper
- The HelperMethods object to be set.
-
instance
Returns the singleton instance of the MenuManager.- Returns:
- The singleton instance of the MenuManager.