mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
multi line per line xp cost added
This commit is contained in:
parent
20d8fb6eda
commit
2c9b2ef9fa
1 changed files with 10 additions and 5 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue