Skip to content

Commit

Permalink
1.0.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xap3y committed Jun 15, 2024
1 parent 19fdb44 commit 4922563
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>eu.xap3y</groupId>
<artifactId>xalib</artifactId>
<version>1.0.5</version>
<version>1.0.5.2</version>

<properties>
<kotlin.version>2.0.0</kotlin.version>
Expand Down
13 changes: 7 additions & 6 deletions src/main/kotlin/eu/xap3y/xalib/managers/Texter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -146,11 +147,11 @@ class Texter(private val data: TexterObj) {
* @return Component
*/
@JvmStatic
fun format(map: LinkedHashMap<String, FormatterModifiers>): Component {
fun formatOneLine(map: LinkedHashMap<String, FormatterModifiers?>): 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()
}
Expand All @@ -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))
}
}

0 comments on commit 4922563

Please sign in to comment.