multi line per line xp cost added

This commit is contained in:
alexcrea 2025-03-17 10:00:31 +01:00
parent 53173bcd33
commit 5f3eed08e2
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F

View file

@ -30,18 +30,20 @@ object AnvilLoreEditUtil {
if (!hasLoreEditByBookPermission(player)) return null if (!hasLoreEditByBookPermission(player)) return null
val result = first.clone() val result = first.clone()
val meta = result.itemMeta val meta = result.itemMeta?: return null
val lore = if (meta?.hasLore() == true) { val lore = if (meta.hasLore()) {
ArrayList<String>(meta.lore!!) ArrayList<String>(meta.lore!!)
} else ArrayList() } else ArrayList()
//TODO check color if color if enabled //TODO check color if color if enabled
lore.addAll(book.pages[0].split("\n")) val lines = book.pages[0].split("\n")
lore.addAll(lines)
meta?.lore = lore meta.lore = lore
result.itemMeta = meta result.itemMeta = meta
// Handle other xp // Handle other xp
xpCost.addAndGet(lines.size * LoreEditType.APPEND_BOOK.perLineCost)
xpCost.addAndGet(baseEditLoreXpCost(first, result, LoreEditType.APPEND_BOOK)) xpCost.addAndGet(baseEditLoreXpCost(first, result, LoreEditType.APPEND_BOOK))
return result return result
@ -52,11 +54,14 @@ object AnvilLoreEditUtil {
// remove lore // remove lore
val result = first.clone() val result = first.clone()
val leftMeta = result.itemMeta!! val leftMeta = result.itemMeta?: return null
val currentLore = leftMeta.lore?: return null
leftMeta.lore = null leftMeta.lore = null
result.itemMeta = leftMeta result.itemMeta = leftMeta
// Handle other xp // Handle other xp
xpCost.addAndGet(currentLore.size * LoreEditType.REMOVE_BOOK.perLineCost)
xpCost.addAndGet(baseEditLoreXpCost(first, result, LoreEditType.REMOVE_BOOK)) xpCost.addAndGet(baseEditLoreXpCost(first, result, LoreEditType.REMOVE_BOOK))
return result return result