1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Improved code

This commit is contained in:
Rothes 2021-04-20 12:47:48 +08:00 committed by GitHub
parent 2f7335e65b
commit 68dc6d560d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting; package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import java.util.Arrays;
/** /**
* The {@link AutoDisenchanter}, in contrast to the {@link AutoEnchanter}, removes * The {@link AutoDisenchanter}, in contrast to the {@link AutoEnchanter}, removes
* {@link Enchantment Enchantments} from a given {@link ItemStack} and transfers them * {@link Enchantment Enchantments} from a given {@link ItemStack} and transfers them
@ -152,13 +151,16 @@ public class AutoDisenchanter extends AContainer {
private boolean isDisenchantable(@Nullable ItemStack item) { private boolean isDisenchantable(@Nullable ItemStack item) {
if (item == null) { if (item == null) {
return false; return false;
} else if (item.hasItemMeta() && item.getItemMeta().hasLore()) { } else {
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta != null && itemMeta.hasLore()) {
for (String lore : cantDisenchantLores.getValue()) { for (String lore : cantDisenchantLores.getValue()) {
if (item.getItemMeta().getLore().contains(ChatColors.color(lore))) { if (itemMeta.getLore().contains(ChatColors.color(lore))) {
return false; return false;
} }
} }
} }
}
if (item.getType() != Material.BOOK) { if (item.getType() != Material.BOOK) {
// ^ This stops endless checks of getByItem for books // ^ This stops endless checks of getByItem for books
SlimefunItem sfItem = SlimefunItem.getByItem(item); SlimefunItem sfItem = SlimefunItem.getByItem(item);