Record Class MenuItemSnapshot

java.lang.Object
java.lang.Record
nl.pim16aap2.lightkeeper.framework.MenuItemSnapshot
Record Components:
slot - Raw slot index.
materialKey - Material key.
displayName - Optional display name.
lore - Lore lines.

public record MenuItemSnapshot(int slot, String materialKey, String displayName, List<String> lore) extends Record
Menu item snapshot.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MenuItemSnapshot(int slot, String materialKey, String displayName, List<String> lore)
    Copies lore and normalizes material keys and absent display names.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the displayName record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the lore record component.
    boolean
    matches(org.bukkit.inventory.ItemStack expected)
    Compares only material, display name and ordered lore, excluding unobserved metadata and amount.
    boolean
    matchesMaterial(@Nullable String expected)
    Compares normalized material keys.
    Returns the value of the materialKey record component.
    int
    Returns the value of the slot record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MenuItemSnapshot

      public MenuItemSnapshot(int slot, String materialKey, String displayName, List<String> lore)
      Copies lore and normalizes material keys and absent display names.
  • Method Details

    • matchesMaterial

      public boolean matchesMaterial(@Nullable String expected)
      Compares normalized material keys.
      Parameters:
      expected - Material name or namespaced key.
      Returns:
      Whether the materials match.
    • matches

      public boolean matches(org.bukkit.inventory.ItemStack expected)
      Compares only material, display name and ordered lore, excluding unobserved metadata and amount.
      Parameters:
      expected - Expected Bukkit item.
      Returns:
      Whether all represented fields match.
    • 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.
    • slot

      public int slot()
      Returns the value of the slot record component.
      Returns:
      the value of the slot record component
    • materialKey

      public String materialKey()
      Returns the value of the materialKey record component.
      Returns:
      the value of the materialKey record component
    • displayName

      public String displayName()
      Returns the value of the displayName record component.
      Returns:
      the value of the displayName record component
    • lore

      public List<String> lore()
      Returns the value of the lore record component.
      Returns:
      the value of the lore record component