From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 8 May 2021 15:02:00 -0700 Subject: [PATCH] Attributes API for item defaults diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java index 0b3b623455337c6500b9ce518ad8e6a7e5e9a17f..220db091ce8b79688f82a099b5c227c86dd2c803 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -4584,6 +4584,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla public io.papermc.paper.inventory.ItemRarity getItemRarity() { return Bukkit.getUnsafe().getItemRarity(this); } + + /** + * Returns an immutable multimap of attributes for the slot. + * {@link #isItem()} must be true for this material. + * + * @param equipmentSlot the slot to get the attributes for + * @throws IllegalArgumentException if {@link #isItem()} is false + * @return an immutable multimap of attributes + * @deprecated use {@link #getDefaultAttributeModifiers(EquipmentSlot)} + */ + @NotNull + @Deprecated + public Multimap getItemAttributes(@NotNull EquipmentSlot equipmentSlot) { + return Bukkit.getUnsafe().getItemAttributes(this, equipmentSlot); + } // Paper end /** diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java index 00e61ab3103c86c9aabcdfa2fd4c565adcc091da..a9e7c64e1f98ff73c1804466d7c79eaf343dde7c 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java @@ -170,6 +170,18 @@ public interface UnsafeValues { */ public boolean isValidRepairItemStack(@org.jetbrains.annotations.NotNull ItemStack itemToBeRepaired, @org.jetbrains.annotations.NotNull ItemStack repairMaterial); + /** + * Returns an immutable multimap of attributes for the material and slot. + * {@link Material#isItem()} must be true for this material. + * + * @param material the material + * @param equipmentSlot the slot to get the attributes for + * @throws IllegalArgumentException if {@link Material#isItem()} is false + * @return an immutable multimap of attributes + */ + @org.jetbrains.annotations.NotNull + public Multimap getItemAttributes(@org.jetbrains.annotations.NotNull Material material, @org.jetbrains.annotations.NotNull EquipmentSlot equipmentSlot); + /** * Returns the server's protocol version. *