From 4922563a27a0413c88c4d5f9662e5b6f272cf257 Mon Sep 17 00:00:00 2001 From: XAP3Y Date: Sat, 15 Jun 2024 16:45:28 +0200 Subject: [PATCH] 1.0.5.2 --- pom.xml | 2 +- src/main/kotlin/eu/xap3y/xalib/managers/Texter.kt | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index fb900fd..3d28080 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ eu.xap3y xalib - 1.0.5 + 1.0.5.2 2.0.0 diff --git a/src/main/kotlin/eu/xap3y/xalib/managers/Texter.kt b/src/main/kotlin/eu/xap3y/xalib/managers/Texter.kt index d0975f9..abc86e2 100644 --- a/src/main/kotlin/eu/xap3y/xalib/managers/Texter.kt +++ b/src/main/kotlin/eu/xap3y/xalib/managers/Texter.kt @@ -13,6 +13,7 @@ import net.kyori.adventure.text.event.HoverEvent import org.bukkit.Bukkit import org.bukkit.ChatColor import org.bukkit.command.CommandSender +import org.bukkit.entity.Player import java.util.logging.Level class Texter(private val data: TexterObj) { @@ -96,7 +97,7 @@ class Texter(private val data: TexterObj) { @JvmStatic fun progressBar(modifiers: ProgressbarModifier): String { val maxLength = 20 - val fillText: String = modifiers.symbolFill.toString().repeat(maxLength * (modifiers.percentage / 100)) + val fillText: String = modifiers.symbolFill.toString().repeat((modifiers.percentage * maxLength) / 100) val emptyText: String = modifiers.symbolEmpty.toString().repeat(maxLength - fillText.length) return modifiers.colorFill + fillText + modifiers.colorEmpty + emptyText } @@ -146,11 +147,11 @@ class Texter(private val data: TexterObj) { * @return Component */ @JvmStatic - fun format(map: LinkedHashMap): Component { + fun formatOneLine(map: LinkedHashMap): Component { val builder: TextComponent.Builder = Component.text() - map.forEach { (key: String, value: FormatterModifiers) -> - builder.append(Component.text(key).clickEvent(value.clickAction).hoverEvent(HoverEvent.showText( - Component.text(value.hoverText ?: "")))) + map.forEach { (key: String, value: FormatterModifiers?) -> + builder.append(Component.text(key.replace("&", "§")).clickEvent(value?.clickAction).hoverEvent(HoverEvent.showText( + Component.text(value?.hoverText?.replace("&", "§") ?: "")))) } return builder.build() } @@ -163,6 +164,6 @@ class Texter(private val data: TexterObj) { * @return Component */ fun format(text: String, modifier: FormatterModifiers): Component = - format(linkedMapOf(text to modifier)) + formatOneLine(linkedMapOf(text to modifier)) } } \ No newline at end of file