99import org .bukkit .inventory .ItemStack ;
1010import org .bukkit .inventory .meta .EnchantmentStorageMeta ;
1111import org .jetbrains .annotations .NotNull ;
12+ import org .jetbrains .annotations .Nullable ;
1213import pro .cloudnode .smp .enchantbookplus .ConfigEnchantmentEntry ;
1314import pro .cloudnode .smp .enchantbookplus .EnchantBookPlus ;
1415import pro .cloudnode .smp .enchantbookplus .Permissions ;
1516
1617import java .util .HashMap ;
1718import java .util .Map ;
18- import java .util .Objects ;
1919import java .util .Optional ;
2020
2121public final class PrepareAnvil implements Listener {
@@ -24,8 +24,10 @@ public void onPrepareAnvil(final @NotNull PrepareAnvilEvent event) {
2424 final @ NotNull Optional <@ NotNull ItemStack > result = Optional .ofNullable (event .getResult ());
2525 if (result .isEmpty ()) return ;
2626 final @ NotNull AnvilInventory inventory = event .getInventory ();
27- final @ NotNull ItemStack item = Objects .requireNonNull (inventory .getItem (0 ));
28- final @ NotNull ItemStack upgrade = Objects .requireNonNull (inventory .getItem (1 ));
27+ final @ Nullable ItemStack item = inventory .getItem (0 );
28+ if (item == null ) return ;
29+ final @ Nullable ItemStack upgrade = inventory .getItem (1 );
30+ if (upgrade == null ) return ;
2931 final @ NotNull Map <@ NotNull Enchantment , @ NotNull Integer > itemEnchants =
3032 item .getType () == Material .ENCHANTED_BOOK && item .getItemMeta () instanceof final @ NotNull EnchantmentStorageMeta itemMeta ?
3133 itemMeta .getStoredEnchants () : item .getEnchantments ();
0 commit comments