mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Ensure MaterialChoice materials are items (#11325)
This commit is contained in:
parent
50b7f46507
commit
5f317598d4
1 changed files with 21 additions and 0 deletions
|
@ -13,6 +13,9 @@ recipes and ingredient slots.
|
||||||
Also fixes some issues regarding mutability of both ItemStack
|
Also fixes some issues regarding mutability of both ItemStack
|
||||||
and implementations of RecipeChoice.
|
and implementations of RecipeChoice.
|
||||||
|
|
||||||
|
Also adds some validation regarding Materials passed to RecipeChoice
|
||||||
|
being items.
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/inventory/CookingRecipe.java b/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
diff --git a/src/main/java/org/bukkit/inventory/CookingRecipe.java b/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
--- a/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
||||||
|
@ -163,6 +166,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
/**
|
/**
|
||||||
* Represents a choice of multiple matching Materials.
|
* Represents a choice of multiple matching Materials.
|
||||||
*/
|
*/
|
||||||
|
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||||
|
* @param choices the tag
|
||||||
|
*/
|
||||||
|
public MaterialChoice(@NotNull Tag<Material> choices) {
|
||||||
|
- Preconditions.checkArgument(choices != null, "choices");
|
||||||
|
- this.choices = new ArrayList<>(choices.getValues());
|
||||||
|
+ this(new ArrayList<>(java.util.Objects.requireNonNull(choices, "Cannot create a material choice with null tag").getValues())); // Paper - delegate to list ctor to make sure all checks are called
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialChoice(@NotNull List<Material> choices) {
|
||||||
|
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||||
|
}
|
||||||
|
|
||||||
|
Preconditions.checkArgument(!choice.isAir(), "Cannot have empty/air choice");
|
||||||
|
+ Preconditions.checkArgument(choice.isItem(), "Cannot have non-item choice %s", choice); // Paper - validate material choice input to items
|
||||||
|
this.choices.add(choice);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MaterialChoice{" + "choices=" + choices + '}';
|
return "MaterialChoice{" + "choices=" + choices + '}';
|
||||||
|
|
Loading…
Reference in a new issue