mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 03:55:14 +01:00
3b9db2b194
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bb4e97c6 Add support for Java 23 bc6874dd Bump asm to 9.7.1 50e8a00b PR-1064: Add specific getTopInventory methods for InventoryView derivatives 758b0a0f SPIGOT-7911: Fix Location#isWorldLoaded() for re-loaded worlds 133a64a7 Improve Registry#getOrThrow messages be0f5957 PR-1058: Add tests for Minecraft registry <-> Bukkit fields d1b31df2 PR-1062: Clarify BeaconView documentation 3fab4384 PR-1060: Cache Material to BlockType and ItemType conversion 967a7301 SPIGOT-7906: Increase YAML nesting limit to 100 6ecf033d SPIGOT-7899: Smithing recipes don't require inputs CraftBukkit Changes: 0a7bd6c81 PR-1493: Improve reroute performance and add some tests 54941524c Add support for Java 23 f4d957fff SPIGOT-7915: Fix World#getKeepSpawnInMemory() using Spawn Radius rather than Spawn Chunk Radius ded183674 Fix HIDE_ENCHANTS flag in items without enchantments 308785a0a Bump asm to 9.7.1 and re-add ClassReader to ClassWriter 72ce823cd PR-1487: Add specific getTopInventory methods for InventoryView derivatives 11a5e840c SPIGOT-7907, PR-1484: Improve merchant recipe item matching behavior to more closely align with older versions 45b66f7e4 SPIGOT-7909: Always set HIDE_ENCHANTS flag to item if flag is set 963459791 Increase outdated build delay fc5b2d75f SPIGOT-7910: Fix launching breeze wind charge from API and improve dispenser launch API c7d6428f2 SPIGOT-7856, PR-1483: End platform not dropping items after replacing blocks 2a5572b52 SPIGOT-7780, PR-1482: Cannot edit chunks during unload event 527041ab5 SPIGOT-7902, PR-1477: Fix CraftMetaPotion#hasCustomEffects() does not check if customEffects (List) is empty 5529a1769 Implement base methods for tags 30fbdbaaf Improve Registry#getOrThrow messages 6b71a7322 PR-1475: Add tests for Minecraft registry <-> Bukkit fields 5f24c255c SPIGOT-7908: Mark junit-platform-suite-engine as test scope e4c92ef65 PR-1473: Change tests to use suites, to run tests in different environments and feature flags d25e1e722 PR-1481: Fix BeaconView#set[X]Effect(null) d69a05362 PR-1480: Fix PerMaterialTest#isEdible test running for legacy materials bb3284a89 PR-1479: Use custom #isBlock method in legacy init instead of the one in Material, since it relies on legacy being init 98c57cbbe SPIGOT-7904: Fix NPE for PlayerItemBreakEvent f35bae9ec Fix missing hasJukeboxPlayable 8a6f8b6d8 SPIGOT-7881: CTRL+Pick Block saves position data into item 7913b3be7 SPIGOT-7899: Smithing recipes don't require inputs
126 lines
6.9 KiB
Diff
126 lines
6.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Wed, 22 May 2024 10:00:19 -0700
|
|
Subject: [PATCH] Fix equipment slot and group API
|
|
|
|
Adds the following:
|
|
- Add missing 'body' slot group
|
|
- Expose LivingEntity#canUseSlot
|
|
|
|
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
|
|
|
|
diff --git a/src/main/java/org/bukkit/attribute/AttributeModifier.java b/src/main/java/org/bukkit/attribute/AttributeModifier.java
|
|
index def473b6424da1e81448bd492b7fef46691eaf8c..027a7d3b6feb52f6c3424edc0820d29fdaf6ebae 100644
|
|
--- a/src/main/java/org/bukkit/attribute/AttributeModifier.java
|
|
+++ b/src/main/java/org/bukkit/attribute/AttributeModifier.java
|
|
@@ -130,6 +130,7 @@ public class AttributeModifier implements ConfigurationSerializable, Keyed {
|
|
*/
|
|
@Nullable
|
|
@Deprecated
|
|
+ @io.papermc.paper.annotation.DoNotUse // Paper
|
|
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 51a428473e702be3ab79bd1e579d1114f747791b..68c08e7a212bc3e3885f9b5a4d9aef85fcb3b029 100644
|
|
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
|
@@ -1457,4 +1457,15 @@ 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.
|
|
+ * <br>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 1b34286fb6cbedb3841c84c499eb626f61885126..91cd0a918b640df7e75f6e40f3c6bd3689d4ff40 100644
|
|
--- a/src/main/java/org/bukkit/inventory/EntityEquipment.java
|
|
+++ b/src/main/java/org/bukkit/inventory/EntityEquipment.java
|
|
@@ -15,6 +15,8 @@ public interface EntityEquipment {
|
|
*
|
|
* @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);
|
|
|
|
@@ -23,7 +25,9 @@ public interface EntityEquipment {
|
|
*
|
|
* @param slot the slot to put the ItemStack
|
|
* @param item the ItemStack to set
|
|
- * @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);
|
|
|
|
@@ -32,6 +36,8 @@ public interface EntityEquipment {
|
|
*
|
|
* @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);
|
|
diff --git a/src/main/java/org/bukkit/inventory/EquipmentSlot.java b/src/main/java/org/bukkit/inventory/EquipmentSlot.java
|
|
index c1c69ba4c361740f0ad422a7840a7f0f055c186a..1bedf9b7ee16729397e1fa2915dd76a1c6fbe212 100644
|
|
--- a/src/main/java/org/bukkit/inventory/EquipmentSlot.java
|
|
+++ b/src/main/java/org/bukkit/inventory/EquipmentSlot.java
|
|
@@ -15,7 +15,7 @@ public enum EquipmentSlot {
|
|
/**
|
|
* Only for certain entities such as horses and wolves.
|
|
*/
|
|
- BODY(() -> EquipmentSlotGroup.ARMOR);
|
|
+ BODY(() -> EquipmentSlotGroup.BODY); // Paper - add missing slot type
|
|
|
|
private final Supplier<EquipmentSlotGroup> group; // Supplier because of class loading order, since EquipmentSlot and EquipmentSlotGroup reference each other on class init
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java b/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java
|
|
index 0019c8d91eefbfb44e76b9f929b25cd189295b79..2ba475ee5e976a6f5451021be17697345b29110a 100644
|
|
--- a/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java
|
|
+++ b/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java
|
|
@@ -25,7 +25,8 @@ public final class EquipmentSlotGroup implements Predicate<EquipmentSlot> {
|
|
public static final EquipmentSlotGroup LEGS = get("legs", EquipmentSlot.LEGS);
|
|
public static final EquipmentSlotGroup CHEST = get("chest", EquipmentSlot.CHEST);
|
|
public static final EquipmentSlotGroup HEAD = get("head", EquipmentSlot.HEAD);
|
|
- public static final EquipmentSlotGroup ARMOR = get("armor", (test) -> test == EquipmentSlot.FEET || test == EquipmentSlot.LEGS || test == EquipmentSlot.CHEST || test == EquipmentSlot.HEAD, EquipmentSlot.CHEST);
|
|
+ public static final EquipmentSlotGroup ARMOR = get("armor", (test) -> test == EquipmentSlot.FEET || test == EquipmentSlot.LEGS || test == EquipmentSlot.CHEST || test == EquipmentSlot.HEAD || test == EquipmentSlot.BODY, EquipmentSlot.CHEST); // Paper - add missing slot type
|
|
+ public static final EquipmentSlotGroup BODY = get("body", EquipmentSlot.BODY); // Paper - add missing slot group
|
|
//
|
|
private final String key;
|
|
private final Predicate<EquipmentSlot> predicate;
|
|
diff --git a/src/main/java/org/bukkit/inventory/PlayerInventory.java b/src/main/java/org/bukkit/inventory/PlayerInventory.java
|
|
index 2c54660dc1fbc7c1232096797a23cae1262888e9..bcfcf963063e7c0fdc711febef2df2d0ff12776d 100644
|
|
--- a/src/main/java/org/bukkit/inventory/PlayerInventory.java
|
|
+++ b/src/main/java/org/bukkit/inventory/PlayerInventory.java
|
|
@@ -95,6 +95,8 @@ 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);
|
|
@@ -105,6 +107,8 @@ 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);
|