summaryrefslogtreecommitdiffstats
path: root/nms-patches/Enchantment.patch
blob: 259916040fce1e8eba21528299b8c49cc728e19e (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
--- a/net/minecraft/server/Enchantment.java
+++ b/net/minecraft/server/Enchantment.java
@@ -15,6 +15,17 @@
     @Nullable
     protected String d;
 
+    // CraftBukkit start - add back
+    @Nullable
+    public static Enchantment fromId(MinecraftKey key) {
+        return Enchantment.enchantments.get(key);
+    }
+
+    public static MinecraftKey getId(Enchantment enchantment) {
+        return Enchantment.enchantments.b(enchantment);
+    }
+    // CraftBukkit end
+
     protected Enchantment(Enchantment.Rarity enchantment_rarity, EnchantmentSlotType enchantmentslottype, EnumItemSlot[] aenumitemslot) {
         this.e = enchantment_rarity;
         this.itemTarget = enchantmentslottype;
@@ -153,6 +164,11 @@
         a("channeling", new EnchantmentTridentChanneling(Enchantment.Rarity.VERY_RARE, new EnumItemSlot[] { EnumItemSlot.MAINHAND}));
         a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values()));
         a("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values()));
+        // CraftBukkit start
+        for (Object enchantment : Enchantment.enchantments) {
+            org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment((Enchantment) enchantment));
+        }
+        // CraftBukkit end
     }
 
     private static void a(String s, Enchantment enchantment) {