Record Class MenuView

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.gui.background.MenuView
Record Components:
menuId - the menu's ID in guis.yml, such as party.members
name - the menu's own name: its title without the texture
rows - the menu's size in rows
elements - every visible element, in the order placed, mapped to the state it is drawn in; an element without states maps to an empty string
entries - how many entries each content list the menu reported holds, across all pages
page - the page on screen, counting from 1
pages - how many pages there are, at least 1
view - the view the menu reports, such as no-party; empty for a menu with one
background - what the background decided, or null while conditions are being tested and for a menu whose texture Zentrix does not decide: one without rules in guis.yml that no resolver covers

public record MenuView(@NotNull String menuId, @NotNull String name, int rows, @NotNull Map<String,String> elements, @NotNull Map<String,Integer> entries, int page, int pages, @NotNull String view, @Nullable MenuBackgroundResult background) extends Record
What one open Zentrix menu shows, as its background rules see it.

Zentrix records this while the menu places its buttons: every element placed through the menu's guis.yml layout counts as shown, in the state it was drawn in. It is the same record the shown, state, entries, page and view conditions are tested against, and what /zx gui debug prints.

A view is a snapshot: it does not follow the menu after it was taken.

Since:
1.15.0
  • Field Details

    • MAIN_LIST

      public static final String MAIN_LIST
      The content list a menu with several lists calls its main one.
      See Also:
  • Constructor Details

    • MenuView

      public MenuView(@NotNull @NotNull String menuId, @NotNull @NotNull String name, int rows, @NotNull @NotNull Map<String,String> elements, @NotNull @NotNull Map<String,Integer> entries, int page, int pages, @NotNull @NotNull String view, @Nullable @Nullable MenuBackgroundResult background)
      Creates an instance of a MenuView record class.
      Parameters:
      menuId - the value for the menuId record component
      name - the value for the name record component
      rows - the value for the rows record component
      elements - the value for the elements record component
      entries - the value for the entries record component
      page - the value for the page record component
      pages - the value for the pages record component
      view - the value for the view record component
      background - the value for the background record component
  • Method Details

    • isShown

      public boolean isShown(@NotNull @NotNull String elementId)
      Whether an element is visible, ignoring case.
    • state

      @NotNull public @NotNull Optional<String> state(@NotNull @NotNull String elementId)
      The state a visible element is drawn in, ignoring case.
      Returns:
      the state, an empty string for an element without states, or empty when the element is not visible
    • entryCount

      @NotNull public @NotNull OptionalInt entryCount(@NotNull @NotNull String listId)
      How many entries one content list holds across all its pages.
      Returns:
      the count, or empty when the menu did not report that list
    • entryCount

      @NotNull public @NotNull OptionalInt entryCount()
      How many entries the menu's main list holds: the list named "entries", or else the only list the menu reported.
      Returns:
      the count, or empty when there is no such list
    • isPaged

      public boolean isPaged()
      Whether the menu has a page before this one or after it.
    • backgroundResult

      @NotNull public @NotNull Optional<MenuBackgroundResult> backgroundResult()
      What the background decided, when it decided anything.
    • 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.
    • name

      @NotNull public @NotNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • rows

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

      @NotNull public @NotNull Map<String,String> elements()
      Returns the value of the elements record component.
      Returns:
      the value of the elements record component
    • entries

      @NotNull public @NotNull Map<String,Integer> entries()
      Returns the value of the entries record component.
      Returns:
      the value of the entries record component
    • page

      public int page()
      Returns the value of the page record component.
      Returns:
      the value of the page record component
    • pages

      public int pages()
      Returns the value of the pages record component.
      Returns:
      the value of the pages record component
    • view

      @NotNull public @NotNull String view()
      Returns the value of the view record component.
      Returns:
      the value of the view record component
    • background

      @Nullable public @Nullable MenuBackgroundResult background()
      Returns the value of the background record component.
      Returns:
      the value of the background record component