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 fd1f64089359bf432a4934932ca6cad46145c04b..d849908850025a078ec5127870ec0f61d77a72e9 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -4013,6 +4013,19 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata 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 + */ + @NotNull + public com.google.common.collect.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 e0043bb2890862d9227f5faf15a3e4993dfc59ca..e21c42e14d9fdbe5ee9c15cfd8e408062cffc471 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java @@ -166,6 +166,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 com.google.common.collect.Multimap getItemAttributes(@org.jetbrains.annotations.NotNull Material material, @org.jetbrains.annotations.NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot); + /** * Returns the server's protocol version. *