Record Class MenuDefinition

java.lang.Object
java.lang.Record
de.Keyle.MyPet.api.gui.MenuDefinition
Record Components:
menuId - identifies the menu this was loaded for
titleMiniMessage - the window title, in MiniMessage form, before placeholders
rows - inventory height, from 1 to 6
escSupportsBack - whether ESC pops back a level instead of closing outright
soundOnOpen - played as the menu opens
soundOnClose - played as the menu closes
soundOnBack - played when popping back, or null to reuse soundOnClose
sections - the menu's sections, keyed by section id

public record MenuDefinition(String menuId, String titleMiniMessage, int rows, boolean escSupportsBack, SoundSpec soundOnOpen, SoundSpec soundOnClose, @Nullable SoundSpec soundOnBack, Map<String,Section> sections) extends Record
Immutable resolved blueprint for one menu. Produced by the loader after deep-merging the bundled and overlay JSON. The renderer walks this to produce the live inventory.
  • Constructor Details

    • MenuDefinition

      public MenuDefinition(String menuId, String titleMiniMessage, int rows, boolean escSupportsBack, SoundSpec soundOnOpen, SoundSpec soundOnClose, @Nullable @Nullable SoundSpec soundOnBack, Map<String,Section> sections)
      Rejects an out-of-range row count or absent title, and substitutes silence for absent sounds.
  • Method Details

    • effectiveSoundOnBack

      public SoundSpec effectiveSoundOnBack()
      Effective sound when popping back: explicit soundOnBack or soundOnClose.
      Returns:
      soundOnBack when set, otherwise soundOnClose
    • slotCount

      public int slotCount()
      Returns how many slots this menu has.
      Returns:
      rows * 9
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • titleMiniMessage

      public String titleMiniMessage()
      Returns the value of the titleMiniMessage record component.
      Returns:
      the value of the titleMiniMessage record component
    • rows

      public int rows()
      Returns the value of the rows record component.
      Returns:
      the value of the rows record component
    • escSupportsBack

      public boolean escSupportsBack()
      Returns the value of the escSupportsBack record component.
      Returns:
      the value of the escSupportsBack record component
    • soundOnOpen

      public SoundSpec soundOnOpen()
      Returns the value of the soundOnOpen record component.
      Returns:
      the value of the soundOnOpen record component
    • soundOnClose

      public SoundSpec soundOnClose()
      Returns the value of the soundOnClose record component.
      Returns:
      the value of the soundOnClose record component
    • soundOnBack

      @Nullable public @Nullable SoundSpec soundOnBack()
      Returns the value of the soundOnBack record component.
      Returns:
      the value of the soundOnBack record component
    • sections

      public Map<String,Section> sections()
      Returns the value of the sections record component.
      Returns:
      the value of the sections record component