From d145eb1122d7d5ad2daf1a0451a42e2ddf51ae2a Mon Sep 17 00:00:00 2001 From: alexcrea <42614139+alexcrea@users.noreply.github.com> Date: Sun, 27 Apr 2025 23:29:02 +0200 Subject: [PATCH] fix null lore issue --- .../xyz/alexcrea/cuanvil/util/AnvilLoreEditUtil.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilLoreEditUtil.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilLoreEditUtil.kt index 25256a1..8f5b180 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilLoreEditUtil.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilLoreEditUtil.kt @@ -1,6 +1,5 @@ package xyz.alexcrea.cuanvil.util -import com.willfp.eco.util.toNiceString import org.bukkit.entity.HumanEntity import org.bukkit.inventory.ItemStack import org.bukkit.inventory.meta.BookMeta @@ -63,7 +62,7 @@ object AnvilLoreEditUtil { val result = first.clone() val leftMeta = result.itemMeta ?: return null val currentLore: ArrayList = DependencyManager.stripLore(result) - if(currentLore.isEmpty()) return null + if (currentLore.isEmpty()) return null val uncolorCost = uncolorLines(player, currentLore, LoreEditType.REMOVE_BOOK) @@ -148,7 +147,7 @@ object AnvilLoreEditUtil { if (!hasLoreEditByPaperPermission(player)) return null val result = first.clone() - val meta = result.itemMeta?: return null + val meta = result.itemMeta ?: return null val lore = if (meta.hasLore()) { ArrayList(meta.lore!!) } else ArrayList() @@ -187,7 +186,7 @@ object AnvilLoreEditUtil { val removeEnd = LoreEditConfigUtil.paperLoreOrderIsEnd val lore: ArrayList = DependencyManager.stripLore(result) - if(lore.isEmpty()) return null + if (lore.isEmpty()) return null val line = if (removeEnd) lore.removeAt(lore.size - 1) else lore.removeAt(0) @@ -199,7 +198,7 @@ object AnvilLoreEditUtil { DependencyManager.updateLore(result) val finalLore = ArrayList() - finalLore.addAll(meta.lore!!) + finalLore.addAll(meta.lore ?: emptyList()) finalLore.addAll(lore) meta.lore = lore @@ -271,7 +270,7 @@ object AnvilLoreEditUtil { } fun uncolorLines(player: Permissible, lines: ArrayList, editType: LoreEditType): Int { - if(!editType.shouldRemoveColorOnLoreRemoval) return 0 + if (!editType.shouldRemoveColorOnLoreRemoval) return 0 // Now handle color of each lines var hasUndidColor = false