Record Class RecipeIngredient

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.recipe.RecipeIngredient
Record Components:
key - the pattern character of a shaped crafting ingredient; null otherwise
matching - how the recipe compares an offered item with options()
options - the items the ingredient accepts; for RecipeIngredient.Matching.MATERIAL, one item per accepted material

public record RecipeIngredient(@Nullable Character key, @NotNull RecipeIngredient.Matching matching, @NotNull List<org.bukkit.inventory.ItemStack> options) extends Record
One ingredient of a recipe, with every item it accepts.

ZentrixRecipe.getIngredients() shows one representative item per ingredient; this keeps them all. The items are copies.

Since:
1.8.0
  • Constructor Details

    • RecipeIngredient

      public RecipeIngredient(@Nullable @Nullable Character key, @NotNull @NotNull RecipeIngredient.Matching matching, @NotNull @NotNull List<org.bukkit.inventory.ItemStack> options)
      Creates an instance of a RecipeIngredient record class.
      Parameters:
      key - the value for the key record component
      matching - the value for the matching record component
      options - the value for the options record component
  • Method Details

    • keyIfShaped

      @NotNull public @NotNull Optional<Character> keyIfShaped()
      The pattern character, for a shaped crafting ingredient.
    • options

      @NotNull public @NotNull List<org.bukkit.inventory.ItemStack> options()
      Fresh copies of the accepted items, safe to change.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • key

      @Nullable public @Nullable Character key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • matching

      @NotNull public @NotNull RecipeIngredient.Matching matching()
      Returns the value of the matching record component.
      Returns:
      the value of the matching record component