diff options
author | Walker Selby <git@walkerselby.com> | 2023-10-11 11:24:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 12:24:39 +0200 |
commit | 4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7 (patch) | |
tree | 80d0ba5a1fa2893c0529f0382a99d6a044bc905c /src/main | |
parent | 8527d7555ea16becbcfe949413eabfd41c8400c4 (diff) | |
download | skyhanni-4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7.tar.gz skyhanni-4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7.tar.bz2 skyhanni-4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7.zip |
More Code Cleanup - When (#531)
code cleanup #531
Diffstat (limited to 'src/main')
13 files changed, 258 insertions, 215 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt index bd2c7dfe7..2bb65b942 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt @@ -206,10 +206,8 @@ class MobFinder { if (entity.name == "Mage Outlaw") { return EntityResult(bossType = BossType.NETHER_MAGE_OUTLAW) } - if (entity.name == "DukeBarb ") { - if (entity.getLorenzVec().distanceToPlayer() < 30) { - return EntityResult(bossType = BossType.NETHER_BARBARIAN_DUKE) - } + if (entity.name == "DukeBarb " && entity.getLorenzVec().distanceToPlayer() < 30) { + return EntityResult(bossType = BossType.NETHER_BARBARIAN_DUKE) } } if (entity is EntityWither && entity.hasNameTagWith(4, "§8[§7Lv100§8] §c§5Vanquisher§r ")) { @@ -300,14 +298,12 @@ class MobFinder { } checkArachne(entity)?.let { return it } } - if (entity is EntityWolf) { - if (entity.hasNameTagWith(1, "§c☠ §fSven Packmaster ")) { - when { - entity.hasMaxHealth(2_000, true) -> return EntityResult(bossType = BossType.SLAYER_WOLF_1) - entity.hasMaxHealth(40_000, true) -> return EntityResult(bossType = BossType.SLAYER_WOLF_2) - entity.hasMaxHealth(750_000, true) -> return EntityResult(bossType = BossType.SLAYER_WOLF_3) - entity.hasMaxHealth(2_000_000, true) -> return EntityResult(bossType = BossType.SLAYER_WOLF_4) - } + if (entity is EntityWolf && entity.hasNameTagWith(1, "§c☠ §fSven Packmaster ")) { + when { + entity.hasMaxHealth(2_000, true) -> return EntityResult(bossType = BossType.SLAYER_WOLF_1) + entity.hasMaxHealth(40_000, true) -> return EntityResult(bossType = BossType.SLAYER_WOLF_2) + entity.hasMaxHealth(750_000, true) -> return EntityResult(bossType = BossType.SLAYER_WOLF_3) + entity.hasMaxHealth(2_000_000, true) -> return EntityResult(bossType = BossType.SLAYER_WOLF_4) } } if (entity is EntityOtherPlayerMP) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt index 75b775174..50985ecfe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt @@ -40,11 +40,9 @@ object FarmingContestAPI { } private fun checkActiveContest() { - if (inContest) { - if (startTime.passedSince() > 20.minutes) { - FarmingContestEvent(contestCrop!!, FarmingContestPhase.STOP).postAndCatch() - inContest = false - } + if (inContest && startTime.passedSince() > 20.minutes) { + FarmingContestEvent(contestCrop!!, FarmingContestPhase.STOP).postAndCatch() + inContest = false } val currentCrop = readCurrentCrop() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt index b1d1a0f38..fc3ad61d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt @@ -285,80 +285,90 @@ open class FFGuideGUI : GuiScreen() { if (selectedPage != FortuneGuidePage.UPGRADES) { if (currentCrop == null) { - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 130, 16, 16) && - currentPet != FarmingItems.ELEPHANT - ) { - SoundUtils.playClickSound() - currentPet = FarmingItems.ELEPHANT - FFStats.getTotalFF() - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 130, 16, 16) && - currentPet != FarmingItems.MOOSHROOM_COW - ) { - SoundUtils.playClickSound() - currentPet = FarmingItems.MOOSHROOM_COW - FFStats.getTotalFF() - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 130, 16, 16) && - currentPet != FarmingItems.RABBIT - ) { - SoundUtils.playClickSound() - currentPet = FarmingItems.RABBIT - FFStats.getTotalFF() - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 130, 16, 16) && - currentPet != FarmingItems.BEE - ) { - SoundUtils.playClickSound() - currentPet = FarmingItems.BEE - FFStats.getTotalFF() - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 1) 0 else 1 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 2) 0 else 2 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 3) 0 else 3 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 4) 0 else 4 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 262, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 1) 0 else 1 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 282, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 2) 0 else 2 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 302, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 3) 0 else 3 - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 322, guiTop + 5, 16, 16)) { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 4) 0 else 4 + when { + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 130, 16, 16) && + currentPet != FarmingItems.ELEPHANT -> { + SoundUtils.playClickSound() + currentPet = FarmingItems.ELEPHANT + FFStats.getTotalFF() + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 130, 16, 16) && + currentPet != FarmingItems.MOOSHROOM_COW -> { + SoundUtils.playClickSound() + currentPet = FarmingItems.MOOSHROOM_COW + FFStats.getTotalFF() + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 130, 16, 16) && + currentPet != FarmingItems.RABBIT -> { + SoundUtils.playClickSound() + currentPet = FarmingItems.RABBIT + FFStats.getTotalFF() + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 130, 16, 16) && + currentPet != FarmingItems.BEE -> { + SoundUtils.playClickSound() + currentPet = FarmingItems.BEE + FFStats.getTotalFF() + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 5, 16, 16) -> { + SoundUtils.playClickSound() + currentArmor = if (currentArmor == 1) 0 else 1 + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 5, 16, 16) -> { + SoundUtils.playClickSound() + currentArmor = if (currentArmor == 2) 0 else 2 + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 5, 16, 16) -> { + SoundUtils.playClickSound() + currentArmor = if (currentArmor == 3) 0 else 3 + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 5, 16, 16) -> { + SoundUtils.playClickSound() + currentArmor = if (currentArmor == 4) 0 else 4 + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 262, guiTop + 5, 16, 16) -> { + SoundUtils.playClickSound() + currentEquipment = if (currentEquipment == 1) 0 else 1 + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 282, guiTop + 5, 16, 16) -> { + SoundUtils.playClickSound() + currentEquipment = if (currentEquipment == 2) 0 else 2 + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 302, guiTop + 5, 16, 16) -> { + SoundUtils.playClickSound() + currentEquipment = if (currentEquipment == 3) 0 else 3 + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 322, guiTop + 5, 16, 16) -> { + SoundUtils.playClickSound() + currentEquipment = if (currentEquipment == 4) 0 else 4 + } } } else { - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 160, 16, 16) && - currentPet != FarmingItems.ELEPHANT - ) { - SoundUtils.playClickSound() - currentPet = FarmingItems.ELEPHANT - FFStats.getTotalFF() - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 160, 16, 16) && - currentPet != FarmingItems.MOOSHROOM_COW - ) { - SoundUtils.playClickSound() - currentPet = FarmingItems.MOOSHROOM_COW - FFStats.getTotalFF() - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 160, 16, 16) && - currentPet != FarmingItems.RABBIT - ) { - SoundUtils.playClickSound() - currentPet = FarmingItems.RABBIT - FFStats.getTotalFF() - } else if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 160, 16, 16) && - currentPet != FarmingItems.BEE - ) { - SoundUtils.playClickSound() - currentPet = FarmingItems.BEE - FFStats.getTotalFF() + when { + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 160, 16, 16) && + currentPet != FarmingItems.ELEPHANT -> { + SoundUtils.playClickSound() + currentPet = FarmingItems.ELEPHANT + FFStats.getTotalFF() + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 160, 16, 16) && + currentPet != FarmingItems.MOOSHROOM_COW -> { + SoundUtils.playClickSound() + currentPet = FarmingItems.MOOSHROOM_COW + FFStats.getTotalFF() + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 160, 16, 16) && + currentPet != FarmingItems.RABBIT -> { + SoundUtils.playClickSound() + currentPet = FarmingItems.RABBIT + FFStats.getTotalFF() + } + GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 160, 16, 16) && + currentPet != FarmingItems.BEE -> { + SoundUtils.playClickSound() + currentPet = FarmingItems.BEE + FFStats.getTotalFF() + } } } } else { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt index dbd5f00c5..61a777a63 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt @@ -244,17 +244,24 @@ object FFStats { val strength = (GardenAPI.config?.fortune?.farmingStrength) if (strength != null) { val rawInternalName = pet.getInternalName() - return if (rawInternalName.contains("ELEPHANT;4")) { - 1.5 * petLevel - } else if (rawInternalName.contains("MOOSHROOM_COW;4")) { - (10 + petLevel).toDouble() + floor(floor(strength / (40 - petLevel * .2)) * .7) - } else if (rawInternalName.contains("MOOSHROOM")) { - (10 + petLevel).toDouble() - } else if (rawInternalName.contains("BEE;2")) { - 0.2 * petLevel - } else if (rawInternalName.contains("BEE;3") || rawInternalName.contains("BEE;4")) { - 0.3 * petLevel - } else 0.0 + return when { + rawInternalName.contains("ELEPHANT;4") -> { + 1.5 * petLevel + } + rawInternalName.contains("MOOSHROOM_COW;4") -> { + (10 + petLevel).toDouble() + floor(floor(strength / (40 - petLevel * .2)) * .7) + } + rawInternalName.contains("MOOSHROOM") -> { + (10 + petLevel).toDouble() + } + rawInternalName.contains("BEE;2") -> { + 0.2 * petLevel + } + rawInternalName.contains("BEE;3") || rawInternalName.contains("BEE;4") -> { + 0.3 * petLevel + } + else -> 0.0 + } } return 0.0 } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt index b92e63a20..2e785ea89 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt @@ -91,13 +91,16 @@ class OverviewPage: FFGuideGUI.FFGuidePage() { line = if (currentArmor == 0) "§7§2The base fortune from your armor\n§2Select a piece for more info" else "§7§2Base fortune from your\n${armorItem.getItem().displayName}" - value = if (currentArmor == 0) { - if (FFStats.usingSpeedBoots) 160 else 130 - } else if (currentArmor == 1) 30 - else if (currentArmor == 2) 35 - else if (currentArmor == 3) 35 - else { - if (FFStats.usingSpeedBoots) 60 else 30 + value = when (currentArmor) { + 0 -> { + if (FFStats.usingSpeedBoots) 160 else 130 + } + 1 -> 30 + 2 -> 35 + 3 -> 35 + else -> { + if (FFStats.usingSpeedBoots) 60 else 30 + } } GuiRenderUtils.drawFarmingBar("§2Base $word Fortune", line, armorFF[FFTypes.BASE] ?: 0, value, FFGuideGUI.guiLeft + 135, 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 375238dc3..5fa005021 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt @@ -98,16 +98,12 @@ class TpsCounter { } private fun getColor(tps: Double): String { - return if (tps > 19.8) { - "§2" - } else if (tps > 19) { - "§a" - } else if (tps > 17.5) { - "§6" - } else if (tps > 12) { - "§c" - } else { - "§4" + return 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 6e0f6acf0..9ec187ca8 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 @@ -100,21 +100,25 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) val island = LorenzUtils.skyBlockIsland if (location == "Your Island") location = "Private Island" - if (island == IslandType.PRIVATE_ISLAND_GUEST) lastKnownDisplayStrings[LOCATION] = - "${getVisitingName()}'s Island" - else if (island == IslandType.GARDEN) { - if (location.startsWith("Plot: ")) { - lastKnownDisplayStrings[LOCATION] = "Personal Garden ($location)" // Personal Garden (Plot: 8) - } else { - lastKnownDisplayStrings[LOCATION] = "Personal Garden" + 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) + } else { + 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 } - } else if (island == IslandType.GARDEN_GUEST) { - lastKnownDisplayStrings[LOCATION] = "${getVisitingName()}'s Garden" - if (location.startsWith("Plot: ")) { - lastKnownDisplayStrings[LOCATION] = "${lastKnownDisplayStrings[LOCATION]} ($location)" - } // "MelonKingDe's Garden (Plot: 8)" - } else if (location != "None" && location != "invalid") { - lastKnownDisplayStrings[LOCATION] = location } lastKnownDisplayStrings[LOCATION] ?: "None"// only display None if we don't have a last known area }), @@ -128,14 +132,19 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) val motes = scoreboard.firstOrNull { motesRegex.matches(it.removeColor()) }?.let { motesRegex.find(it.removeColor())?.groupValues?.get(1) ?: "" } - if (coins == "1") { - lastKnownDisplayStrings[PURSE] = "1 Coin" - } else if (coins != "" && coins != null) { - lastKnownDisplayStrings[PURSE] = "$coins Coins" - } else if (motes == "1") { - lastKnownDisplayStrings[PURSE] = "1 Mote" - } else if (motes != "" && motes != null) { - lastKnownDisplayStrings[PURSE] = "$motes Motes" + 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] ?: "" }), @@ -210,10 +219,12 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) var profile = "SkyBlock Level: [$sbLevel] on " profile += ( - if (HypixelData.ironman) "♲" - else if (HypixelData.bingo) "Ⓑ" - else if (HypixelData.stranded) "☀" - else "" + when { + HypixelData.ironman -> "♲" + HypixelData.bingo -> "Ⓑ" + HypixelData.stranded -> "☀" + else -> "" + } ) val fruit = HypixelData.profileName.firstLetterUppercase() @@ -235,18 +246,23 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) for (line in ScoreboardData.sidebarLinesFormatted) { val noColorLine = line.removeColor() val match = slayerRegex.matcher(noColorLine) - if (match.matches()) { - slayerName = match.group("name") - slayerLevel = match.group("level") - } else if (noColorLine == "Slay the boss!") bossAlive = "slaying" - else if (noColorLine == "Boss slain!") bossAlive = "slain" + when { + match.matches() -> { + slayerName = match.group("name") + slayerLevel = match.group("level") + } + noColorLine == "Slay the boss!" -> bossAlive = "slaying" + noColorLine == "Boss slain!" -> bossAlive = "slain" + } } - if (slayerLevel == "") AutoStatus.SLAYER.placeholderText // selected slayer in rpc but hasn't started a quest - else if (bossAlive == "spawning") "Spawning a $slayerName $slayerLevel boss." - else if (bossAlive == "slaying") "Slaying a $slayerName $slayerLevel boss." - else if (bossAlive == "slain") "Finished slaying a $slayerName $slayerLevel boss." - else "Something went wrong with slayer detection!" + when { + slayerLevel == "" -> AutoStatus.SLAYER.placeholderText // selected slayer in rpc but hasn't started a quest + bossAlive == "spawning" -> "Spawning a $slayerName $slayerLevel boss." + bossAlive == "slaying" -> "Slaying a $slayerName $slayerLevel boss." + bossAlive == "slain" -> "Finished slaying a $slayerName $slayerLevel boss." + else -> "Something went wrong with slayer detection!" + } }), CUSTOM({ 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 c0e506abf..365a8db0e 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 @@ -31,22 +31,28 @@ object GhostUtil { val hours = millis / 1000 / 60 / 60 % 24 val days = millis / 1000 / 60 / 60 / 24 return buildMap { - if (millis < 0) { - clear() - } else if (minutes == 0L && hours == 0L && days == 0L) { - put("seconds", seconds.toString()) - } else if (hours == 0L && days == 0L) { - put("seconds", seconds.toString()) - put("minutes", minutes.toString()) - } else if (days == 0L) { - put("seconds", seconds.toString()) - put("minutes", minutes.toString()) - put("hours", hours.toString()) - } else { - put("seconds", seconds.toString()) - put("minutes", minutes.toString()) - put("hours", hours.toString()) - put("days", days.toString()) + when { + 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()) + put("hours", hours.toString()) + put("days", days.toString()) + } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index f4809c10b..babf7e1c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -300,11 +300,9 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { fun finishKuudra(kuudraTier: KuudraTier) { val kuudraQuest = getQuest<KuudraQuest>() ?: return - if (kuudraQuest.kuudraTier == kuudraTier) { - //TODO make inline method for this two lines - if (kuudraQuest.state == QuestState.ACCEPTED) { - kuudraQuest.state = QuestState.READY_TO_COLLECT - } + //TODO make inline method for this two lines + if (kuudraQuest.kuudraTier == kuudraTier && kuudraQuest.state == QuestState.ACCEPTED) { + kuudraQuest.state = QuestState.READY_TO_COLLECT } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt index 1c19cdef9..d66973cd3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt @@ -50,17 +50,22 @@ object DanceRoomHelper { val size = instructions.size val format = line.format() - if (index < size && index == lineIndex) { - val countdown = countdown?.let { "${color.countdown.formatColor()}$it" } ?: "" - "${now.formatColor()} $format $countdown" + when { + index < size && index == lineIndex -> { + val countdown = countdown?.let { "${color.countdown.formatColor()}$it" } ?: "" + "${now.formatColor()} $format $countdown" - } else if (index + 1 < size && index + 1 == lineIndex) { - "${next.formatColor()} $format" + } + index + 1 < size && index + 1 == lineIndex -> { + "${next.formatColor()} $format" - } else if (index + 2 < size && (index + 2..index + config.lineToShow).contains(lineIndex)) { - "${later.formatColor()} $format" + } + index + 2 < size && (index + 2..index + config.lineToShow).contains(lineIndex) -> { + "${later.formatColor()} $format" - } else null + } + else -> null + } } private fun String.formatColor() = replace("&", "§") diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt index d9d5d59bf..308bebf7a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt @@ -185,12 +185,13 @@ object VampireSlayerFeatures { val shouldRender = if (ownBoss) true else if (otherBoss) true else coopBoss val color = - if (canUseSteak && config.changeColorWhenCanSteak) - config.steakColor.color() - else if (ownBoss) configOwnBoss.highlightColor.color() - else if (otherBoss) configOtherBoss.highlightColor.color() - else if (coopBoss) configCoopBoss.highlightColor.color() - else 0 + when { + canUseSteak && config.changeColorWhenCanSteak -> config.steakColor.color() + ownBoss -> configOwnBoss.highlightColor.color() + otherBoss -> configOtherBoss.highlightColor.color() + coopBoss -> configCoopBoss.highlightColor.color() + else -> 0 + } val shouldSendSteakTitle = if (canUseSteak && configOwnBoss.steakAlert && containUser) true diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt index 874697607..ab89d499d 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt @@ -82,13 +82,18 @@ object SkyHanniConfigSearchResetCommand { rawJson = readFromClipboard } - val root: Any = if (term.startsWith("config")) { - SkyHanniMod.feature - } else if (term.startsWith("playerSpecific")) { - ProfileStorageData.playerSpecific ?: return "§cplayerSpecific is null!" - } else if (term.startsWith("profileSpecific")) { - ProfileStorageData.profileSpecific ?: return "§cprofileSpecific is null!" - } else return "§cUnknown config location!" + val root: Any = when { + term.startsWith("config") -> { + SkyHanniMod.feature + } + term.startsWith("playerSpecific") -> { + ProfileStorageData.playerSpecific ?: return "§cplayerSpecific is null!" + } + term.startsWith("profileSpecific") -> { + ProfileStorageData.profileSpecific ?: return "§cprofileSpecific is null!" + } + else -> return "§cUnknown config location!" + } val affectedElements = findConfigElements({ it.startsWith("$term.") }, { true }).size if (affectedElements > 3 && !args.contentEquals(lastCommand)) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt index 3bf5ff2f6..52916b98d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt @@ -38,33 +38,35 @@ object CombatUtils { if (lastTotalXp > 0) { val delta: Float = totalXp - lastTotalXp - if (delta > 0 && delta < 1000) { - xpGainTimer = GhostCounter.config.pauseTimer - xpGainQueue.add(0, delta) - while (xpGainQueue.size > 30) { - xpGainQueue.removeLast() + when { + delta > 0 && delta < 1000 -> { + xpGainTimer = GhostCounter.config.pauseTimer + xpGainQueue.add(0, delta) + calculateXPHour() } - var totalGain = 0f - for (f in xpGainQueue) totalGain += f - xpGainHour = totalGain * (60 * 60) / xpGainQueue.size - isKilling = true - } else if (xpGainTimer > 0) { - xpGainTimer-- - xpGainQueue.add(0, 0f) - while (xpGainQueue.size > 30) { - xpGainQueue.removeLast() + xpGainTimer > 0 -> { + xpGainTimer-- + xpGainQueue.add(0, 0f) + calculateXPHour() + } + delta <= 0 -> { + isKilling = false } - var totalGain = 0f - for (f in xpGainQueue) totalGain += f - xpGainHour = totalGain * (60 * 60) / xpGainQueue.size - isKilling = true - } else if (delta <= 0) { - isKilling = false } } lastTotalXp = totalXp } + private fun calculateXPHour(){ + while (xpGainQueue.size > 30) { + xpGainQueue.removeLast() + } + var totalGain = 0f + for (f in xpGainQueue) totalGain += f + xpGainHour = totalGain * (60 * 60) / xpGainQueue.size + isKilling = true + } + fun calculateETA() { lastKillUpdate = System.currentTimeMillis() killGainHourLast = killGainHour |