From 3ba6a1b438b4bb4d7143903bc477a1493508c54c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 8 Aug 2023 03:28:52 +0200 Subject: misc code cleanup --- .../hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 10 ++++------ .../skyhanni/features/bingo/BingoCardDisplay.kt | 14 ++++++-------- .../skyhanni/features/bingo/BingoNextStepHelper.kt | 14 +++++--------- .../hannibal2/skyhanni/features/chat/ChatFilterGui.kt | 2 +- .../skyhanni/features/commands/WarpIsCommand.kt | 8 +++----- .../skyhanni/features/event/diana/BurrowWarpHelper.kt | 4 ---- .../skyhanni/features/fishing/BarnFishingTimer.kt | 14 +++++--------- .../hannibal2/skyhanni/features/misc/BestiaryData.kt | 14 ++++++++------ .../skyhanni/features/misc/BrewingStandOverlay.kt | 3 +-- .../skyhanni/features/nether/ashfang/AshfangBlazes.kt | 19 +++++++++++-------- .../slayer/blaze/BlazeSlayerFirePitsWarning.kt | 10 ++-------- 11 files changed, 46 insertions(+), 66 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index a90520651..b0c08a4e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -103,12 +103,10 @@ class BazaarApi { private fun checkIfInBazaar(event: InventoryFullyOpenedEvent): Boolean { val returnItem = event.inventorySize - 5 for ((slot, item) in event.inventoryItems) { - if (slot == returnItem) { - if (item.name?.removeColor().let { it == "Go Back" }) { - val lore = item.getLore() - if (lore.getOrNull(0)?.removeColor().let { it == "To Bazaar" }) { - return true - } + if (slot == returnItem && item.name?.removeColor().let { it == "Go Back" }) { + val lore = item.getLore() + if (lore.getOrNull(0)?.removeColor().let { it == "To Bazaar" }) { + return true } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt index 01f4cbe0b..c2610d930 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt @@ -142,14 +142,12 @@ class BingoCardDisplay { if (!LorenzUtils.isBingoProfile) return if (!config.enabled) return - if (config.quickToggle) { - if (ItemUtils.isSkyBlockMenuItem(InventoryUtils.getItemInHand())) { - val sneaking = Minecraft.getMinecraft().thePlayer.isSneaking - if (lastSneak != sneaking) { - lastSneak = sneaking - if (sneaking) { - toggleMode() - } + if (config.quickToggle && ItemUtils.isSkyBlockMenuItem(InventoryUtils.getItemInHand())) { + val sneaking = Minecraft.getMinecraft().thePlayer.isSneaking + if (lastSneak != sneaking) { + lastSneak = sneaking + if (sneaking) { + toggleMode() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt index 61a6390a6..e740d0af2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt @@ -76,11 +76,9 @@ class BingoNextStepHelper { } } - if (!step.done && !parentDone) { - if (requirementsToDo == 0) { - if (!currentSteps.contains(step)) { - currentSteps = currentSteps.editCopy { add(step) } - } + if (!step.done && !parentDone && requirementsToDo == 0) { + if (!currentSteps.contains(step)) { + currentSteps = currentSteps.editCopy { add(step) } } } } @@ -195,10 +193,8 @@ class BingoNextStepHelper { if (done) return done = true updateResult() - if (!silent) { - if (config.stepHelper) { - LorenzUtils.chat("§e[SkyHanni] A bingo goal step is done! ($displayName)") - } + if (!silent && config.stepHelper) { + LorenzUtils.chat("§e[SkyHanni] A bingo goal step is done! ($displayName)") } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt index 971878306..0cf4f5b57 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt @@ -34,7 +34,7 @@ class ChatFilterGui(private val history: List 10) { warpPoint diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt index ed2321058..1c420af0c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt @@ -47,10 +47,8 @@ class BarnFishingTimer { private fun checkMobs() { val newCount = if (inHollows) countHollowsMobs() else countMobs() - if (currentCount == 0) { - if (newCount > 0) { - startTime = System.currentTimeMillis() - } + if (currentCount == 0 && newCount > 0) { + startTime = System.currentTimeMillis() } currentCount = newCount @@ -67,11 +65,9 @@ class BarnFishingTimer { .count { it.endsWith("§c❤") } private fun isRightLocation(): Boolean { - if (config.barnTimerCrystalHollows) { - if (IslandType.CRYSTAL_HOLLOWS.isInIsland()) { - inHollows = true - return true - } + if (config.barnTimerCrystalHollows && IslandType.CRYSTAL_HOLLOWS.isInIsland()) { + inHollows = true + return true } inHollows = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt index b25d4be39..104d6b25f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt @@ -340,13 +340,15 @@ object BestiaryData { for (cat in catList) { newDisplay.add(buildList { add(" §7- ${cat.name}§7: ") - if (cat.familiesCompleted == cat.totalFamilies) { - add("§c§lCompleted!") - } else if (cat.familiesFound == cat.totalFamilies) { - add("§b${cat.familiesCompleted}§7/§b${cat.totalFamilies} §7completed") - } else if (cat.familiesFound < cat.totalFamilies) { - add("§b${cat.familiesFound}§7/§b${cat.totalFamilies} §7found, §b${cat.familiesCompleted}§7/§b${cat.totalFamilies} §7completed") + val element = when { + cat.familiesCompleted == cat.totalFamilies -> "§c§lCompleted!" + cat.familiesFound == cat.totalFamilies -> "§b${cat.familiesCompleted}§7/§b${cat.totalFamilies} §7completed" + cat.familiesFound < cat.totalFamilies -> + "§b${cat.familiesFound}§7/§b${cat.totalFamilies} §7found, §b${cat.familiesCompleted}§7/§b${cat.totalFamilies} §7completed" + + else -> continue } + add(element) }) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BrewingStandOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BrewingStandOverlay.kt index 5557309a2..d7bee2948 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BrewingStandOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BrewingStandOverlay.kt @@ -23,8 +23,7 @@ class BrewingStandOverlay { 13, // Ingredient input 21, // Progress 42, // Output right side - -> { - } + -> Unit else -> return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt index fb6095059..e6d57a184 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt @@ -37,14 +37,17 @@ class AshfangBlazes { if (list.size == 1) { val armorStand = list[0] blazeArmorStand[entity] = armorStand - if (armorStand.name.contains("Ashfang Follower")) { - blazeColor[entity] = LorenzColor.DARK_GRAY - } else if (armorStand.name.contains("Ashfang Underling")) { - blazeColor[entity] = LorenzColor.RED - } else if (armorStand.name.contains("Ashfang Acolyte")) { - blazeColor[entity] = LorenzColor.BLUE - } else { - blazeArmorStand.remove(entity) + val color = when { + armorStand.name.contains("Ashfang Follower") -> LorenzColor.DARK_GRAY + armorStand.name.contains("Ashfang Underling") -> LorenzColor.RED + armorStand.name.contains("Ashfang Acolyte") -> LorenzColor.BLUE + else -> { + blazeArmorStand.remove(entity) + null + } + } + color?.let { + blazeColor[entity] = it } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt index 9d61e1393..c518d1317 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt @@ -28,14 +28,8 @@ class BlazeSlayerFirePitsWarning { val difference = System.currentTimeMillis() - lastFirePitsWarning - if (difference > 0) { - if (difference <= 2_000) { - if (event.isMod(10)) { - if (config.firePitsWarning) { - SoundUtils.createSound("random.orb", 0.8f).playSound() - } - } - } + if (difference in 1..2_000 && event.isMod(10) && config.firePitsWarning) { + SoundUtils.createSound("random.orb", 0.8f).playSound() } } -- cgit