Minestom/src/main/java/net/minestom/server/recipe/ShapelessRecipe.java

56 lines
1.5 KiB
Java
Raw Normal View History

2020-04-24 03:25:58 +02:00
package net.minestom.server.recipe;
2020-04-01 13:16:18 +02:00
2020-04-24 03:25:58 +02:00
import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
2020-04-01 13:16:18 +02:00
import java.util.LinkedList;
2020-04-01 13:16:18 +02:00
import java.util.List;
import java.util.Objects;
2020-04-01 13:16:18 +02:00
public abstract class ShapelessRecipe extends Recipe {
private String group;
private final List<DeclareRecipesPacket.Ingredient> ingredients;
private ItemStack result;
protected ShapelessRecipe(
@NotNull String recipeId,
@NotNull String group,
@Nullable List<DeclareRecipesPacket.Ingredient> ingredients,
@NotNull ItemStack result
) {
super(RecipeType.SHAPELESS, recipeId);
this.group = group;
this.ingredients = Objects.requireNonNullElseGet(ingredients, LinkedList::new);
this.result = result;
}
2020-04-01 13:16:18 +02:00
@NotNull
public String getGroup() {
return group;
}
2020-04-01 13:16:18 +02:00
public void setGroup(@NotNull String group) {
this.group = group;
2020-04-01 13:16:18 +02:00
}
public void addIngredient(DeclareRecipesPacket.Ingredient ingredient) {
ingredients.add(ingredient);
}
@NotNull
2020-04-01 13:16:18 +02:00
public List<DeclareRecipesPacket.Ingredient> getIngredients() {
return ingredients;
}
@NotNull
2020-04-01 13:16:18 +02:00
public ItemStack getResult() {
return result;
}
public void setResult(@NotNull ItemStack result) {
2020-04-01 13:16:18 +02:00
this.result = result;
}
}