From a2f29b2bfe846c9d0cd2a45b2b8352bab556da37 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sat, 8 Jun 2024 23:46:53 +1000 Subject: Even more annotation (#2031) --- .../features/bingo/card/BingoCardDisplay.kt | 53 +++++----- .../card/nextstephelper/BingoNextStepHelper.kt | 107 ++++++++++----------- 2 files changed, 79 insertions(+), 81 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/bingo') diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt index 72d8fb955..94bd4f6dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.bingo.BingoCardUpdateEvent import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.HypixelCommands @@ -28,45 +29,43 @@ import net.minecraft.client.gui.inventory.GuiInventory import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.days -class BingoCardDisplay { +@SkyHanniModule +object BingoCardDisplay { private var display = emptyList() private var hasHiddenPersonalGoals = false - companion object { + private const val MAX_PERSONAL_GOALS = 20 + private const val MAX_COMMUNITY_GOALS = 5 - private const val MAX_PERSONAL_GOALS = 20 - private const val MAX_COMMUNITY_GOALS = 5 + private val config get() = SkyHanniMod.feature.event.bingo.bingoCard + private var displayMode = 0 - private val config get() = SkyHanniMod.feature.event.bingo.bingoCard - private var displayMode = 0 + fun command() { + reload() + } - fun command() { - reload() - } + private fun reload() { + BingoAPI.bingoGoals.clear() + } - private fun reload() { - BingoAPI.bingoGoals.clear() + fun toggleCommand() { + if (!LorenzUtils.isBingoProfile) { + ChatUtils.userError("This command only works on a bingo profile!") + return } - - fun toggleCommand() { - if (!LorenzUtils.isBingoProfile) { - ChatUtils.userError("This command only works on a bingo profile!") - return - } - if (!config.enabled) { - ChatUtils.userError("Bingo Card is disabled in the config!") - return - } - toggleMode() + if (!config.enabled) { + ChatUtils.userError("Bingo Card is disabled in the config!") + return } + toggleMode() + } - private fun toggleMode() { - displayMode++ - if (displayMode == 3) { - displayMode = 0 - } + private fun toggleMode() { + displayMode++ + if (displayMode == 3) { + displayMode = 0 } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt index b723a41c0..427fbb902 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps.ObtainCrys import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps.PartialProgressItemsStep import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps.ProgressionStep import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps.SkillLevelStep +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.InventoryUtils @@ -29,7 +30,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BingoNextStepHelper { +@SkyHanniModule +object BingoNextStepHelper { private val config get() = SkyHanniMod.feature.event.bingo.bingoCard private var dirty = true @@ -61,72 +63,69 @@ class BingoNextStepHelper { private val islands = mutableMapOf() private val rhysTaskName = "30x Enchanted Minerals (Redstone, Lapis Lazuli, Coal) (for Rhys)" - companion object { + private val finalSteps = mutableListOf() + private var currentSteps = emptyList() + var currentHelp = emptyList() - private val finalSteps = mutableListOf() - private var currentSteps = emptyList() - var currentHelp = emptyList() - - fun command() { - updateResult(true) - } + fun command() { + updateResult(true) + } - private fun updateResult(print: Boolean = false) { + private fun updateResult(print: Boolean = false) { + if (print) println() + currentSteps = listOf() + for (step in finalSteps) { + printRequirements(step, print) if (print) println() - currentSteps = listOf() - for (step in finalSteps) { - printRequirements(step, print) - if (print) println() - } - - currentHelp = drawDisplay(print) } - private fun drawDisplay(print: Boolean): MutableList { - val newCurrentHelp = mutableListOf() - newCurrentHelp.add("§6Bingo Step Helper:") + currentHelp = drawDisplay(print) + } - if (currentSteps.isEmpty()) { - newCurrentHelp.add("§cOpen the §e/bingo §ccard.") - } - for (currentStep in currentSteps) { - val text = getName(currentStep) - newCurrentHelp.add(" §7$text") - if (print) println(text) - } - if (print) println() - return newCurrentHelp - } + private fun drawDisplay(print: Boolean): MutableList { + val newCurrentHelp = mutableListOf() + newCurrentHelp.add("§6Bingo Step Helper:") - private fun printRequirements(step: NextStep, print: Boolean, parentDone: Boolean = false, depth: Int = 0) { - if (print) println(getName(step, parentDone, depth)) - var requirementsToDo = 0 - for (requirement in step.requirements) { - printRequirements(requirement, print, step.done || parentDone, depth + 1) - if (!requirement.done) { - requirementsToDo++ - } - } + if (currentSteps.isEmpty()) { + newCurrentHelp.add("§cOpen the §e/bingo §ccard.") + } + for (currentStep in currentSteps) { + val text = getName(currentStep) + newCurrentHelp.add(" §7$text") + if (print) println(text) + } + if (print) println() + return newCurrentHelp + } - if (!step.done && !parentDone && requirementsToDo == 0 && !currentSteps.contains(step)) { - currentSteps = currentSteps.editCopy { add(step) } + private fun printRequirements(step: NextStep, print: Boolean, parentDone: Boolean = false, depth: Int = 0) { + if (print) println(getName(step, parentDone, depth)) + var requirementsToDo = 0 + for (requirement in step.requirements) { + printRequirements(requirement, print, step.done || parentDone, depth + 1) + if (!requirement.done) { + requirementsToDo++ } } - private fun getName(step: NextStep, parentDone: Boolean = false, depth: Int = 0): String { - val prefix = " ".repeat(depth) + if (step.done) "[DONE] " else if (parentDone) "[done] " else "" - val suffix = if (step is ProgressionStep) progressDisplay(step) else "" - return prefix + step.displayName + suffix + if (!step.done && !parentDone && requirementsToDo == 0 && !currentSteps.contains(step)) { + currentSteps = currentSteps.editCopy { add(step) } } + } - private fun progressDisplay(step: ProgressionStep): String { - val having = step.amountHaving - return if (having > 0) { - val needed = step.amountNeeded - val percentage = LorenzUtils.formatPercentage(having.toDouble() / needed) - " $percentage (${having.addSeparators()}/${needed.addSeparators()})" - } else "" - } + private fun getName(step: NextStep, parentDone: Boolean = false, depth: Int = 0): String { + val prefix = " ".repeat(depth) + if (step.done) "[DONE] " else if (parentDone) "[done] " else "" + val suffix = if (step is ProgressionStep) progressDisplay(step) else "" + return prefix + step.displayName + suffix + } + + private fun progressDisplay(step: ProgressionStep): String { + val having = step.amountHaving + return if (having > 0) { + val needed = step.amountNeeded + val percentage = LorenzUtils.formatPercentage(having.toDouble() / needed) + " $percentage (${having.addSeparators()}/${needed.addSeparators()})" + } else "" } init { -- cgit