From 25c8c8a3da55e9c76eb7dd8bbb9aec135a04cf78 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot <noreply+git-bukkit@papermc.io> Date: Tue, 14 May 2024 19:52:25 +1000 Subject: [PATCH] #1011: Throw an exception if a RecipeChoice is ever supplied air This would otherwise crash the client. By: 2008Choco <hawkeboyz2@hotmail.com> --- .../src/main/java/org/bukkit/inventory/RecipeChoice.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/inventory/RecipeChoice.java b/paper-api/src/main/java/org/bukkit/inventory/RecipeChoice.java index 6734bc9d7a..5b7ddf5f3e 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/RecipeChoice.java +++ b/paper-api/src/main/java/org/bukkit/inventory/RecipeChoice.java @@ -13,7 +13,8 @@ import org.jetbrains.annotations.NotNull; /** * Represents a potential item match within a recipe. All choices within a - * recipe must be satisfied for it to be craftable. + * recipe must be satisfied for it to be craftable. Choices must never be + * null or air. * * <b>This class is not legal for implementation by plugins!</b> */ @@ -66,6 +67,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable { Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice"); for (Material choice : choices) { Preconditions.checkArgument(choice != null, "Cannot have null choice"); + Preconditions.checkArgument(!choice.isAir(), "Cannot have empty/air choice"); } this.choices = new ArrayList<>(choices); @@ -166,6 +168,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable { Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice"); for (ItemStack choice : choices) { Preconditions.checkArgument(choice != null, "Cannot have null choice"); + Preconditions.checkArgument(!choice.getType().isAir(), "Cannot have empty/air choice"); } this.choices = new ArrayList<>(choices);