Interface MenuInstance


public interface MenuInstance
Runtime handle for one open menu. Handlers receive this in their callbacks and use it to mutate the visible state (refresh sections, flip slot states, pop back).
  • Method Details

    • definition

      MenuDefinition definition()
      Returns the blueprint this menu was built from.
      Returns:
      the resolved definition backing this menu
    • viewer

      Player viewer()
      Returns who has this menu open.
      Returns:
      the viewing player
    • refreshSection

      void refreshSection(String sectionId)
      Re-render one section.
      Parameters:
      sectionId - the section to re-render
    • close

      void close()
    • popBack

      boolean popBack()
      ESC-as-back from a click handler.
      Returns:
      true if a pop happened, false if no-op (menu lacks esc-supports-back or stack empty)
    • playSound

      void playSound(SoundSpec spec)
      Fire a one-off sound at the viewer (for ad-hoc feedback like error pings).
      Parameters:
      spec - the sound to play for the viewer
    • section

      <S extends Section> S section(String id, Class<S> type)
      Typed access to a section by id; throws if id is unknown or type mismatches.
      Type Parameters:
      S - the section record type expected
      Parameters:
      id - the section id
      type - the record class it is expected to be
      Returns:
      the section, typed
    • setSlotState

      void setSlotState(String slotSectionId, String stateName)
      Flip a multi-state SlotSection's state and refresh that section.
      Parameters:
      slotSectionId - the multi-state slot section to flip
      stateName - the state to switch it into
    • getSlotState

      String getSlotState(String slotSectionId)
      Current state name of a multi-state slot section, or its default.
      Parameters:
      slotSectionId - the multi-state slot section to read
      Returns:
      its current state name, or its default
    • context

      Object context()
      The context object this menu was opened with.
      Returns:
      the context object this menu was opened with