Class CauldronIngredientMaterial

java.lang.Object
wtf.choco.alchema.crafting.CauldronIngredientMaterial
All Implemented Interfaces:
CauldronIngredient

public class CauldronIngredientMaterial
extends java.lang.Object
implements CauldronIngredient
A CauldronIngredient implementation wrapped around Material. This ingredient does not care about specific ItemMeta and will match any item such that the material matches.
Author:
Parker Hawke - Choco
  • Field Summary

    Fields
    Modifier and Type Field Description
    static org.bukkit.NamespacedKey KEY
    The NamespacedKey used for this ingredient type
  • Constructor Summary

    Constructors
    Constructor Description
    CauldronIngredientMaterial​(@NotNull com.google.gson.JsonObject object)
    Construct a new CauldronIngredientMaterial deserialized from the provided JsonObject.
    CauldronIngredientMaterial​(@NotNull org.bukkit.Material material)
    Construct a new CauldronIngredientMaterial with an amount of 1.
    CauldronIngredientMaterial​(@NotNull org.bukkit.Material material, int amount)
    Construct a new CauldronIngredientMaterial with a given amount.
  • Method Summary

    Modifier and Type Method Description
    @NotNull CauldronIngredient adjustAmountBy​(int amount)
    Return a new cauldron ingredient with the amount changed by the specified amount.
    @NotNull org.bukkit.inventory.ItemStack asItemStack()
    Get this ingredient represented as an ItemStack, if possible.
    boolean equals​(java.lang.Object obj)  
    int getAmount()
    Get the amount of this ingredient.
    @NotNull org.bukkit.NamespacedKey getKey()
    Get the key for this ingredient type.
    int hashCode()  
    boolean isSimilar​(@NotNull CauldronIngredient other)
    Check whether this ingredient is similar to the provided ingredient.
    @NotNull CauldronIngredient merge​(@NotNull CauldronIngredient other)
    Merge this ingredient with another ingredient.
    @NotNull com.google.gson.JsonObject toJson()
    Serialize this ingredient to a JsonObject.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface wtf.choco.alchema.crafting.CauldronIngredient

    drop
  • Field Details

    • KEY

      public static final org.bukkit.NamespacedKey KEY
      The NamespacedKey used for this ingredient type
  • Constructor Details

    • CauldronIngredientMaterial

      public CauldronIngredientMaterial​(@NotNull @NotNull org.bukkit.Material material, int amount)
      Construct a new CauldronIngredientMaterial with a given amount.
      Parameters:
      material - the material
      amount - the amount of material
    • CauldronIngredientMaterial

      public CauldronIngredientMaterial​(@NotNull @NotNull org.bukkit.Material material)
      Construct a new CauldronIngredientMaterial with an amount of 1.
      Parameters:
      material - the material
    • CauldronIngredientMaterial

      public CauldronIngredientMaterial​(@NotNull @NotNull com.google.gson.JsonObject object)
      Construct a new CauldronIngredientMaterial deserialized from the provided JsonObject.
      Parameters:
      object - the object from which to deserialize
  • Method Details

    • getKey

      @NotNull public @NotNull org.bukkit.NamespacedKey getKey()
      Description copied from interface: CauldronIngredient
      Get the key for this ingredient type.
      Specified by:
      getKey in interface CauldronIngredient
      Returns:
      the ingredient key
    • getAmount

      public int getAmount()
      Description copied from interface: CauldronIngredient
      Get the amount of this ingredient.
      Specified by:
      getAmount in interface CauldronIngredient
      Returns:
      the ingredient amount
    • asItemStack

      @NotNull public @NotNull org.bukkit.inventory.ItemStack asItemStack()
      Description copied from interface: CauldronIngredient
      Get this ingredient represented as an ItemStack, if possible.
      Specified by:
      asItemStack in interface CauldronIngredient
      Returns:
      the item stack. null if no item stack representation
    • isSimilar

      public boolean isSimilar​(@NotNull @NotNull CauldronIngredient other)
      Description copied from interface: CauldronIngredient
      Check whether this ingredient is similar to the provided ingredient. The ingredient amount is not taken into consideration when comparing.
      Specified by:
      isSimilar in interface CauldronIngredient
      Parameters:
      other - the other ingredient against which to compare
      Returns:
      true if similar, false otherwise
    • merge

      @NotNull public @NotNull CauldronIngredient merge​(@NotNull @NotNull CauldronIngredient other)
      Description copied from interface: CauldronIngredient
      Merge this ingredient with another ingredient. The result of this method should be a new ingredient with the combined amounts of this ingredient and the one passed.
      Specified by:
      merge in interface CauldronIngredient
      Parameters:
      other - the other ingredient
      Returns:
      the merged ingredient
    • adjustAmountBy

      @NotNull public @NotNull CauldronIngredient adjustAmountBy​(int amount)
      Description copied from interface: CauldronIngredient
      Return a new cauldron ingredient with the amount changed by the specified amount. The amount can be either negative or positive but must not result in a negative or zero amount (i.e. if getAmount() - amount is 0 or negative, an exception will be thrown).
      Specified by:
      adjustAmountBy in interface CauldronIngredient
      Parameters:
      amount - the change in amount to apply
      Returns:
      the new ingredient
    • toJson

      @NotNull public @NotNull com.google.gson.JsonObject toJson()
      Description copied from interface: CauldronIngredient
      Serialize this ingredient to a JsonObject.
      Specified by:
      toJson in interface CauldronIngredient
      Returns:
      the serialized json
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object