2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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
2023-03-18 18:05:04 +01:00
index 467282a76dbf2edfd88baa4275991ae1163c0919..31ec16d134fd8eb5607d18e17f93225eef402d7e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
2023-03-14 18:21:11 +01:00
@@ -4425,6 +4425,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
2021-06-11 14:02:28 +02:00
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
2022-01-01 04:05:42 +01:00
+ * @deprecated use {@link #getDefaultAttributeModifiers(EquipmentSlot)}
2021-06-11 14:02:28 +02:00
+ */
+ @NotNull
2022-01-01 04:05:42 +01:00
+ @Deprecated
+ public Multimap<Attribute, AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) {
2021-06-11 14:02:28 +02:00
+ 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
2023-02-28 17:36:01 +01:00
index 29a91ec8e97ce66383a1dd1fc3dcbcdcca7cfc41..0d47278d68cdf015cb980721c234a3abee39646a 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
2023-02-28 17:36:01 +01:00
@@ -165,6 +165,18 @@ public interface UnsafeValues {
2021-06-11 14:02:28 +02:00
*/
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
2022-01-01 04:05:42 +01:00
+ public Multimap<Attribute, AttributeModifier> getItemAttributes(@org.jetbrains.annotations.NotNull Material material, @org.jetbrains.annotations.NotNull EquipmentSlot equipmentSlot);
2021-06-11 14:02:28 +02:00
+
/**
* Returns the server's protocol version.
*