Package wtf.choco.alchema.crafting
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
TheNamespacedKey
used for this ingredient type -
Constructor Summary
Constructors Constructor Description CauldronIngredientMaterial(@NotNull com.google.gson.JsonObject object)
Construct a newCauldronIngredientMaterial
deserialized from the providedJsonObject
.CauldronIngredientMaterial(@NotNull org.bukkit.Material material)
Construct a newCauldronIngredientMaterial
with an amount of 1.CauldronIngredientMaterial(@NotNull org.bukkit.Material material, int amount)
Construct a newCauldronIngredientMaterial
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 anItemStack
, 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 aJsonObject
.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 KEYTheNamespacedKey
used for this ingredient type
-
-
Constructor Details
-
CauldronIngredientMaterial
public CauldronIngredientMaterial(@NotNull @NotNull org.bukkit.Material material, int amount)Construct a newCauldronIngredientMaterial
with a given amount.- Parameters:
material
- the materialamount
- the amount of material
-
CauldronIngredientMaterial
public CauldronIngredientMaterial(@NotNull @NotNull org.bukkit.Material material)Construct a newCauldronIngredientMaterial
with an amount of 1.- Parameters:
material
- the material
-
CauldronIngredientMaterial
public CauldronIngredientMaterial(@NotNull @NotNull com.google.gson.JsonObject object)Construct a newCauldronIngredientMaterial
deserialized from the providedJsonObject
.- 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 interfaceCauldronIngredient
- Returns:
- the ingredient key
-
getAmount
public int getAmount()Description copied from interface:CauldronIngredient
Get the amount of this ingredient.- Specified by:
getAmount
in interfaceCauldronIngredient
- Returns:
- the ingredient amount
-
asItemStack
@NotNull public @NotNull org.bukkit.inventory.ItemStack asItemStack()Description copied from interface:CauldronIngredient
Get this ingredient represented as anItemStack
, if possible.- Specified by:
asItemStack
in interfaceCauldronIngredient
- Returns:
- the item stack. null if no item stack representation
-
isSimilar
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 interfaceCauldronIngredient
- Parameters:
other
- the other ingredient against which to compare- Returns:
- true if similar, false otherwise
-
merge
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 interfaceCauldronIngredient
- Parameters:
other
- the other ingredient- Returns:
- the merged ingredient
-
adjustAmountBy
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. ifgetAmount() - amount
is 0 or negative, an exception will be thrown).- Specified by:
adjustAmountBy
in interfaceCauldronIngredient
- 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 aJsonObject
.- Specified by:
toJson
in interfaceCauldronIngredient
- Returns:
- the serialized json
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-