website/resources/txt/newlore.sk

69 lines
1.9 KiB
Plaintext
Raw Normal View History

2022-09-07 09:29:20 +00:00
import:
org.bukkit.ChatColor
options:
CharacterLimitPerLine: 25
LegacyLoreSupport: true
#USAGE
#set slot 0 of player's current inventory to emerald with lore "your lore here", "maybe here too?"
#OR if the syntax override isn't working for you
#set slot 0 of player's current inventory to emerald with custom lore "your lore here", "maybe here too?"
expression %itemstack% with [custom] lore %strings%:
get:
set {_item} to expression 1
set {_lore::*} to expressions 2
if {@LegacyLoreSupport} is true:
loop {_lore::*}:
loop loop-value split at "||":
add 1 to {_i}
#the weird index is needed to keep things in right line order after split
set {_lore::%loop-index-1%.0%{_i}%} to loop-value-2
if {_lore::%loop-index%.0%{_i}%} is set:
delete {_lore::%loop-index%}
loop {_lore::*}:
length of uncolored loop-value is higher than {@CharacterLimitPerLine}:
loop loop-value split at " ":
set {_color} to ChatColor.getLastColors({_lasttext} ? loop-value-2)
if {_textt} is not set:
set {_textt} to "%{_color}%%loop-value-2%"
else:
set {_textt} to "%{_textt}% %loop-value-2%"
#for getting color codes of last text later
set {_lasttext} to {_textt}
#when one line reaches character limit
if length of uncolored {_textt} is not less than {@CharacterLimitPerLine}:
add {_textt} to {_lorefinal::*}
delete {_textt}
#when the whole line is over, but not reached character limit
{_textt} is set:
add {_textt} to {_lorefinal::*}
delete {_textt}
else:
#when the line doesn't need splitting, it is shorter than the character limit
add loop-value to {_lorefinal::*}
set lore of {_item} to {_lorefinal::*}
return {_item}