diff options
Diffstat (limited to 'src/main')
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!") } } |