#1011: Throw an exception if a RecipeChoice is ever supplied air

This would otherwise crash the client.

By: 2008Choco <hawkeboyz2@hotmail.com>
This commit is contained in:
Bukkit/Spigot 2024-05-14 19:52:25 +10:00
parent 30784afe2f
commit 25c8c8a3da

View file

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