diff options
8 files changed, 131 insertions, 37 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 296098f37..3297cdc3e 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.Features; import at.hannibal2.skyhanni.config.commands.Commands; import at.hannibal2.skyhanni.data.*; import at.hannibal2.skyhanni.data.repo.RepoManager; +import at.hannibal2.skyhanni.events.FirstConfigLoadedEvent; import at.hannibal2.skyhanni.features.anvil.AnvilCombineHelper; import at.hannibal2.skyhanni.features.bazaar.*; import at.hannibal2.skyhanni.features.bingo.CompactBingoChat; @@ -181,6 +182,8 @@ public class SkyHanniMod { configManager = new ConfigManager(); configManager.firstLoad(); + new FirstConfigLoadedEvent().postAndCatch(); + MinecraftConsoleFilter.Companion.initLogging(); Runtime.getRuntime().addShutdownHook(new Thread(configManager::saveConfig)); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java index b3d138269..7a26ace3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java @@ -2,7 +2,9 @@ package at.hannibal2.skyhanni.config.features; import com.google.gson.annotations.Expose; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; public class Hidden { @@ -18,4 +20,13 @@ public class Hidden { @Expose public Map<String, String> minionName = new HashMap<>(); + + @Expose + public List<String> crimsonIsleQuests = new ArrayList<>(); + + @Expose + public int crimsonIsleLatestTrophyFishInInventory = 0; + + @Expose + public List<String> crimsonIsleMiniBossesDoneToday = new ArrayList<>(); } diff --git a/src/main/java/at/hannibal2/skyhanni/events/FirstConfigLoadedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/FirstConfigLoadedEvent.kt new file mode 100644 index 000000000..0213ae835 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/FirstConfigLoadedEvent.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.events + +class FirstConfigLoadedEvent: LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt index f2c610e04..06fbc93d6 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt @@ -5,7 +5,7 @@ import com.google.gson.Gson import com.google.gson.JsonObject import java.io.File -class RepositoryReloadEvent(val repoLocation: File, val gson: Gson): LorenzEvent() { +class RepositoryReloadEvent(private val repoLocation: File, val gson: Gson): LorenzEvent() { fun getConstant(constant: String): JsonObject? { return RepoUtils.getConstant(repoLocation, constant, gson) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index b34ab8df3..5ba40ed41 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HyPixelData import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.FirstConfigLoadedEvent import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQuestHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.CrimsonMiniBoss import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.DailyMiniBossHelper @@ -20,6 +21,9 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { val miniBosses = mutableListOf<CrimsonMiniBoss>() + private val display = mutableListOf<String>() + private var dirty = true + init { skyHanniMod.loadModule(questHelper) skyHanniMod.loadModule(miniBossHelper) @@ -34,9 +38,6 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { miniBossHelper.init() } - private val display = mutableListOf<String>() - private var dirty = true - @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (!HyPixelData.skyBlock) return @@ -47,6 +48,12 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { } } + @SubscribeEvent + fun onFirstConfigLoaded(event: FirstConfigLoadedEvent) { + questHelper.loadConfig() + miniBossHelper.loadConfig() + } + private fun updateRender() { display.clear() @@ -67,5 +74,16 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { fun update() { dirty = true + + questHelper.saveConfig() + miniBossHelper.saveConfig() + } + + fun reset() { + LorenzUtils.chat("§e[SkyHanni] Reset Reputation Helper.") + + questHelper.reset() + miniBossHelper.reset() + update() } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index 6ae1beecb..463cd3347 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HyPixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiContainerEvent @@ -22,13 +23,11 @@ import net.minecraftforge.fml.common.gameevent.TickEvent class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { - val quests = mutableListOf<Quest>() private var tick = 0 - private val loader = QuestLoader(this) + val quests = mutableListOf<Quest>() private val sacksCache = mutableMapOf<String, Long>() - private var latestTrophyFishInInventory = 0 @SubscribeEvent @@ -40,16 +39,13 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { loader.checkInventory() checkInventory() } - if (tick % 60 == 0) { - checkInventoryForFetchItem() - } if (tick % 60 == 0) { + checkInventoryForFetchItem() loader.loadFromTabList() - if (quests.size != 5) { - quests.clear() - LorenzUtils.chat("§e[SkyHanni] Reset Quests.") + if (quests.size > 5) { + reputationHelper.reset() } } } @@ -269,4 +265,40 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { } } } + + fun reset() { + quests.clear() + latestTrophyFishInInventory = 0 + } + + fun loadConfig() { + loader.loadConfig() + } + + fun saveConfig() { + SkyHanniMod.feature.hidden.crimsonIsleQuests.clear() + for (quest in quests) { + val builder = StringBuilder() + val internalName = quest.internalName + builder.append(internalName) + builder.append(":") + val state = quest.state + builder.append(state) + + if (quest is ProgressQuest) { + val need = quest.needAmount + val have = quest.haveAmount + + builder.append(":") + builder.append(need) + builder.append(":") + builder.append(have) + } else { + builder.append(":0") + } + SkyHanniMod.feature.hidden.crimsonIsleQuests.add(builder.toString()) + } + + SkyHanniMod.feature.hidden.crimsonIsleLatestTrophyFishInInventory = latestTrophyFishInInventory + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt index 3d7c2b10a..7a50a483e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.* import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -12,10 +13,6 @@ import net.minecraft.inventory.ContainerChest class QuestLoader(val dailyQuestHelper: DailyQuestHelper) { fun loadFromTabList() { -// println(" ") -// println("#####") -// println(" ") - var i = -1 for (line in TabListUtils.getTabList()) { if (line.contains("Faction Quests:")) { @@ -49,15 +46,9 @@ class QuestLoader(val dailyQuestHelper: DailyQuestHelper) { } checkQuest(name, green, amount) - -// println("line: '$line'") -// println("green: '$green'") -// println("name: '$name'") -// println("amount: '$amount'") -// println(" ") } - private fun checkQuest(name: String, green: Boolean, amount: Int) { + private fun checkQuest(name: String, green: Boolean, needAmount: Int) { val oldQuest = getQuestByName(name) if (oldQuest != null) { if (green) { @@ -72,35 +63,35 @@ class QuestLoader(val dailyQuestHelper: DailyQuestHelper) { val state = if (green) QuestState.READY_TO_COLLECT else QuestState.NOT_ACCEPTED dailyQuestHelper.update() - dailyQuestHelper.quests.add(addQuest(name, state, amount)) + dailyQuestHelper.quests.add(addQuest(name, state, needAmount)) } private fun addQuest( name: String, state: QuestState, - amount: Int + needAmount: Int ): Quest { //TODO add repo //Trophy Fish - if (name == "Lavahorse") return TrophyFishQuest(name, state, amount) - if (name == "Gusher") return TrophyFishQuest(name, state, amount) - if (name == "Volcanic Stonefish") return TrophyFishQuest(name, state, amount) + if (name == "Lavahorse") return TrophyFishQuest(name, state, needAmount) + if (name == "Gusher") return TrophyFishQuest(name, state, needAmount) + if (name == "Volcanic Stonefish") return TrophyFishQuest(name, state, needAmount) //Rescue Mission if (name == "Rescue Mission") return RescueMissionQuest(state) for (miniBoss in dailyQuestHelper.reputationHelper.miniBosses) { if (name == miniBoss.displayName) { - return MiniBossQuest(miniBoss, state, amount) + return MiniBossQuest(miniBoss, state, needAmount) } } //Fetch - if (name == "Magmag") return FetchQuest(name, state, amount) - if (name == "Spectre Dust") return FetchQuest(name, state, amount) - if (name == "Tentacle Meat") return FetchQuest(name, state, amount) + if (name == "Magmag") return FetchQuest(name, state, needAmount) + if (name == "Spectre Dust") return FetchQuest(name, state, needAmount) + if (name == "Tentacle Meat") return FetchQuest(name, state, needAmount) if (name.startsWith("Mastery Rank ") || name.startsWith("Tenacity Rank ") || name.startsWith("Stamina Rank ")) { val split = name.split(" Rank ") @@ -156,4 +147,19 @@ class QuestLoader(val dailyQuestHelper: DailyQuestHelper) { } } } + + fun loadConfig() { + for (text in SkyHanniMod.feature.hidden.crimsonIsleQuests) { + val split = text.split(":") + val name = split[0] + val state = QuestState.valueOf(split[1]) + val needAmount = split[2].toInt() + val quest = addQuest(name, state, needAmount) + if (quest is ProgressQuest) { + val haveAmount = split[3].toInt() + quest.haveAmount = haveAmount + } + dailyQuestHelper.quests.add(quest) + } + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt index 515263db6..a4568363b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HyPixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -17,7 +18,6 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel for (miniBoss in reputationHelper.miniBosses) { miniBossesDoneToday[miniBoss] = false val patterns = " *§r§6§l${miniBoss.displayName.uppercase()} DOWN!" - println("patterns: '$patterns'") miniBossesPatterns[miniBoss] = Pattern.compile(patterns) } } @@ -33,10 +33,7 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel if (pattern.matcher(message).matches()) { finished(entry.key) } - //§r§6§BLADESOUL DOWN! } - // §r§6§lMAGMA BOSS DOWN! - // §r§6§lMAGE OUTLAW DOWN! } private fun finished(miniBoss: CrimsonMiniBoss) { @@ -64,4 +61,28 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel val displayName = miniBoss.displayName return "$displayName: $color" } + + fun reset() { + for (miniBoss in miniBossesDoneToday.keys) { + miniBossesDoneToday[miniBoss] = false + } + } + + fun saveConfig() { + SkyHanniMod.feature.hidden.crimsonIsleMiniBossesDoneToday.clear() + + for (entry in miniBossesDoneToday) { + if (entry.value) { + SkyHanniMod.feature.hidden.crimsonIsleMiniBossesDoneToday.add(entry.key.displayName) + } + } + } + + fun loadConfig() { + for (name in SkyHanniMod.feature.hidden.crimsonIsleMiniBossesDoneToday) { + miniBossesDoneToday[getByDisplayName(name)!!] = true + } + } + + private fun getByDisplayName(name: String) = miniBossesDoneToday.keys.firstOrNull { it.displayName == name } }
\ No newline at end of file |