Validate using_converts_to for food component (#10931)

This commit is contained in:
Lulu13022002 2024-06-21 18:48:48 +02:00 committed by GitHub
parent d64be7e10a
commit 081146c56e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1499,7 +1499,7 @@ index 8b407a33b04af6ae396ada0b8aca7dc246d314ef..d204845cf0b9de00589593469755cb8e
+ // Paper end - General ItemMeta Fixes + // Paper end - General ItemMeta Fixes
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java
index 63fc9138dc3388ceb9acf672b3f75ba0976e8e54..cad52601583c1f304f94de954c4d18a6005906e3 100644 index 63fc9138dc3388ceb9acf672b3f75ba0976e8e54..5986aa3588487c2caef4c895f8883e38a674b61c 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java
@@ -109,6 +109,7 @@ public final class CraftFoodComponent implements FoodComponent { @@ -109,6 +109,7 @@ public final class CraftFoodComponent implements FoodComponent {
@ -1510,7 +1510,15 @@ index 63fc9138dc3388ceb9acf672b3f75ba0976e8e54..cad52601583c1f304f94de954c4d18a6
this.handle = new FoodProperties(this.handle.nutrition(), this.handle.saturation(), this.handle.canAlwaysEat(), eatSeconds, this.handle.usingConvertsTo(), this.handle.effects()); this.handle = new FoodProperties(this.handle.nutrition(), this.handle.saturation(), this.handle.canAlwaysEat(), eatSeconds, this.handle.usingConvertsTo(), this.handle.effects());
} }
@@ -134,6 +135,7 @@ public final class CraftFoodComponent implements FoodComponent { @@ -119,6 +120,7 @@ public final class CraftFoodComponent implements FoodComponent {
@Override
public void setUsingConvertsTo(ItemStack item) {
+ Preconditions.checkArgument(item == null || !item.isEmpty(), "Item cannot be empty"); // Paper - validate using_converts_to
this.handle = new FoodProperties(this.handle.nutrition(), this.handle.saturation(), this.handle.canAlwaysEat(), this.handle.eatSeconds(), Optional.ofNullable(item).map(CraftItemStack::asNMSCopy), this.handle.effects());
}
@@ -134,6 +136,7 @@ public final class CraftFoodComponent implements FoodComponent {
@Override @Override
public FoodEffect addEffect(PotionEffect effect, float probability) { public FoodEffect addEffect(PotionEffect effect, float probability) {