Package de.Keyle.MyPet.api.gui
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 Summary
Modifier and TypeMethodDescriptionvoidclose()Unconditional close — firesMenuHandler.onClose(de.Keyle.MyPet.api.gui.MenuInstance, de.Keyle.MyPet.api.gui.CloseReason)withCloseReason.PLUGIN_CLOSED; stack cleared.context()The context object this menu was opened with.Returns the blueprint this menu was built from.getSlotState(String slotSectionId) Current state name of a multi-state slot section, or its default.voidFire a one-off sound at the viewer (for ad-hoc feedback like error pings).booleanpopBack()ESC-as-back from a click handler.voidrefreshSection(String sectionId) Re-render one section.<S extends Section>
STyped access to a section by id; throws if id is unknown or type mismatches.voidsetSlotState(String slotSectionId, String stateName) Flip a multi-stateSlotSection's state and refresh that section.viewer()Returns who has this menu open.
-
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
Re-render one section.- Parameters:
sectionId- the section to re-render
-
close
void close()Unconditional close — firesMenuHandler.onClose(de.Keyle.MyPet.api.gui.MenuInstance, de.Keyle.MyPet.api.gui.CloseReason)withCloseReason.PLUGIN_CLOSED; stack cleared. -
popBack
boolean popBack()ESC-as-back from a click handler.- Returns:
- true if a pop happened, false if no-op (menu lacks
esc-supports-backor stack empty)
-
playSound
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
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 idtype- the record class it is expected to be- Returns:
- the section, typed
-
setSlotState
Flip a multi-stateSlotSection's state and refresh that section.- Parameters:
slotSectionId- the multi-state slot section to flipstateName- the state to switch it into
-
getSlotState
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
-