SPIGOT-7899: Smithing recipes don't require inputs

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2024-09-15 16:50:14 +10:00
parent f585e110be
commit afaa0a1d88
3 changed files with 14 additions and 11 deletions

View file

@ -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

View file

@ -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;
}
}

View file

@ -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;
}
}