diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-11 12:28:07 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-11 12:28:07 +0200 |
| commit | 8ccfdc9b7d22352c23d4bff5ee240fa71e302262 (patch) | |
| tree | a11139ca4bdfba81fcc538ea76424fe66ca1b409 /src/main/java/at/hannibal2/skyhanni/features/misc | |
| parent | 4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7 (diff) | |
| download | skyhanni-8ccfdc9b7d22352c23d4bff5ee240fa71e302262.tar.gz skyhanni-8ccfdc9b7d22352c23d4bff5ee240fa71e302262.tar.bz2 skyhanni-8ccfdc9b7d22352c23d4bff5ee240fa71e302262.zip | |
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
3 files changed, 57 insertions, 52 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt index 5fa005021..8cf4f8044 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt @@ -97,13 +97,12 @@ class TpsCounter { event.move(2, "misc.tpsDisplayPosition", "gui.tpsDisplayPosition") } - private fun getColor(tps: Double): String { - return when { - tps > 19.8 -> "§2" - tps > 19 -> "§a" - tps > 17.5 -> "§6" - tps > 12 -> "§c" - else -> "§4" - } + private fun getColor(tps: Double) = when { + tps > 19.8 -> "§2" + tps > 19 -> "§a" + tps > 17.5 -> "§6" + tps > 12 -> "§c" + + else -> "§4" } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt index 9ec187ca8..433f468cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt @@ -103,6 +103,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) when { island == IslandType.PRIVATE_ISLAND_GUEST -> lastKnownDisplayStrings[LOCATION] = "${getVisitingName()}'s Island" + island == IslandType.GARDEN -> { if (location.startsWith("Plot: ")) { lastKnownDisplayStrings[LOCATION] = "Personal Garden ($location)" // Personal Garden (Plot: 8) @@ -110,12 +111,14 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) lastKnownDisplayStrings[LOCATION] = "Personal Garden" } } + island == IslandType.GARDEN_GUEST -> { lastKnownDisplayStrings[LOCATION] = "${getVisitingName()}'s Garden" if (location.startsWith("Plot: ")) { lastKnownDisplayStrings[LOCATION] = "${lastKnownDisplayStrings[LOCATION]} ($location)" } // "MelonKingDe's Garden (Plot: 8)" } + location != "None" && location != "invalid" -> { lastKnownDisplayStrings[LOCATION] = location } @@ -132,19 +135,13 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) val motes = scoreboard.firstOrNull { motesRegex.matches(it.removeColor()) }?.let { motesRegex.find(it.removeColor())?.groupValues?.get(1) ?: "" } - when { - coins == "1" -> { - lastKnownDisplayStrings[PURSE] = "1 Coin" - } - coins != "" && coins != null -> { - lastKnownDisplayStrings[PURSE] = "$coins Coins" - } - motes == "1" -> { - lastKnownDisplayStrings[PURSE] = "1 Mote" - } - motes != "" && motes != null -> { - lastKnownDisplayStrings[PURSE] = "$motes Motes" - } + lastKnownDisplayStrings[PURSE] = when { + coins == "1" -> "1 Coin" + coins != "" && coins != null -> "$coins Coins" + motes == "1" -> "1 Mote" + motes != "" && motes != null -> "$motes Motes" + + else -> lastKnownDisplayStrings[PURSE] ?: "" } lastKnownDisplayStrings[PURSE] ?: "" }), @@ -218,14 +215,12 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) var profile = "SkyBlock Level: [$sbLevel] on " - profile += ( - when { - HypixelData.ironman -> "♲" - HypixelData.bingo -> "Ⓑ" - HypixelData.stranded -> "☀" - else -> "" - } - ) + profile += when { + HypixelData.ironman -> "♲" + HypixelData.bingo -> "Ⓑ" + HypixelData.stranded -> "☀" + else -> "" + } val fruit = HypixelData.profileName.firstLetterUppercase() if (fruit == "") profile = @@ -251,6 +246,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) slayerName = match.group("name") slayerLevel = match.group("level") } + noColorLine == "Slay the boss!" -> bossAlive = "slaying" noColorLine == "Boss slain!" -> bossAlive = "slain" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt index 365a8db0e..82acce71b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt @@ -35,18 +35,22 @@ object GhostUtil { millis < 0 -> { clear() } + minutes == 0L && hours == 0L && days == 0L -> { put("seconds", seconds.toString()) } + hours == 0L && days == 0L -> { put("seconds", seconds.toString()) put("minutes", minutes.toString()) } + days == 0L -> { put("seconds", seconds.toString()) put("minutes", minutes.toString()) put("hours", hours.toString()) } + else -> { put("seconds", seconds.toString()) put("minutes", minutes.toString()) @@ -64,7 +68,10 @@ object GhostUtil { LorenzUtils.chat("§e[SkyHanni] §cYou already imported GhostCounterV3 data!") return } - val json = ConfigManager.gson.fromJson(FileReader(GhostCounter.ghostCounterV3File), com.google.gson.JsonObject::class.java) + val json = ConfigManager.gson.fromJson( + FileReader(GhostCounter.ghostCounterV3File), + com.google.gson.JsonObject::class.java + ) GhostData.Option.GHOSTSINCESORROW.add(json["ghostsSinceSorrow"].asDouble) GhostData.Option.SORROWCOUNT.add(json["sorrowCount"].asDouble) GhostData.Option.BAGOFCASH.add(json["BagOfCashCount"].asDouble) @@ -84,32 +91,33 @@ object GhostUtil { fun String.formatText(option: GhostData.Option) = formatText(option.getInt(), option.getInt(true)) fun String.formatText(value: Int, session: Int = -1) = Utils.chromaStringByColourCode( - replace("%value%", value.addSeparators()) + this.replace("%value%", value.addSeparators()) .replace("%session%", session.addSeparators()) .replace("&", "§") ) - fun String.formatText(t: String): String { - return Utils.chromaStringByColourCode(this.replace("%value%", t) - .replace("&", "§")) - } + fun String.formatText(t: String) = Utils.chromaStringByColourCode(this.replace("%value%", t).replace("&", "§")) - fun String.preFormat(t: String, level: Int, nextLevel: Int): String { - return if (nextLevel == 26) { - val lol = Utils.chromaStringByColourCode(this.replace("%value%", t) - .replace("%display%", "25")) - lol - } else { - Utils.chromaStringByColourCode(this.replace("%value%", t) - .replace("%display%", "$level->${if (SkyHanniMod.feature.combat.ghostCounter.showMax) "25" else nextLevel}")) - } + fun String.preFormat(t: String, level: Int, nextLevel: Int) = if (nextLevel == 26) { + Utils.chromaStringByColourCode( + replace("%value%", t) + .replace("%display%", "25") + ) + } else { + Utils.chromaStringByColourCode( + this.replace("%value%", t) + .replace( + "%display%", + "$level->${if (SkyHanniMod.feature.combat.ghostCounter.showMax) "25" else nextLevel}" + ) + ) } - fun String.formatText(value: Double, session: Double): String { - return Utils.chromaStringByColourCode(this.replace("%value%", value.roundToPrecision(2).addSeparators()) + fun String.formatText(value: Double, session: Double) = Utils.chromaStringByColourCode( + this.replace("%value%", value.roundToPrecision(2).addSeparators()) .replace("%session%", session.roundToPrecision(2).addSeparators()) - .replace("&", "§")) - } + .replace("&", "§") + ) fun String.formatBestiary(currentKill: Int, killNeeded: Int): String { val bestiaryNextLevel = GhostCounter.hidden?.bestiaryNextLevel @@ -119,7 +127,10 @@ object GhostUtil { ?: "§cNo Bestiary Level data!" return Utils.chromaStringByColourCode( - this.replace("%currentKill%", if (GhostCounter.config.showMax) GhostCounter.bestiaryCurrentKill.addSeparators() else currentKill.addSeparators()) + this.replace( + "%currentKill%", + if (GhostCounter.config.showMax) GhostCounter.bestiaryCurrentKill.addSeparators() else currentKill.addSeparators() + ) .replace("%percentNumber%", percent(GhostCounter.bestiaryCurrentKill.toDouble())) .replace("%killNeeded%", NumberUtil.format(killNeeded)) .replace("%currentLevel%", currentLevel) @@ -128,7 +139,6 @@ object GhostUtil { ) } - private fun percent(number: Double): String { - return 100.0.coerceAtMost(((number / 250_000) * 100).roundToPrecision(4)).toString() - } + private fun percent(number: Double) = + 100.0.coerceAtMost(((number / 250_000) * 100).roundToPrecision(4)).toString() }
\ No newline at end of file |
