diff options
Diffstat (limited to 'src/main')
34 files changed, 274 insertions, 328 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 4503a63b5..020ca7c88 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -6,48 +6,27 @@ import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.Features import at.hannibal2.skyhanni.config.SackData import at.hannibal2.skyhanni.config.commands.Commands -import at.hannibal2.skyhanni.data.ActionBarStatsData import at.hannibal2.skyhanni.data.GuiEditManager -import at.hannibal2.skyhanni.data.HotmData import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.OtherInventoryData import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.data.SkillExperience -import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson import at.hannibal2.skyhanni.data.jsonobjects.local.VisualWordsJson -import at.hannibal2.skyhanni.data.mob.MobData import at.hannibal2.skyhanni.data.repo.RepoManager import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PreInitFinishedEvent import at.hannibal2.skyhanni.features.bingo.card.BingoCardDisplay import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHelper import at.hannibal2.skyhanni.features.chat.Translator -import at.hannibal2.skyhanni.features.chat.WatchdogHider -import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper -import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder -import at.hannibal2.skyhanni.features.fame.CityProjectFeatures -import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager -import at.hannibal2.skyhanni.features.garden.AnitaMedalProfit -import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay -import at.hannibal2.skyhanni.features.garden.farming.GardenBestCropTime -import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard -import at.hannibal2.skyhanni.features.inventory.SkyblockGuideHighlightFeature -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarOrderHelper -import at.hannibal2.skyhanni.features.mining.KingTalismanHelper -import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventTracker import at.hannibal2.skyhanni.features.misc.CollectionTracker -import at.hannibal2.skyhanni.features.misc.MovementSpeedDisplay import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper -import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.skyhannimodule.LoadedModules import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests @@ -93,44 +72,20 @@ class SkyHanniMod { // data loadModule(HypixelData()) loadModule(ScoreboardData()) - loadModule(SeaCreatureManager()) - loadModule(MobData()) -// loadModule(Year300RaffleEvent) - loadModule(TitleManager()) loadModule(RenderLivingEntityHelper()) loadModule(SkillExperience()) loadModule(GuiEditManager()) - loadModule(ActionBarStatsData) - loadModule(GardenBestCropTime()) - loadModule(HotmData) - - // APIs - loadModule(BazaarApi()) // features - loadModule(BazaarOrderHelper()) loadModule(DamageIndicatorManager()) - loadModule(HellionShieldHelper()) - loadModule(PlayerChatFilter()) loadModule(BurrowWarpHelper()) loadModule(CollectionTracker()) - loadModule(CroesusChestTracker()) loadModule(CrimsonIsleReputationHelper(this)) - loadModule(SkyblockGuideHighlightFeature) loadModule(BingoCardDisplay()) loadModule(BingoNextStepHelper()) - loadModule(SkyMartCopperPrice()) loadModule(FarmingWeightDisplay()) - loadModule(AnitaMedalProfit()) - loadModule(CropSpeedMeter()) - loadModule(MovementSpeedDisplay()) - loadModule(CityProjectFeatures()) - loadModule(KingTalismanHelper()) - loadModule(WatchdogHider()) - loadModule(AccountUpgradeReminder()) loadModule(Translator()) loadModule(CustomScoreboard()) - loadModule(MiningEventTracker()) // test stuff loadModule(SkyHanniDebugsAndTests()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 8d8cfe021..cc0503f37 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker; import at.hannibal2.skyhanni.features.dungeon.DungeonFloor; import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker; import at.hannibal2.skyhanni.features.event.diana.MythologicalCreatureTracker; -import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats; import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker; import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker; import at.hannibal2.skyhanni.features.fishing.tracker.SeaCreatureTracker; @@ -554,7 +553,7 @@ public class ProfileSpecificStorage { public Map<DungeonFloor, Integer> bosses = new HashMap<>(); @Expose - public List<DungeonStorage.DungeonRunInfo> runs = CroesusChestTracker.Companion.generateMaxChestAsList(); + public List<DungeonStorage.DungeonRunInfo> runs = CroesusChestTracker.generateMaxChestAsList(); public static class DungeonRunInfo { diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt index fc7480729..b2145db76 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.ActionBarUpdateEvent import at.hannibal2.skyhanni.events.ActionBarValueUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -37,6 +38,7 @@ enum class ActionBarStatsData(@Language("RegExp") rawPattern: String) { var value: String = "" private set + @SkyHanniModule companion object { init { diff --git a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt index 841e39c17..51b86cf92 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf @@ -267,6 +268,7 @@ enum class HotmData( fun getReward() = rewardFun(activeLevel) + @SkyHanniModule companion object { val storage get() = ProfileStorageData.profileSpecific?.mining?.hotmTree diff --git a/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt b/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt index af3683402..95dbe1577 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark import io.github.notenoughupdates.moulconfig.internal.TextRenderUtils @@ -14,43 +15,41 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class TitleManager { +@SkyHanniModule +object TitleManager { - companion object { + private var originalText = "" + private var display = "" + private var endTime = SimpleTimeMark.farPast() + private var heightModifier = 1.8 + private var fontSizeModifier = 4f - private var originalText = "" - private var display = "" - private var endTime = SimpleTimeMark.farPast() - private var heightModifier = 1.8 - private var fontSizeModifier = 4f + fun sendTitle(text: String, duration: Duration, height: Double, fontSize: Float) { + originalText = text + display = "§f$text" + endTime = SimpleTimeMark.now() + duration + heightModifier = height + fontSizeModifier = fontSize + } - fun sendTitle(text: String, duration: Duration, height: Double, fontSize: Float) { - originalText = text - display = "§f$text" - endTime = SimpleTimeMark.now() + duration - heightModifier = height - fontSizeModifier = fontSize + fun optionalResetTitle(condition: (String) -> Boolean) { + if (condition(originalText)) { + sendTitle("", 1.milliseconds, 1.8, 4f) } + } - fun optionalResetTitle(condition: (String) -> Boolean) { - if (condition(originalText)) { - sendTitle("", 1.milliseconds, 1.8, 4f) - } + fun command(args: Array<String>) { + if (args.size < 4) { + ChatUtils.userError("Usage: /shsendtitle <duration> <height> <fontSize> <text ..>") + return } - fun command(args: Array<String>) { - if (args.size < 4) { - ChatUtils.userError("Usage: /shsendtitle <duration> <height> <fontSize> <text ..>") - return - } + val duration = args[0].toInt().seconds + val height = args[1].toDouble() + val fontSize = args[2].toFloat() + val title = "§6" + args.drop(3).joinToString(" ").replace("&", "§") - val duration = args[0].toInt().seconds - val height = args[1].toDouble() - val fontSize = args[2].toFloat() - val title = "§6" + args.drop(3).joinToString(" ").replace("&", "§") - - sendTitle(title, duration, height, fontSize) - } + sendTitle(title, duration, height, fontSize) } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt index b8bf67f81..59cacde87 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data.mob import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.takeIfAllNotNull import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzLogger @@ -11,36 +12,35 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.TreeMap import at.hannibal2.skyhanni.data.mob.Mob.Type as MobType -class MobData { +@SkyHanniModule +object MobData { class MobSet : HashSet<Mob>() { val entityList get() = this.flatMap { listOf(it.baseEntity) + (it.extraEntities) } } - companion object { - val players = MobSet() - val displayNPCs = MobSet() - val skyblockMobs = MobSet() - val summoningMobs = MobSet() - val special = MobSet() - val currentMobs = MobSet() + val players = MobSet() + val displayNPCs = MobSet() + val skyblockMobs = MobSet() + val summoningMobs = MobSet() + val special = MobSet() + val currentMobs = MobSet() - val entityToMob = mutableMapOf<EntityLivingBase, Mob>() + val entityToMob = mutableMapOf<EntityLivingBase, Mob>() - internal val currentEntityLiving = mutableSetOf<EntityLivingBase>() - internal val previousEntityLiving = mutableSetOf<EntityLivingBase>() + internal val currentEntityLiving = mutableSetOf<EntityLivingBase>() + internal val previousEntityLiving = mutableSetOf<EntityLivingBase>() - internal val retries = TreeMap<Int, RetryEntityInstancing>() + internal val retries = TreeMap<Int, RetryEntityInstancing>() - const val ENTITY_RENDER_RANGE_IN_BLOCKS = 80.0 // Entity DeRender after ~5 Chunks - const val DETECTION_RANGE = 22.0 - const val DISPLAY_NPC_DETECTION_RANGE = 24.0 // 24.0 + const val ENTITY_RENDER_RANGE_IN_BLOCKS = 80.0 // Entity DeRender after ~5 Chunks + const val DETECTION_RANGE = 22.0 + const val DISPLAY_NPC_DETECTION_RANGE = 24.0 // 24.0 - var externRemoveOfRetryAmount = 0 + var externRemoveOfRetryAmount = 0 - val logger = LorenzLogger("mob/detection") - } + val logger = LorenzLogger("mob/detection") internal enum class Result { Found, diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt index 9a1ec8672..452fa09b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt @@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.data.mob import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.mob.MobData.Companion.logger +import at.hannibal2.skyhanni.data.mob.MobData.logger import at.hannibal2.skyhanni.data.mob.MobFilter.isDisplayNPC import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer import at.hannibal2.skyhanni.data.mob.MobFilter.isSkyBlockMob 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 @@ -49,7 +49,6 @@ object GardenCropMilestoneDisplay { private val config get() = GardenAPI.config.cropMilestones private val overflowConfig get() = config.overflow private val storage get() = ProfileStorageData.profileSpecific?.garden?.customGoalMilestone - private val bestCropTime = GardenBestCropTime() private var lastPlaySoundTime = SimpleTimeMark.farPast() private var needsInventory = false @@ -87,7 +86,7 @@ object GardenCropMilestoneDisplay { } if (config.next.bestDisplay) { - config.next.displayPos.renderStringsAndItems(bestCropTime.display, posLabel = "Best Crop Time") + config.next.displayPos.renderStringsAndItems(GardenBestCropTime.display, posLabel = "Best Crop Time") } } @@ -138,14 +137,14 @@ object GardenCropMilestoneDisplay { fun update() { progressDisplay = emptyList() mushroomCowPerkDisplay = emptyList() - bestCropTime.display = emptyList() + GardenBestCropTime.display = emptyList() val currentCrop = GardenAPI.getCurrentlyFarmedCrop() currentCrop?.let { progressDisplay = drawProgressDisplay(it) } if (config.next.bestDisplay && config.next.bestAlwaysOn || currentCrop != null) { - bestCropTime.display = bestCropTime.drawBestDisplay(currentCrop) + GardenBestCropTime.display = GardenBestCropTime.drawBestDisplay(currentCrop) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt index 0b6d3c936..c01998cd4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.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.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -17,14 +18,15 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonPrimitive import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SkyMartCopperPrice { +@SkyHanniModule +object SkyMartCopperPrice { private val copperPattern by RepoPattern.pattern( "garden.inventory.skymart.copper", @@ -34,10 +36,7 @@ class SkyMartCopperPrice { private var display = emptyList<Renderable>() private val config get() = GardenAPI.config.skyMart - companion object { - - var inInventory = false - } + var inInventory = false @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt index e06e7975c..0b3a2830e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt @@ -5,15 +5,16 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.intellij.lang.annotations.Language @@ -68,6 +69,7 @@ class SkyblockGuideHighlightFeature private constructor( objectList.add(this) } + @SkyHanniModule companion object { private val skyblockGuideConfig get() = SkyHanniMod.feature.inventory.skyblockGuideConfig diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt index c1f8dd1d1..99e38fd77 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems @@ -32,43 +33,42 @@ import net.minecraft.inventory.ContainerChest import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BazaarApi { +@SkyHanniModule +object BazaarApi { private var loadedNpcPriceData = false - companion object { + val holder = BazaarDataHolder() + var inBazaarInventory = false + private var currentSearchedItem = "" - val holder = BazaarDataHolder() - var inBazaarInventory = false - private var currentSearchedItem = "" + var currentlyOpenedProduct: NEUInternalName? = null - var currentlyOpenedProduct: NEUInternalName? = null + fun NEUInternalName.getBazaarData(): BazaarData? = HypixelBazaarFetcher.latestProductInformation[this] - fun NEUInternalName.getBazaarData(): BazaarData? = HypixelBazaarFetcher.latestProductInformation[this] + fun NEUInternalName.getBazaarDataOrError(): BazaarData = getBazaarData() ?: run { + ErrorManager.skyHanniError( + "Can not find bazaar data for $itemName", + "internal name" to this + ) + } - fun NEUInternalName.getBazaarDataOrError(): BazaarData = getBazaarData() ?: run { - ErrorManager.skyHanniError( - "Can not find bazaar data for $itemName", - "internal name" to this - ) - } + fun isBazaarItem(stack: ItemStack): Boolean = stack.getInternalName().isBazaarItem() - fun isBazaarItem(stack: ItemStack): Boolean = stack.getInternalName().isBazaarItem() + fun NEUInternalName.isBazaarItem() = getBazaarData() != null - fun NEUInternalName.isBazaarItem() = getBazaarData() != null + fun searchForBazaarItem(internalName: NEUInternalName, amount: Int = -1) { + searchForBazaarItem(internalName.itemNameWithoutColor, amount) + } - fun searchForBazaarItem(internalName: NEUInternalName, amount: Int = -1) { - searchForBazaarItem(internalName.itemNameWithoutColor, amount) - } - fun searchForBazaarItem(displayName: String, amount: Int = -1) { - if (!LorenzUtils.inSkyBlock) return - if (NEUItems.neuHasFocus()) return - if (LorenzUtils.noTradeMode) return - if (DungeonAPI.inDungeon() || LorenzUtils.inKuudraFight) return - HypixelCommands.bazaar(displayName.removeColor()) - if (amount != -1) OSUtils.copyToClipboard(amount.toString()) - currentSearchedItem = displayName.removeColor() - } + fun searchForBazaarItem(displayName: String, amount: Int = -1) { + if (!LorenzUtils.inSkyBlock) return + if (NEUItems.neuHasFocus()) return + if (LorenzUtils.noTradeMode) return + if (DungeonAPI.inDungeon() || LorenzUtils.inKuudraFight) return + HypixelCommands.bazaar(displayName.removeColor()) + if (amount != -1) OSUtils.copyToClipboard(amount.toString()) + currentSearchedItem = displayName.removeColor() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt index b2ab56be6..631ee8175 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.events.BazaarOpenedProductEvent import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarDataOrError +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarDataOrError import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils.getAmountInInventory import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt index 3522eb735..771de0001 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt @@ -2,7 +2,8 @@ package at.hannibal2.skyhanni.features.inventory.bazaar import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarDataOrError +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarDataOrError +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -19,7 +20,8 @@ import net.minecraft.inventory.ContainerChest import net.minecraft.inventory.Slot import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BazaarOrderHelper { +@SkyHanniModule +object BazaarOrderHelper { private val patternGroup = RepoPattern.group("bazaar.orderhelper") private val bazaarItemNamePattern by patternGroup.pattern( "itemname", @@ -34,13 +36,10 @@ class BazaarOrderHelper { "§7Price per unit: §6(?<number>.*) coins" ) - companion object { - - fun isBazaarOrderInventory(inventoryName: String): Boolean = when (inventoryName) { - "Your Bazaar Orders" -> true - "Co-op Bazaar Orders" -> true - else -> false - } + fun isBazaarOrderInventory(inventoryName: String): Boolean = when (inventoryName) { + "Your Bazaar Orders" -> true + "Co-op Bazaar Orders" -> true + else -> false } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt index 4b0404bb7..009a972d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.isBazaarItem +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.isBazaarItem import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.addString diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt index dcc39c8b9..14999c107 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc @@ -23,7 +24,8 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.Collections -class KingTalismanHelper { +@SkyHanniModule +object KingTalismanHelper { private val config get() = SkyHanniMod.feature.mining.kingTalisman private val storage get() = ProfileStorageData.profileSpecific?.mining @@ -33,22 +35,19 @@ class KingTalismanHelper { "§6§lKing (?<name>.*)" ) - companion object { + private var currentOffset: Int? = null + private var skyblockYear = 0 - private var currentOffset: Int? = null - private var skyblockYear = 0 - - private fun getCurrentOffset(): Int? { - if (SkyBlockTime.now().year != skyblockYear) { - return null - } - return currentOffset + private fun getCurrentOffset(): Int? { + if (SkyBlockTime.now().year != skyblockYear) { + return null } + return currentOffset + } - fun kingFix() { - currentOffset = null - ChatUtils.chat("Reset internal offset of King Talisman Helper.") - } + fun kingFix() { + currentOffset = null + ChatUtils.chat("Reset internal offset of King Talisman Helper.") } private val kingLocation = LorenzVec(129.6, 196.5, 194.1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt index 698335f27..44fc087c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.ChatUtils @@ -29,7 +30,8 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class MiningEventTracker { +@SkyHanniModule +object MiningEventTracker { private val config get() = SkyHanniMod.feature.mining.miningEvent private val patternGroup = RepoPattern.group("mining.eventtracker") @@ -59,11 +61,9 @@ class MiningEventTracker { private var canRequestAt = SimpleTimeMark.farPast() - companion object { - var apiErrorCount = 0 + var apiErrorCount = 0 - val apiError get() = apiErrorCount > 0 - } + val apiError get() = apiErrorCount > 0 @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt index d9df6321b..50148f031 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -14,21 +15,20 @@ import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer -class MovementSpeedDisplay { +@SkyHanniModule +object MovementSpeedDisplay { private val config get() = SkyHanniMod.feature.misc private var display = "" private val soulsandSpeeds = mutableListOf<Double>() - companion object { - /** - * This speed value represents the movement speed in blocks per second. - * This has nothing to do with the speed stat. - */ - var speed = 0.0 - var usingSoulsandSpeed = false - } + /** + * This speed value represents the movement speed in blocks per second. + * This has nothing to do with the speed stat. + */ + var speed = 0.0 + var usingSoulsandSpeed = false init { // TODO use LorenzTickEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt index d501e3f0d..421ffb725 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt @@ -4,17 +4,16 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLiving import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HellionShieldHelper { +@SkyHanniModule +object HellionShieldHelper { - companion object { - - val hellionShieldMobs = mutableMapOf<EntityLiving, HellionShield>() - } + val hellionShieldMobs = mutableMapOf<EntityLiving, HellionShield>() @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { @@ -25,17 +24,17 @@ class HellionShieldHelper { fun onWorldChange(event: LorenzWorldChangeEvent) { hellionShieldMobs.clear() } -} -fun EntityLiving.setHellionShield(shield: HellionShield?) { - if (shield != null) { - HellionShieldHelper.hellionShieldMobs[this] = shield - RenderLivingEntityHelper.setEntityColorWithNoHurtTime( - this, - shield.color.toColor().withAlpha(80) - ) { LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.blazes.hellion.coloredMobs } - } else { - HellionShieldHelper.hellionShieldMobs.remove(this) - RenderLivingEntityHelper.removeCustomRender(this) + fun EntityLiving.setHellionShield(shield: HellionShield?) { + if (shield != null) { + hellionShieldMobs[this] = shield + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + this, + shield.color.toColor().withAlpha(80) + ) { LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.blazes.hellion.coloredMobs } + } else { + hellionShieldMobs.remove(this) + RenderLivingEntityHelper.removeCustomRender(this) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 83b1f0828..a31816140 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -15,7 +15,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 75b3e30c4..0577c05e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.MultiFilterJson import at.hannibal2.skyhanni.events.NeuProfileDataLoadedEvent import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarDataHolder import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt index beceaf8f9..2a3fd21d9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.TrackerManager -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList |