From afaa0a1d88328616632e0446a758d86a72e9accb Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot <noreply+git-bukkit@papermc.io> Date: Sun, 15 Sep 2024 16:50:14 +1000 Subject: [PATCH] SPIGOT-7899: Smithing recipes don't require inputs By: md_5 <git@md-5.net> --- .../java/org/bukkit/inventory/SmithingRecipe.java | 11 ++++++----- .../org/bukkit/inventory/SmithingTransformRecipe.java | 7 ++++--- .../java/org/bukkit/inventory/SmithingTrimRecipe.java | 7 ++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/inventory/SmithingRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/SmithingRecipe.java index 0235f4aa50..717878019a 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/SmithingRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/SmithingRecipe.java @@ -3,6 +3,7 @@ package org.bukkit.inventory; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a smithing recipe. @@ -27,7 +28,7 @@ public class SmithingRecipe implements Recipe, Keyed { * added to the server. */ @Deprecated - public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { + public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @Nullable RecipeChoice base, @Nullable RecipeChoice addition) { this.key = key; this.result = result; this.base = base; @@ -39,9 +40,9 @@ public class SmithingRecipe implements Recipe, Keyed { * * @return base choice */ - @NotNull + @Nullable public RecipeChoice getBase() { - return base.clone(); + return (base != null) ? base.clone() : null; } /** @@ -49,9 +50,9 @@ public class SmithingRecipe implements Recipe, Keyed { * * @return addition choice */ - @NotNull + @Nullable public RecipeChoice getAddition() { - return addition.clone(); + return (addition != null) ? addition.clone() : null; } @NotNull diff --git a/paper-api/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java index 08fd3eca83..7a9d77a0cd 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java @@ -2,6 +2,7 @@ package org.bukkit.inventory; import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a smithing transform recipe. @@ -19,7 +20,7 @@ public class SmithingTransformRecipe extends SmithingRecipe { * @param base The base ingredient * @param addition The addition ingredient */ - public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { + public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @Nullable RecipeChoice template, @Nullable RecipeChoice base, @Nullable RecipeChoice addition) { super(key, result, base, addition); this.template = template; } @@ -29,8 +30,8 @@ public class SmithingTransformRecipe extends SmithingRecipe { * * @return template choice */ - @NotNull + @Nullable public RecipeChoice getTemplate() { - return template.clone(); + return (template != null) ? template.clone() : null; } } diff --git a/paper-api/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java index 32cbdc3426..4271c54cfb 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java @@ -3,6 +3,7 @@ package org.bukkit.inventory; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a smithing trim recipe. @@ -19,7 +20,7 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe * @param base The base ingredient * @param addition The addition ingredient */ - public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { + public SmithingTrimRecipe(@NotNull NamespacedKey key, @Nullable RecipeChoice template, @Nullable RecipeChoice base, @Nullable RecipeChoice addition) { super(key, new ItemStack(Material.AIR), base, addition); this.template = template; } @@ -29,8 +30,8 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe * * @return template choice */ - @NotNull + @Nullable public RecipeChoice getTemplate() { - return template.clone(); + return (template != null) ? template.clone() : null; } }