mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-07 23:52:11 -07:00
#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:
@@ -13,7 +13,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a potential item match within a recipe. All choices within a
|
* 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>
|
* <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");
|
Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice");
|
||||||
for (Material choice : choices) {
|
for (Material choice : choices) {
|
||||||
Preconditions.checkArgument(choice != null, "Cannot have null choice");
|
Preconditions.checkArgument(choice != null, "Cannot have null choice");
|
||||||
|
Preconditions.checkArgument(!choice.isAir(), "Cannot have empty/air choice");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.choices = new ArrayList<>(choices);
|
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");
|
Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice");
|
||||||
for (ItemStack choice : choices) {
|
for (ItemStack choice : choices) {
|
||||||
Preconditions.checkArgument(choice != null, "Cannot have null choice");
|
Preconditions.checkArgument(choice != null, "Cannot have null choice");
|
||||||
|
Preconditions.checkArgument(!choice.getType().isAir(), "Cannot have empty/air choice");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.choices = new ArrayList<>(choices);
|
this.choices = new ArrayList<>(choices);
|
||||||
|
Reference in New Issue
Block a user