Record Class IngredientHolder

java.lang.Object
java.lang.Record
net.okocraft.box.feature.craft.model.IngredientHolder
Record Components:
slot - the position in the crafting table (0-8)
patterns - the BoxIngredientItem list that is contained this IngredientHolder

public record IngredientHolder(int slot, @NotNull @Unmodifiable List<BoxIngredientItem> patterns) extends Record
A class that holds multiple BoxIngredientItems.
  • Constructor Details

    • IngredientHolder

      public IngredientHolder(int slot, @NotNull @NotNull @Unmodifiable List<BoxIngredientItem> patterns)
      Creates an instance of a IngredientHolder record class.
      Parameters:
      slot - the value for the slot record component
      patterns - the value for the patterns record component
  • Method Details

    • enableCache

      @Internal public static void enableCache()
      Enables caching objects.
    • disableCache

      @Internal public static void disableCache()
      Disables caching objects.
    • create

      @NotNull public static @NotNull IngredientHolder create(int slot, @NotNull @NotNull @Unmodifiable List<BoxIngredientItem> patterns)
    • fromMaterialChoice

      @NotNull public static @NotNull IngredientHolder fromMaterialChoice(int slot, @NotNull org.bukkit.inventory.RecipeChoice.MaterialChoice choice)
      Creates a IngredientHolder from RecipeChoice.MaterialChoice.
      Parameters:
      slot - the position in the crafting table (0-8)
      choice - the RecipeChoice.MaterialChoice instance to create IngredientHolder
      Returns:
      a IngredientHolder
    • fromExactChoice

      @NotNull public static @NotNull IngredientHolder fromExactChoice(int slot, @NotNull org.bukkit.inventory.RecipeChoice.ExactChoice choice)
      Creates a IngredientHolder from RecipeChoice.ExactChoice.
      Parameters:
      slot - the position in the crafting table (0-8)
      choice - the RecipeChoice.ExactChoice instance to create IngredientHolder
      Returns:
      a IngredientHolder
    • fromSingleItem

      @NotNull public static @NotNull IngredientHolder fromSingleItem(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Creates a IngredientHolder from the single ItemStack.
      Parameters:
      slot - the position in the crafting table (0-8)
      itemStack - the ItemStack to create IngredientHolder
      Returns:
      a IngredientHolder
    • slot

      public int slot()
      Returns the position in the crafting table (0-8).

      A 3x3 craft table is represented by the following numbers:

      0 1 2
      3 4 5
      6 7 8

      Returns:
      the position in the crafting table (0-8)
    • 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.
    • patterns

      @NotNull public @NotNull @Unmodifiable List<BoxIngredientItem> patterns()
      Returns the value of the patterns record component.
      Returns:
      the value of the patterns record component