From 2e81136c00cb903d5f8d960e7030953dbbdcf001 Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 4 Mar 2021 23:26:17 -0500 Subject: [PATCH] additional crafting station lore fixes --- .../mmoitems/gui/CraftingStationPreview.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/gui/CraftingStationPreview.java b/src/main/java/net/Indyuce/mmoitems/gui/CraftingStationPreview.java index ee69c7d3..30842806 100644 --- a/src/main/java/net/Indyuce/mmoitems/gui/CraftingStationPreview.java +++ b/src/main/java/net/Indyuce/mmoitems/gui/CraftingStationPreview.java @@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.gui; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.util.LegacyComponent; +import io.lumine.mythic.utils.adventure.text.Component; import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.api.crafting.ingredient.Ingredient.CheckedIngredient; import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe; @@ -90,16 +91,23 @@ public class CraftingStationPreview extends PluginInventory { inv.setItem(10, ConfigItems.BACK.getItem()); inv.setItem(34, ConfigItems.CONFIRM.getItem()); - ItemStack book = recipe.display(); - book.setType(Material.KNOWLEDGE_BOOK); - book.setAmount(1); - ItemMeta meta = book.getItemMeta(); - List newLore = meta.getLore().subList(0, meta.getLore().size() - 3); - meta.setLore(newLore); + ItemStack bookStack = recipe.display(); + + bookStack.setType(Material.KNOWLEDGE_BOOK); + bookStack.setAmount(1); + + ItemMeta meta = bookStack.getItemMeta(); + for (Enchantment ench : meta.getEnchants().keySet()) meta.removeEnchant(ench); - book.setItemMeta(meta); - inv.setItem(28, book); + bookStack.setItemMeta(meta); + + NBTItem book = NBTItem.get(bookStack); + + List lore = book.getLoreComponents(); + book.setLoreComponents(lore.subList(0, lore.size() - 3)); + + inv.setItem(28, book.toItem()); inv.setItem(20, page > 1 ? ConfigItems.PREVIOUS_PAGE.getItem() : ConfigItems.FILL.getItem()); inv.setItem(24, max < ingredients.size() ? ConfigItems.NEXT_PAGE.getItem() : ConfigItems.FILL.getItem());