aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authormartimavocado <39881008+martimavocado@users.noreply.github.com>2024-03-24 09:12:33 +0000
committerGitHub <noreply@github.com>2024-03-24 10:12:33 +0100
commit374b56662212253f844c963c353167064fb2f592 (patch)
tree2ee0862e65d2d16aad7ac164f961598a5ed52a50 /src/main/java/at/hannibal2/skyhanni
parent72cf0dbf71002194f64dee8518ae19e56c538d0f (diff)
downloadskyhanni-374b56662212253f844c963c353167064fb2f592.tar.gz
skyhanni-374b56662212253f844c963c353167064fb2f592.tar.bz2
skyhanni-374b56662212253f844c963c353167064fb2f592.zip
Fix: Various limbo stats related fixes (#1252)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt69
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt2
3 files changed, 51 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index d4f36c1c2..ac8ce0df7 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -294,7 +294,7 @@ object Commands {
)
registerCommand(
"shlimbostats",
- "Prints your Limbo Stats!"
+ "Prints your Limbo Stats.\n §7This includes your Personal Best, Playtime, and §aSkyHanni User Luck§7!"
) { LimboTimeTracker.printStats() }
registerCommand(
"shlimbo",
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 ceb18770e..77eb27799 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
@@ -31,7 +31,7 @@ class LimboPlaytime {
"§5§o§b([\\d.,]+) hours.+\$"
)
- private var wholeMinutes: Long = 0
+ private var wholeMinutes = 0
private var hoursString: String = ""
private val storage get() = ProfileStorageData.playerSpecific?.limbo
@@ -46,17 +46,35 @@ class LimboPlaytime {
if (event.inventory !is ContainerLocalMenu) return
if (event.inventory.displayName.unformattedText != "Detailed /playtime") return
if (event.slotNumber != 43) return
- if (storage?.playtime == 0) return
+ val playtime = storage?.playtime ?: 0
+ if (playtime < 60) return
if (lastCreateCooldown.passedSince() > 3.seconds) {
lastCreateCooldown = SimpleTimeMark.now()
- limboItem = if (wholeMinutes >= 60) Utils.createItemStack(
- itemID.getItemStack().item,
- itemName,
- "§7Playtime: §a${wholeMinutes.addSeparators()} minutes",
- "§7Or: §b$hoursString hours"
- )
- else Utils.createItemStack(itemID.getItemStack().item, itemName, "§7Playtime: §a$wholeMinutes minutes")
+ limboItem = when {
+ wholeMinutes >= 60 -> {
+ Utils.createItemStack(
+ itemID.getItemStack().item,
+ itemName,
+ "§7Playtime: §a${wholeMinutes.addSeparators()} minutes",
+ "§7Or: §b$hoursString hours"
+ )
+ }
+ wholeMinutes == 1 -> {
+ Utils.createItemStack(
+ itemID.getItemStack().item,
+ itemName,
+ "§7Playtime: §a$wholeMinutes minute"
+ )
+ }
+ else -> {
+ Utils.createItemStack(
+ itemID.getItemStack().item,
+ itemName,
+ "§7Playtime: §a$wholeMinutes minutes"
+ )
+ }
+ }
}
event.replaceWith(limboItem)
}
@@ -66,7 +84,8 @@ class LimboPlaytime {
if (!LorenzUtils.inSkyBlock) return
if (!event.slot.inventory.displayName.unformattedText.startsWith("Detailed /playtime")) return
if (event.slot.slotIndex != 4) return
- if (storage?.playtime == 0) return
+ val playtime = storage?.playtime ?: 0
+ if (playtime <= 120) return
val lore = event.toolTip
val hoursList = lore.filter { hoursPattern.matches(it) }.toMutableList()
@@ -83,23 +102,24 @@ class LimboPlaytime {
if (storedPlaytime < 60) return
val playtime = storedPlaytime.seconds
val wholeHours = playtime.inWholeHours
- wholeMinutes = playtime.inWholeMinutes
- if ((wholeMinutes % 60).toInt() == 0) {
+ wholeMinutes = playtime.inWholeMinutes.toInt()
+ if ((wholeMinutes % 60) == 0) {
hoursString = "$wholeHours"
} else {
- val minutes: Float = ((wholeMinutes - wholeHours * 60).toFloat() / 60)
- hoursString = wholeHours.addSeparators() + minutes.round(1).toString().replace("0", "")
+ val minutes: Float = ((wholeMinutes - wholeHours * 60).toFloat() / 60).round(1)
+ hoursString = wholeHours.addSeparators()
+ if (findFloatDecimalPlace(minutes) != 0) {
+ val minutesString = minutes.toString()
+ hoursString += minutesString.substring(minutesString.indexOf("."))
+ }
}
}
private fun addLimbo(hoursList: MutableList<String>, minutesList: MutableList<String>) {
val storedPlaytime = storage?.playtime ?: 0
if (wholeMinutes >= 60) {
- val hours = storedPlaytime.seconds.inWholeHours
- val minutes = (storedPlaytime.seconds.inWholeMinutes - (hours * 60).toFloat() / 6).toInt()
modifiedList = hoursList
- if (minutes == 0) modifiedList.add("§5§o§b$hours hours §7on Limbo")
- else modifiedList.add("§5§o§b$hoursString hours §7on Limbo")
+ modifiedList.add("§5§o§b$hoursString hours §7on Limbo")
modifiedList = modifiedList.sortedByDescending {
val matcher = hoursPattern.matcher(it)
if (matcher.find()) {
@@ -110,9 +130,12 @@ class LimboPlaytime {
} else {
val minutes = storedPlaytime.seconds.inWholeMinutes
modifiedList = minutesList
- modifiedList.add("§a$minutes minutes §7on Limbo")
+ modifiedList.add("§5§o§a$minutes minutes §7on Limbo")
modifiedList = modifiedList.sortedByDescending {
- it.substringAfter("§a").substringBefore(" minutes").toDoubleOrNull()
+ val matcher = minutesPattern.matcher(it)
+ if (matcher.find()) {
+ matcher.group(1).toDoubleOrNull() ?: 0.0
+ } else 0.0
}.toMutableList()
setMinutes = true
}
@@ -136,4 +159,10 @@ class LimboPlaytime {
}
toolTip.add(totalPlaytime)
}
+
+ private fun findFloatDecimalPlace(input: Float): Int {
+ val string = input.toString()
+ val dotIndex = string.indexOf(".")
+ return (string[dotIndex+1].toString().toInt())
+ }
}
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 fae469050..e39736326 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,7 +147,7 @@ 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)}✴ §fSkyHanni User Luck!")
+ 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!")
}
}