aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authormartimavocado <39881008+martimavocado@users.noreply.github.com>2024-03-29 14:08:42 +0000
committerGitHub <noreply@github.com>2024-03-29 15:08:42 +0100
commitb98cfd9c8a6da8d24063e37f9e333de5abe0681f (patch)
treeabe479de617ad474ee3ad577b36cf7b8c723f0b1 /src/main/java/at
parentc71e6bd9158777c6060a56fd8dcb6310d0f39afe (diff)
downloadskyhanni-b98cfd9c8a6da8d24063e37f9e333de5abe0681f.tar.gz
skyhanni-b98cfd9c8a6da8d24063e37f9e333de5abe0681f.tar.bz2
skyhanni-b98cfd9c8a6da8d24063e37f9e333de5abe0681f.zip
Fix : /playtimedetailed tooltip generation, limbostats with negative luck (#1307)
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt15
2 files changed, 29 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
index cf0da4b6c..b232b837d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
@@ -137,10 +137,22 @@ class LimboPlaytime {
minutesList: MutableList<String>,
hoursList: MutableList<String>,
) {
- val firstLine = toolTip.first()
- val totalPlaytime = toolTip.last()
+ val firstList = mutableListOf<String>()
+ val lastList = mutableListOf<String>()
+ var hasPassed = false
+ toolTip.forEach {
+ if (!(hoursPattern.matches(it) || minutesPattern.matches(it)) && !hasPassed) {
+ firstList.add(it)
+ } else hasPassed = true
+ }
+ hasPassed = false
+ toolTip.forEach {
+ if (!(hoursPattern.matches(it) || minutesPattern.matches(it)) && hasPassed) {
+ lastList.add(it)
+ } else hasPassed = true
+ }
toolTip.clear()
- toolTip.add(firstLine)
+ toolTip.addAll(firstList)
if (!setMinutes) {
toolTip.addAll(modifiedList)
toolTip.addAll(minutesList)
@@ -148,7 +160,7 @@ class LimboPlaytime {
toolTip.addAll(hoursList)
toolTip.addAll(modifiedList)
}
- toolTip.add(totalPlaytime)
+ toolTip.addAll(lastList)
}
private fun findFloatDecimalPlace(input: Float): Int {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt
index e39736326..9e9a9113f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt
@@ -147,8 +147,13 @@ object LimboTimeTracker {
val currentPB = storage?.personalBest ?: 0
val userLuck = storage?.userLuck ?: 0f
val limboPB: Int = if (currentPB < timeInLimbo) timeInLimbo else currentPB
- ChatUtils.chat("§fYour current PB is §e${limboPB.seconds}§f, granting you §a+${userLuck.round(2)}✴ SkyHanni User Luck§f!")
- ChatUtils.chat("§fYou have §e${playtime.seconds} §fof playtime!")
+ var luckString = tryTruncateFloat(userLuck.round(2))
+ if (userLuck > 0) luckString = "+$luckString"
+ var firstMessage = "§fYour current PB is §e${limboPB.seconds}§f, granting you §a$luckString✴ SkyHanni User Luck§f!"
+ val secondMessage = "§fYou have §e${playtime.seconds} §fof playtime!"
+ if ((userLuck == Float.POSITIVE_INFINITY) || (userLuck == Float.NEGATIVE_INFINITY)) firstMessage = "$firstMessage §Zwhat"
+ ChatUtils.chat(firstMessage)
+ ChatUtils.chat(secondMessage)
}
}
@@ -189,4 +194,10 @@ object LimboTimeTracker {
}
fun isEnabled() = config.showTimeInLimbo
+
+ private fun tryTruncateFloat(input: Float): String {
+ val string = input.toString()
+ return if (string.endsWith(".0")) return string.dropLast(2)
+ else string
+ }
}