Class MenuManager

java.lang.Object
net.tnemc.menu.core.manager.MenuManager

public class MenuManager extends Object
MenuManager class is responsible for managing menus and menu viewers.
  • Field Details

    • ROW_SIZE

      public static final int ROW_SIZE
      See Also:
    • viewers

      private final Map<UUID,MenuViewer> viewers
      Represents a collection of MenuViewers associated with unique UUIDs.
    • instance

      private static final MenuManager instance
      Singleton instance of the MenuManager.
    • helper

      private net.tnemc.item.providers.HelperMethods helper
  • Constructor Details

    • MenuManager

      private MenuManager()
  • Method Details

    • open

      public void open(String menu, int page, MenuPlayer player)
    • findMenu

      public Optional<Menu> findMenu(String name)
      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.
    • addMenu

      public void addMenu(Menu menu)
      Adds a menu to the collection.
      Parameters:
      menu - The menu to be added.
    • inMenu

      public boolean inMenu(UUID id)
    • findViewer

      public Optional<MenuViewer> findViewer(UUID id)
      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.
    • addViewer

      public void addViewer(MenuViewer viewer)
      Adds a MenuViewer to the collection.
      Parameters:
      viewer - The MenuViewer to be added.
    • updateViewer

      public void updateViewer(UUID identifier, String menu, int page)
      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.
    • updateViewer

      public void updateViewer(UUID identifier, ViewerStatus status)
    • removeViewer

      public void removeViewer(UUID identifier)
      Removes a MenuViewer associated with the given UUID from the viewers map.
      Parameters:
      identifier - The UUID identifying the player whose viewer 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

      public static MenuManager instance()
      Returns the singleton instance of the MenuManager.
      Returns:
      The singleton instance of the MenuManager.