diff options
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. |
