diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/BlastingRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/BlastingRecipeIngredients.kt index b7da249a..b7720d4b 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/BlastingRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/BlastingRecipeIngredients.kt @@ -8,18 +8,20 @@ import org.bukkit.inventory.BlastingRecipe import org.bukkit.inventory.ItemStack import org.bukkit.inventory.Recipe import org.bukkit.inventory.RecipeChoice +import org.bukkit.inventory.recipe.CookingBookCategory @Serializable @SerialName("blasting") class BlastingRecipeIngredients( val input: SerializableItemStack, val experience: Float, - val cookingTime: Int + val cookingTime: Int, ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { val recipe = BlastingRecipe(key, result, RecipeChoice.ExactChoice(input.toItemStack()), experience, cookingTime) recipe.group = group + recipe.category = CookingBookCategory.entries.find { it.name == category } ?: CookingBookCategory.MISC return recipe } diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/CampfireRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/CampfireRecipeIngredients.kt index a83394ba..08408ddc 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/CampfireRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/CampfireRecipeIngredients.kt @@ -8,18 +8,20 @@ import org.bukkit.inventory.CampfireRecipe import org.bukkit.inventory.ItemStack import org.bukkit.inventory.Recipe import org.bukkit.inventory.RecipeChoice +import org.bukkit.inventory.recipe.CookingBookCategory @Serializable @SerialName("campfire") class CampfireRecipeIngredients( val input: SerializableItemStack, val experience: Float, - val cookingTime: Int + val cookingTime: Int, ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { val recipe = CampfireRecipe(key, result, RecipeChoice.ExactChoice(input.toItemStack()), experience, cookingTime) recipe.group = group + recipe.category = CookingBookCategory.entries.find { it.name == category } ?: CookingBookCategory.MISC return recipe } diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/FurnaceRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/FurnaceRecipeIngredients.kt index e1a7b36b..48093f51 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/FurnaceRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/FurnaceRecipeIngredients.kt @@ -8,18 +8,20 @@ import org.bukkit.inventory.FurnaceRecipe import org.bukkit.inventory.ItemStack import org.bukkit.inventory.Recipe import org.bukkit.inventory.RecipeChoice +import org.bukkit.inventory.recipe.CookingBookCategory @Serializable @SerialName("furnace") class FurnaceRecipeIngredients( val input: SerializableItemStack, val experience: Float, - val cookingTime: Int + val cookingTime: Int, ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { val recipe = FurnaceRecipe(key, result, RecipeChoice.ExactChoice(input.toItemStack()), experience, cookingTime) recipe.group = group + recipe.category = CookingBookCategory.entries.find { it.name == category } ?: CookingBookCategory.MISC return recipe } diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SerializableRecipe.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SerializableRecipe.kt index e022d286..876f2d75 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SerializableRecipe.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SerializableRecipe.kt @@ -10,7 +10,9 @@ class SerializableRecipe( val ingredients: SerializableRecipeIngredients, val result: SerializableItemStack, val group: String = "", + val category: String = "MISC" ) { - fun toCraftingRecipe() = - ingredients.toRecipe(key.toMCKey(), result.toItemStack(), group) + fun toCraftingRecipe() { + ingredients.toRecipe(key.toMCKey(), result.toItemStack(), group, category) + } } \ No newline at end of file diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SerializableRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SerializableRecipeIngredients.kt index 39bea710..fb927854 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SerializableRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SerializableRecipeIngredients.kt @@ -7,5 +7,5 @@ import org.bukkit.inventory.Recipe @Serializable sealed class SerializableRecipeIngredients { - abstract fun toRecipe(key: NamespacedKey, result: ItemStack, group: String = ""): Recipe + abstract fun toRecipe(key: NamespacedKey, result: ItemStack, group: String = "", category: String = "MISC"): Recipe } \ No newline at end of file diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/ShapedRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/ShapedRecipeIngredients.kt index 2a4e96b8..d85f0503 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/ShapedRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/ShapedRecipeIngredients.kt @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack import org.bukkit.inventory.Recipe import org.bukkit.inventory.RecipeChoice import org.bukkit.inventory.ShapedRecipe +import org.bukkit.inventory.recipe.CraftingBookCategory @Serializable @SerialName("shaped") @@ -18,12 +19,13 @@ class ShapedRecipeIngredients( val items: Map, val configuration: String = "", ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { val recipe = ShapedRecipe(key, result) recipe.shape(*configuration.replace("|", "").split("\n").toTypedArray()) recipe.group = group + recipe.category = CraftingBookCategory.entries.find { it.name == category } ?: CraftingBookCategory.MISC items.forEach { (key, ingredient) -> if (ingredient.tag?.isNotEmpty() == true) { diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/ShapelessRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/ShapelessRecipeIngredients.kt index d33b3e71..564ed26c 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/ShapelessRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/ShapelessRecipeIngredients.kt @@ -11,16 +11,18 @@ import org.bukkit.inventory.ItemStack import org.bukkit.inventory.Recipe import org.bukkit.inventory.RecipeChoice import org.bukkit.inventory.ShapelessRecipe +import org.bukkit.inventory.recipe.CraftingBookCategory @Serializable @SerialName("shapeless") class ShapelessRecipeIngredients( val items: List, ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { val recipe = ShapelessRecipe(key, result) recipe.group = group + recipe.category = CraftingBookCategory.entries.find { it.name == category } ?: CraftingBookCategory.MISC items.forEach { ingredient -> if (ingredient.tag?.isNotEmpty() == true) { diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmithingTransformRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmithingTransformRecipeIngredients.kt index c91be479..8f095750 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmithingTransformRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmithingTransformRecipeIngredients.kt @@ -18,7 +18,7 @@ class SmithingTransformRecipeIngredients( val addition: SerializableItemStack, val copyNbt: Boolean = false ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { return SmithingTransformRecipe( key, result, diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmithingTrimRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmithingTrimRecipeIngredients.kt index 13d2a92d..06cf82ab 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmithingTrimRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmithingTrimRecipeIngredients.kt @@ -18,7 +18,7 @@ class SmithingTrimRecipeIngredients( val addition: SerializableItemStack, val copyNbt: Boolean = false ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { return SmithingTrimRecipe( key, RecipeChoice.ExactChoice(template.toItemStack()), diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmokingRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmokingRecipeIngredients.kt index 1a2c3a77..c8877947 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmokingRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/SmokingRecipeIngredients.kt @@ -8,19 +8,21 @@ import org.bukkit.inventory.ItemStack import org.bukkit.inventory.Recipe import org.bukkit.inventory.RecipeChoice import org.bukkit.inventory.SmokingRecipe +import org.bukkit.inventory.recipe.CookingBookCategory @Serializable @SerialName("smoking") class SmokingRecipeIngredients( val input: SerializableItemStack, val experience: Float, - val cookingTime: Int + val cookingTime: Int, ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { val recipe = SmokingRecipe(key, result, RecipeChoice.ExactChoice(input.toItemStack()), experience, cookingTime) recipe.group = group + recipe.category = CookingBookCategory.entries.find { it.name == category } ?: CookingBookCategory.MISC return recipe } } \ No newline at end of file diff --git a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/StonecuttingRecipeIngredients.kt b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/StonecuttingRecipeIngredients.kt index 72d8fadf..2d7df44b 100644 --- a/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/StonecuttingRecipeIngredients.kt +++ b/idofront-serializers/src/main/kotlin/com/mineinabyss/idofront/serialization/recipes/StonecuttingRecipeIngredients.kt @@ -14,7 +14,7 @@ import org.bukkit.inventory.StonecuttingRecipe class StonecuttingRecipeIngredients( val input: SerializableItemStack, ) : SerializableRecipeIngredients() { - override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String): Recipe { + override fun toRecipe(key: NamespacedKey, result: ItemStack, group: String, category: String): Recipe { val recipe = StonecuttingRecipe(key, result, RecipeChoice.ExactChoice(input.toItemStack())) recipe.group = group