diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
24 files changed, 219 insertions, 230 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt index 11e51e686..6e1b00504 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt @@ -4,33 +4,39 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class WatchdogHider { +@SkyHanniModule +object WatchdogHider { private var inWatchdog = false private var blockedLines = 0 private var startLineComponent: IChatComponent? = null + private const val START_LINE = "§f" + private const val ANNOUNCEMENT_LINE = "§4[WATCHDOG ANNOUNCEMENT]" + private const val END_LINE = "§c" + @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!LorenzUtils.onHypixel || !SkyHanniMod.feature.chat.filterType.watchDog) return when (event.message) { - watchdogStartLine -> { + START_LINE -> { startLineComponent = event.chatComponent blockedLines = 0 } - watchdogAnnouncementLine -> { + ANNOUNCEMENT_LINE -> { ChatManager.retractMessage(startLineComponent, "watchdog") startLineComponent = null inWatchdog = true } - watchdogEndLine -> { + END_LINE -> { event.blockedReason = "watchdog" inWatchdog = false } @@ -46,17 +52,8 @@ class WatchdogHider { } } - companion object { - - private const val watchdogStartLine = "§f" - private const val watchdogAnnouncementLine = "§4[WATCHDOG ANNOUNCEMENT]" - private const val watchdogEndLine = "§c" - } - @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "chat.watchDog", "chat.filterType.watchDog") } } - - diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt index cb6f68c4d..23de5de6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt @@ -2,26 +2,25 @@ package at.hannibal2.skyhanni.features.chat.playerchat import at.hannibal2.skyhanni.data.jsonobjects.repo.PlayerChatFilterJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.MultiFilter import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PlayerChatFilter { +@SkyHanniModule +object PlayerChatFilter { - companion object { + private val filters = mutableMapOf<String, MultiFilter>() - private val filters = mutableMapOf<String, MultiFilter>() - - fun shouldChatFilter(original: IChatComponent): Boolean { - val message = original.formattedText.lowercase() - for (filter in filters) { - filter.value.matchResult(message)?.let { - return true - } + fun shouldChatFilter(original: IChatComponent): Boolean { + val message = original.formattedText.lowercase() + for (filter in filters) { + filter.value.matchResult(message)?.let { + return true } - - return false } + + return false } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index 6ee7979fa..80b912aa5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -19,7 +19,7 @@ import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.slayer.blaze.HellionShield -import at.hannibal2.skyhanni.features.slayer.blaze.setHellionShield +import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper.setHellionShield import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.CollectionUtils.put diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt index af666b5f0..89fdc89ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt @@ -23,7 +23,7 @@ import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.formatText import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.isUsingCTGhostCounter import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.preFormat import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.prettyTime -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ChatUtils.chat diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt index b565c0210..801b4f800 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.DungeonChest +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -31,7 +32,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CroesusChestTracker { +@SkyHanniModule +object CroesusChestTracker { private val config get() = SkyHanniMod.feature.dungeon.chest @@ -49,10 +51,11 @@ class CroesusChestTracker { private val openedPattern by patternGroup.pattern("chest.state.opened", "§8Opened Chest:.*") private val unopenedPattern by patternGroup.pattern("chest.state.unopened", "§8No Chests Opened!") - private val kismetSlotId = 50 - private val emptySlotId = 22 - private val frontArrowSlotId = 53 - private val backArrowSlotId = 45 + private const val KISMET_SLOT = 50 + private const val EMPTY_SLOT = 22 + private const val FRONT_ARROW_SLOT = 53 + private const val BACK_ARROW_SLOT = 45 + private const val MAX_CHESTS = 60 private val kismetInternalName = "KISMET_FEATHER".asInternalName() @@ -67,6 +70,8 @@ class CroesusChestTracker { private var kismetAmountCache = 0 + private val croesusChests get() = ProfileStorageData.profileSpecific?.dungeons?.runs + @SubscribeEvent(priority = EventPriority.LOW) fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { if (!LorenzUtils.inSkyBlock) return @@ -119,7 +124,7 @@ class CroesusChestTracker { kismetAmountCache = getKismetAmount() } if (config.showUsedKismets) { - val kismetItem = event.inventoryItems[kismetSlotId] ?: return + val kismetItem = event.inventoryItems[KISMET_SLOT] ?: return if (config.showUsedKismets && kismetUsedPattern.matches(kismetItem.getLore().lastOrNull())) setKismetUsed() } @@ -155,8 +160,8 @@ class CroesusChestTracker { private fun pageSetup(event: InventoryFullyOpenedEvent) { inCroesusInventory = true pageSwitchable = true - croesusEmpty = croesusEmptyPattern.matches(event.inventoryItems[emptySlotId]?.name) - if (event.inventoryItems[backArrowSlotId]?.item != Items.arrow) { + croesusEmpty = croesusEmptyPattern.matches(event.inventoryItems[EMPTY_SLOT]?.name) + if (event.inventoryItems[BACK_ARROW_SLOT]?.item != Items.arrow) { currentPage = 0 } } @@ -177,19 +182,19 @@ class CroesusChestTracker { fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.showUsedKismets) return - if (chestInventory != null && event.slotId == kismetSlotId) { + if (chestInventory != null && event.slotId == KISMET_SLOT) { setKismetUsed() return } if (inCroesusInventory && !croesusEmpty) { if (event.slot == null) return when (event.slotId) { - frontArrowSlotId -> if (pageSwitchable && event.slot.stack.isArrow()) { + FRONT_ARROW_SLOT -> if (pageSwitchable && event.slot.stack.isArrow()) { pageSwitchable = false currentPage++ } - backArrowSlotId -> if (pageSwitchable && event.slot.stack.isArrow()) { + BACK_ARROW_SLOT -> if (pageSwitchable && event.slot.stack.isArrow()) { pageSwitchable = false currentPage-- } @@ -227,7 +232,7 @@ class CroesusChestTracker { if (event.floor == "E") return croesusChests?.add(0, DungeonRunInfo(event.floor)) currentRunIndex = 0 - if ((croesusChests?.size ?: 0) > maxChests) { + if ((croesusChests?.size ?: 0) > MAX_CHESTS) { croesusChests?.dropLast(1) } @@ -261,26 +266,21 @@ class CroesusChestTracker { private inline fun <reified T> runSlots(slotId: Int, any: T) = croesusSlotMapToRun(slotId)?.getRun()?.let { it to any } - companion object { - val maxChests = 60 - - private val croesusChests get() = ProfileStorageData.profileSpecific?.dungeons?.runs - - fun resetChest() = croesusChests?.let { - it.clear() - it.addAll(generateMaxChest()) - ChatUtils.chat("Kismet State was cleared!") - } + fun resetChest() = croesusChests?.let { + it.clear() + it.addAll(generateMaxChest()) + ChatUtils.chat("Kismet State was cleared!") + } - fun generateMaxChest(): Sequence<DungeonRunInfo> = generateSequence { DungeonRunInfo() }.take(maxChests) - fun generateMaxChestAsList(): List<DungeonRunInfo> = generateMaxChest().toList() + @JvmStatic + fun generateMaxChestAsList(): List<DungeonRunInfo> = generateMaxChest().toList() + private fun generateMaxChest(): Sequence<DungeonRunInfo> = generateSequence { DungeonRunInfo() }.take(MAX_CHESTS) - fun getLastActiveChest(includeDungeonKey: Boolean = false): Int = - (croesusChests?.indexOfLast { - it.floor != null && - (it.openState == OpenedState.UNOPENED || (includeDungeonKey && it.openState == OpenedState.OPENED)) - } ?: -1) + 1 - } + fun getLastActiveChest(includeDungeonKey: Boolean = false): Int = + (croesusChests?.indexOfLast { + it.floor != null && + (it.openState == OpenedState.UNOPENED || (includeDungeonKey && it.openState == OpenedState.OPENED)) + } ?: -1) + 1 enum class OpenedState { UNOPENED, diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt index 4e8bc060c..134e09d09 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt @@ -20,6 +20,7 @@ import java.time.Instant import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +// @SkyHanniModule object Year300RaffleEvent { private val config get() = SkyHanniMod.feature.event.century diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt index b26a05094..b1001fe52 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils @@ -17,12 +18,18 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.seconds -class AccountUpgradeReminder { +@SkyHanniModule +object AccountUpgradeReminder { private var inInventory = false private var duration: Duration? = null private var lastReminderSend = SimpleTimeMark.farPast() + // TODO repo patterns + private val durationRegex = "§8Duration: (\\d{1,3})d".toRegex() + private val startedRegex = "§eYou started the §r§a(.+) §r§eupgrade!".toRegex() + private val claimedRegex = "§eYou claimed the §r§a.+ §r§eupgrade!".toRegex() + // TODO: find a way to save SimpleTimeMark directly in the config private var nextCompletionTime: SimpleTimeMark? get() = ProfileStorageData.playerSpecific?.nextAccountUpgradeCompletionTime?.asTimeMark() @@ -104,17 +111,10 @@ class AccountUpgradeReminder { nextCompletionTime = SimpleTimeMark.farPast() } - companion object { - - private val durationRegex = "§8Duration: (\\d{1,3})d".toRegex() - private val startedRegex = "§eYou started the §r§a(.+) §r§eupgrade!".toRegex() - private val claimedRegex = "§eYou claimed the §r§a.+ §r§eupgrade!".toRegex() + private fun isEnabled() = SkyHanniMod.feature.misc.accountUpgradeReminder - private fun isEnabled() = SkyHanniMod.feature.misc.accountUpgradeReminder - - fun disable() { - SkyHanniMod.feature.misc.accountUpgradeReminder = false - ChatUtils.chat("Disabled account upgrade reminder.") - } + fun disable() { + SkyHanniMod.feature.misc.accountUpgradeReminder = false + ChatUtils.chat("Disabled account upgrade reminder.") } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt index 7b2ef9bce..88d9f52a8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems @@ -40,7 +41,10 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class CityProjectFeatures { +@SkyHanniModule +object CityProjectFeatures { + + private val config get() = SkyHanniMod.feature.event.cityProject private var display = emptyList<List<Any>>() private var inInventory = false @@ -56,13 +60,9 @@ class CityProjectFeatures { "§aProject is (?:being built|released)!" ) - companion object { - - private val config get() = SkyHanniMod.feature.event.cityProject - fun disable() { - config.dailyReminder = false - ChatUtils.chat("Disabled city project reminder messages!") - } + fun disable() { + config.dailyReminder = false + ChatUtils.chat("Disabled city project reminder messages!") } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt index 5f7499574..b665cf7bc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt @@ -5,13 +5,24 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.SeaCreatureJson import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SeaCreatureManager { +@SkyHanniModule +object SeaCreatureManager { private var doubleHook = false + private val seaCreatureMap = mutableMapOf<String, SeaCreature>() + var allFishingMobs = mapOf<String, SeaCreature>() + var allVariants = mapOf<String, List<String>>() + + private val doubleHookMessages = setOf( + "§eIt's a §r§aDouble Hook§r§e! Woot woot!", + "§eIt's a §r§aDouble Hook§r§e!" + ) + @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!LorenzUtils.inSkyBlock) return @@ -61,19 +72,7 @@ class SeaCreatureManager { allVariants = variants } - companion object { - - private val seaCreatureMap = mutableMapOf<String, SeaCreature>() - var allFishingMobs = mapOf<String, SeaCreature>() - var allVariants = mapOf<String, List<String>>() - - private val doubleHookMessages = setOf( - "§eIt's a §r§aDouble Hook§r§e! Woot woot!", - "§eIt's a §r§aDouble Hook§r§e!" - ) - - fun getSeaCreatureFromMessage(message: String): SeaCreature? { - return seaCreatureMap.getOrDefault(message, null) - } + private fun getSeaCreatureFromMessage(message: String): SeaCreature? { + return seaCreatureMap.getOrDefault(message, null) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index d642140b9..191dc125a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.InventoryUtils @@ -25,15 +26,13 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AnitaMedalProfit { +@SkyHanniModule +object AnitaMedalProfit { private val config get() = GardenAPI.config.anitaShop private var display = emptyList<Renderable>() - companion object { - - var inInventory = false - } + var inInventory = false enum class MedalType(val displayName: String, val factorBronze: Int) { GOLD("§6Gold medal", 8), diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index 97a63928c..b149dedad 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -13,8 +13,8 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.isBazaarItem +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.isBazaarItem import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarData import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt index 710862f90..aa977b65a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt @@ -7,19 +7,24 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CropSpeedMeter { +@SkyHanniModule +object CropSpeedMeter { private var display = emptyList<String>() private var currentCrop: CropType? = null private var currentBlocks = 0 private var snapshot = emptyList<String>() + var enabled = false + private var startCrops = mapOf<CropType, Long>() + @SubscribeEvent fun onCropClick(event: CropClickEvent) { if (!isEnabled()) return @@ -98,7 +103,6 @@ class CropSpeedMeter { val baseDrops = it.baseDrops val farmingFortune = (cropsPerBlocks * 100 / baseDrops).round(3) - list.add(" §7Calculated farming Fortune: §e" + farmingFortune.addSeparators()) list.add("§cOpen /cropmilestones again to recalculate!") @@ -112,16 +116,10 @@ class CropSpeedMeter { currentBlocks++ } - companion object { - - var enabled = false - private var startCrops = mapOf<CropType, Long>() - - fun toggle() { - enabled = !enabled - ChatUtils.chat("Crop Speed Meter " + if (enabled) "§aEnabled" else "§cDisabled") - startCrops = emptyMap() - } + fun toggle() { + enabled = !enabled + ChatUtils.chat("Crop Speed Meter " + if (enabled) "§aEnabled" else "§cDisabled") + startCrops = emptyMap() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index b1c2a3b82..2412c7596 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.ConfigUtils @@ -18,41 +19,39 @@ import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenBestCropTime { +@SkyHanniModule +object GardenBestCropTime { var display = emptyList<List<Any>>() - companion object { + private val config get() = GardenAPI.config.cropMilestones + val timeTillNextCrop = mutableMapOf<CropType, Long>() - private val config get() = GardenAPI.config.cropMilestones - val timeTillNextCrop = mutableMapOf<CropType, Long>() - - fun reset() { - timeTillNextCrop.clear() - updateTimeTillNextCrop() - } + fun reset() { + timeTillNextCrop.clear() + updateTimeTillNextCrop() + } - fun updateTimeTillNextCrop() { - val useOverflow = config.overflow.bestCropTime - for (crop in CropType.entries) { - val speed = crop.getSpeed() ?: continue - if (crop.isMaxed(useOverflow)) continue + fun updateTimeTillNextCrop() { + val useOverflow = config.overflow.bestCropTime + for (crop in CropType.entries) { + val speed = crop.getSpeed() ?: continue + if (crop.isMaxed(useOverflow)) continue - val counter = crop.getCounter() - val currentTier = GardenCropMilestones.getTierForCropCount(counter, crop, allowOverflow = true) + val counter = crop.getCounter() + val currentTier = GardenCropMilestones.getTierForCropCount(counter, crop, allowOverflow = true) - val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier, crop) - val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 - val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier, crop) + val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier, crop) + val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 + val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier, crop) - val have = counter - cropsForCurrentTier - val need = cropsForNextTier - cropsForCurrentTier + val have = counter - cropsForCurrentTier + val need = cropsForNextTier - cropsForCurrentTier - val missing = need - have - val missingTimeSeconds = missing / speed - val millis = missingTimeSeconds * 1000 - timeTillNextCrop[crop] = millis - } + val missing = need - have + val missingTimeSeconds = missing / speed + val millis = missingTimeSeconds * 1000 + timeTillNextCrop[crop] = millis } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index 667659129..f782b1b37 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ - |
