diff --git a/src/main/java/com/nookure/core/inv/paper/PaperItemConverter.java b/src/main/java/com/nookure/core/inv/paper/PaperItemConverter.java index 6c8ba08..98ed94a 100644 --- a/src/main/java/com/nookure/core/inv/paper/PaperItemConverter.java +++ b/src/main/java/com/nookure/core/inv/paper/PaperItemConverter.java @@ -10,7 +10,7 @@ import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; +import org.bukkit.Registry; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -38,6 +38,10 @@ public Item convert(ItemStack itemStack) { @Override @SuppressWarnings("deprecation") public ItemStack convert(Item item, I18nAdapter adapter) { + if (item.material() == null && item.head() == null) { + throw new UserFriendlyRuntimeException("Material or head must be set for item " + item.id()); + } + ItemStack itemStack; if (item.material() == null) { itemStack = createHead(item.head(), item.headType()); @@ -113,7 +117,7 @@ public ItemStack convert(Item item, I18nAdapter adapter) { } if (item.enchanted()) { - meta.addEnchant(Enchantment.DURABILITY, 1, true); + Registry.ENCHANTMENT.stream().findAny().ifPresent(enchantment -> meta.addEnchant(enchantment, 1, true)); } itemStack.setItemMeta(meta);