aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0289-Attributes-API-for-item-defaults.patch
blob: b7b2aac3ef211263e16cfeeadf5ea843e6c9f646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
index cfe35b0ca1f502c5c9af0d307bd22dcecc3b0f32..9be00bc616b1c6ad9619d9a48d5870f6d7ffb917 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4474,6 +4474,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<Attribute, AttributeModifier> 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 edc9b1ec665a57d9e4954c8409b1a42b29118b8c..d30cdfece8d324fb95c96c156974317450518274 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -169,6 +169,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<Attribute, AttributeModifier> getItemAttributes(@org.jetbrains.annotations.NotNull Material material, @org.jetbrains.annotations.NotNull EquipmentSlot equipmentSlot);
+
     /**
      * Returns the server's protocol version.
      *