mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
fix null lore issue
This commit is contained in:
parent
8dbfeec2fa
commit
d145eb1122
1 changed files with 5 additions and 6 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
package xyz.alexcrea.cuanvil.util
|
package xyz.alexcrea.cuanvil.util
|
||||||
|
|
||||||
import com.willfp.eco.util.toNiceString
|
|
||||||
import org.bukkit.entity.HumanEntity
|
import org.bukkit.entity.HumanEntity
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.BookMeta
|
import org.bukkit.inventory.meta.BookMeta
|
||||||
|
|
@ -63,7 +62,7 @@ object AnvilLoreEditUtil {
|
||||||
val result = first.clone()
|
val result = first.clone()
|
||||||
val leftMeta = result.itemMeta ?: return null
|
val leftMeta = result.itemMeta ?: return null
|
||||||
val currentLore: ArrayList<String> = DependencyManager.stripLore(result)
|
val currentLore: ArrayList<String> = DependencyManager.stripLore(result)
|
||||||
if(currentLore.isEmpty()) return null
|
if (currentLore.isEmpty()) return null
|
||||||
|
|
||||||
val uncolorCost = uncolorLines(player, currentLore, LoreEditType.REMOVE_BOOK)
|
val uncolorCost = uncolorLines(player, currentLore, LoreEditType.REMOVE_BOOK)
|
||||||
|
|
||||||
|
|
@ -148,7 +147,7 @@ object AnvilLoreEditUtil {
|
||||||
if (!hasLoreEditByPaperPermission(player)) return null
|
if (!hasLoreEditByPaperPermission(player)) return null
|
||||||
|
|
||||||
val result = first.clone()
|
val result = first.clone()
|
||||||
val meta = result.itemMeta?: return null
|
val meta = result.itemMeta ?: return null
|
||||||
val lore = if (meta.hasLore()) {
|
val lore = if (meta.hasLore()) {
|
||||||
ArrayList<String>(meta.lore!!)
|
ArrayList<String>(meta.lore!!)
|
||||||
} else ArrayList()
|
} else ArrayList()
|
||||||
|
|
@ -187,7 +186,7 @@ object AnvilLoreEditUtil {
|
||||||
|
|
||||||
val removeEnd = LoreEditConfigUtil.paperLoreOrderIsEnd
|
val removeEnd = LoreEditConfigUtil.paperLoreOrderIsEnd
|
||||||
val lore: ArrayList<String> = DependencyManager.stripLore(result)
|
val lore: ArrayList<String> = DependencyManager.stripLore(result)
|
||||||
if(lore.isEmpty()) return null
|
if (lore.isEmpty()) return null
|
||||||
|
|
||||||
val line = if (removeEnd) lore.removeAt(lore.size - 1)
|
val line = if (removeEnd) lore.removeAt(lore.size - 1)
|
||||||
else lore.removeAt(0)
|
else lore.removeAt(0)
|
||||||
|
|
@ -199,7 +198,7 @@ object AnvilLoreEditUtil {
|
||||||
DependencyManager.updateLore(result)
|
DependencyManager.updateLore(result)
|
||||||
|
|
||||||
val finalLore = ArrayList<String>()
|
val finalLore = ArrayList<String>()
|
||||||
finalLore.addAll(meta.lore!!)
|
finalLore.addAll(meta.lore ?: emptyList())
|
||||||
finalLore.addAll(lore)
|
finalLore.addAll(lore)
|
||||||
|
|
||||||
meta.lore = lore
|
meta.lore = lore
|
||||||
|
|
@ -271,7 +270,7 @@ object AnvilLoreEditUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uncolorLines(player: Permissible, lines: ArrayList<String>, editType: LoreEditType): Int {
|
fun uncolorLines(player: Permissible, lines: ArrayList<String>, editType: LoreEditType): Int {
|
||||||
if(!editType.shouldRemoveColorOnLoreRemoval) return 0
|
if (!editType.shouldRemoveColorOnLoreRemoval) return 0
|
||||||
|
|
||||||
// Now handle color of each lines
|
// Now handle color of each lines
|
||||||
var hasUndidColor = false
|
var hasUndidColor = false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue