diff --git a/patches/api/Fix-equipment-slot-and-group-API.patch b/patches/api/Fix-equipment-slot-and-group-API.patch index 58fcf467bd..bc470bb53f 100644 --- a/patches/api/Fix-equipment-slot-and-group-API.patch +++ b/patches/api/Fix-equipment-slot-and-group-API.patch @@ -3,7 +3,11 @@ From: Jake Potrebic Date: Wed, 22 May 2024 10:00:19 -0700 Subject: [PATCH] Fix equipment slot and group API -was missing the 'body' slot group +Adds the following: +- Add missing 'body' slot group +- Expose LivingEntity#canUseSlot + +Co-authored-by: SoSeDiK diff --git a/src/main/java/org/bukkit/attribute/AttributeModifier.java b/src/main/java/org/bukkit/attribute/AttributeModifier.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -17,6 +21,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public EquipmentSlot getSlot() { return slot == EquipmentSlotGroup.ANY ? null : slot.getExample(); } +diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/LivingEntity.java ++++ b/src/main/java/org/bukkit/entity/LivingEntity.java +@@ -0,0 +0,0 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource + */ + void setBodyYaw(float bodyYaw); + // Paper end - body yaw API ++ ++ // Paper start - Expose canUseSlot ++ /** ++ * Checks whether this entity can use the equipment slot. ++ *
For example, not all entities may have {@link org.bukkit.inventory.EquipmentSlot#BODY}. ++ * ++ * @param slot equipment slot ++ * @return whether this entity can use the equipment slot ++ */ ++ boolean canUseEquipmentSlot(org.bukkit.inventory.@NotNull EquipmentSlot slot); ++ // Paper end - Expose canUseSlot + } diff --git a/src/main/java/org/bukkit/inventory/EntityEquipment.java b/src/main/java/org/bukkit/inventory/EntityEquipment.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/EntityEquipment.java @@ -26,6 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @param slot the slot to put the ItemStack * @param item the ItemStack to set + * @throws IllegalArgumentException if the slot is invalid for the entity ++ * @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot) */ public void setItem(@NotNull EquipmentSlot slot, @Nullable ItemStack item); @@ -36,6 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - * @param silent whether or not the equip sound should be silenced + * @param silent whether the equip sound should be silenced + * @throws IllegalArgumentException if the slot is invalid for the entity ++ * @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot) */ public void setItem(@NotNull EquipmentSlot slot, @Nullable ItemStack item, boolean silent); @@ -44,6 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @param slot the slot to get the ItemStack * @return the ItemStack in the given slot + * @throws IllegalArgumentException if the slot is invalid for the entity ++ * @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot) */ @NotNull public ItemStack getItem(@NotNull EquipmentSlot slot); @@ -74,3 +101,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // private final String key; private final Predicate predicate; +diff --git a/src/main/java/org/bukkit/inventory/PlayerInventory.java b/src/main/java/org/bukkit/inventory/PlayerInventory.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/PlayerInventory.java ++++ b/src/main/java/org/bukkit/inventory/PlayerInventory.java +@@ -0,0 +0,0 @@ public interface PlayerInventory extends Inventory { + * @param slot the slot to put the ItemStack + * @param item the ItemStack to set + * ++ * @throws IllegalArgumentException if the slot is invalid for the player ++ * @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot) + * @see #setItem(int, ItemStack) + */ + public void setItem(@NotNull EquipmentSlot slot, @Nullable ItemStack item); +@@ -0,0 +0,0 @@ public interface PlayerInventory extends Inventory { + * @param slot the slot to get the ItemStack + * + * @return the ItemStack in the given slot ++ * @throws IllegalArgumentException if the slot is invalid for the player ++ * @see org.bukkit.entity.LivingEntity#canUseEquipmentSlot(EquipmentSlot) + */ + @NotNull // Paper + public ItemStack getItem(@NotNull EquipmentSlot slot); diff --git a/patches/server/Fix-equipment-slot-and-group-API.patch b/patches/server/Fix-equipment-slot-and-group-API.patch index fc3093c1d5..43b39e66c8 100644 --- a/patches/server/Fix-equipment-slot-and-group-API.patch +++ b/patches/server/Fix-equipment-slot-and-group-API.patch @@ -3,8 +3,28 @@ From: Jake Potrebic Date: Wed, 22 May 2024 10:01:19 -0700 Subject: [PATCH] Fix equipment slot and group API -Add test for EquipmentSlotGroup +Adds the following: +- Add test for EquipmentSlotGroup +- Expose LivingEntity#canUseSlot +Co-authored-by: SoSeDiK + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { + this.getHandle().setYBodyRot(bodyYaw); + } + // Paper end - body yaw API ++ ++ // Paper start - Expose canUseSlot ++ @Override ++ public boolean canUseEquipmentSlot(org.bukkit.inventory.EquipmentSlot slot) { ++ return this.getHandle().canUseSlot(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot)); ++ } ++ // Paper end - Expose canUseSlot + } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java