Fix enchantment init

This commit is contained in:
Doc 2024-11-17 11:30:18 -03:00
parent be886cf4e7
commit 34f027efa9
No known key found for this signature in database

View file

@ -0,0 +1,31 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Doc <nachito94@msn.com>
Date: Sun, 17 Nov 2024 11:28:34 -0300
Subject: [PATCH] fix Enchantment init
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
index 43e306584988e39a6daca78c621a937acdce48a1..a6c56e0c5b464a03692985d26336d7fa50d7b145 100644
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
@@ -13,6 +13,8 @@ import org.jetbrains.annotations.Nullable;
/**
* The various type of enchantments that may be added to armour or weapons
+ * <br>
+ * <b>Note:</b> Vanilla enchantments can be null or not valid if a datapack just remove them.
*/
public abstract class Enchantment implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
/**
@@ -227,9 +229,9 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
*/
public static final Enchantment SWIFT_SNEAK = getEnchantment("swift_sneak");
- @NotNull
+ @Nullable // Paper - Internal Vanilla enchantments can be Nullables
private static Enchantment getEnchantment(@NotNull String key) {
- return Registry.ENCHANTMENT.getOrThrow(NamespacedKey.minecraft(key));
+ return Registry.ENCHANTMENT.get(NamespacedKey.minecraft(key)); // Paper - Vanilla enchantments can be null if datapacks remove them
}
/**