From 68dc6d560d91cfab78ae4d40200c193fab31f108 Mon Sep 17 00:00:00 2001 From: Rothes <47097395+Rothes@users.noreply.github.com> Date: Tue, 20 Apr 2021 12:47:48 +0800 Subject: [PATCH] Improved code --- .../machines/enchanting/AutoDisenchanter.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java index 4e3d92668..6d61a65cc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,8 +31,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecip import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; -import java.util.Arrays; - /** * The {@link AutoDisenchanter}, in contrast to the {@link AutoEnchanter}, removes * {@link Enchantment Enchantments} from a given {@link ItemStack} and transfers them @@ -152,10 +151,13 @@ public class AutoDisenchanter extends AContainer { private boolean isDisenchantable(@Nullable ItemStack item) { if (item == null) { return false; - } else if (item.hasItemMeta() && item.getItemMeta().hasLore()) { - for (String lore : cantDisenchantLores.getValue()) { - if (item.getItemMeta().getLore().contains(ChatColors.color(lore))) { - return false; + } else { + ItemMeta itemMeta = item.getItemMeta(); + if (itemMeta != null && itemMeta.hasLore()) { + for (String lore : cantDisenchantLores.getValue()) { + if (itemMeta.getLore().contains(ChatColors.color(lore))) { + return false; + } } } }