aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-01-13 21:56:43 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-01-13 21:56:43 +0100
commit670e0227c744502087dfd1f6c2aaa015087e3eeb (patch)
tree7037ffb1d0364574ee1850c02b7f2a8e76dd5219 /src
parente847edd33ea0acff53b941610a4ddcd17427fe92 (diff)
downloadskyhanni-670e0227c744502087dfd1f6c2aaa015087e3eeb.tar.gz
skyhanni-670e0227c744502087dfd1f6c2aaa015087e3eeb.tar.bz2
skyhanni-670e0227c744502087dfd1f6c2aaa015087e3eeb.zip
Added full TrophyFishQuest and RescueMissionQuest support.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt49
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt2
2 files changed, 45 insertions, 6 deletions
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 58e8235ba..a0fdc5fff 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
@@ -28,13 +28,16 @@ class DailyQuestHelper(private val reputationHelper: CrimsonIsleReputationHelper
private val sacksCache = mutableMapOf<String, Long>()
+ private var latestTrophyFishInInventory = 0
+
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (!HyPixelData.skyBlock) return
if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return
tick++
- if (tick % 3 == 0) {
+ if (tick % 20 == 0) {
loader.checkInventory()
+ checkInventory()
}
if (tick % 60 == 0) {
checkInventoryForFetchItem()
@@ -50,6 +53,30 @@ class DailyQuestHelper(private val reputationHelper: CrimsonIsleReputationHelper
}
}
+ private fun checkInventory() {
+ val fishQuest = getQuest<TrophyFishQuest>() ?: return
+ if (fishQuest.state != QuestState.ACCEPTED && fishQuest.state != QuestState.READY_TO_COLLECT) return
+
+ val fishName = fishQuest.fishName
+ var currentlyInInventory = 0
+ val player = Minecraft.getMinecraft().thePlayer
+ for (stack in player.inventory.mainInventory) {
+ if (stack == null) continue
+ val name = stack.name ?: continue
+ if (name.contains(fishName)) {
+ currentlyInInventory += stack.stackSize
+ }
+ }
+ println("currentlyInInventory: $currentlyInInventory")
+
+ val diff = currentlyInInventory - latestTrophyFishInInventory
+ if (diff < 1) return
+ LorenzUtils.debug("diff: $diff")
+ latestTrophyFishInInventory = currentlyInInventory
+
+ updateProcessQuest(fishQuest, fishQuest.haveAmount + diff)
+ }
+
fun update() {
reputationHelper.update()
}
@@ -121,6 +148,11 @@ class DailyQuestHelper(private val reputationHelper: CrimsonIsleReputationHelper
dojoQuest.state = QuestState.READY_TO_COLLECT
update()
}
+ if (message == "§aYou completed your rescue quest! Visit the Town Board to claim the rewards,") {
+ val rescueMissionQuest = getQuest<RescueMissionQuest>() ?: return
+ rescueMissionQuest.state = QuestState.READY_TO_COLLECT
+ update()
+ }
}
private inline fun <reified T : Quest> getQuest() = quests.filterIsInstance<T>().firstOrNull()
@@ -140,15 +172,22 @@ class DailyQuestHelper(private val reputationHelper: CrimsonIsleReputationHelper
count += stack.stackSize
}
}
+ updateProcessQuest(fetchQuest, count)
+ }
- val needAmount = fetchQuest.needAmount
+ private fun updateProcessQuest(
+ quest: ProgressQuest,
+ newAmount: Int
+ ) {
+ var count = newAmount
+ val needAmount = quest.needAmount
if (count > needAmount) {
count = needAmount
}
- if (fetchQuest.haveAmount == count) return
+ if (quest.haveAmount == count) return
- fetchQuest.haveAmount = count
- fetchQuest.state = if (count == needAmount) QuestState.READY_TO_COLLECT else QuestState.ACCEPTED
+ quest.haveAmount = count
+ quest.state = if (count == needAmount) QuestState.READY_TO_COLLECT else QuestState.ACCEPTED
update()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt
index b7de86eba..3ecd80912 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt
@@ -1,4 +1,4 @@
package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest
-class TrophyFishQuest(fishName: String, state: QuestState, needAmount: Int) :
+class TrophyFishQuest(val fishName: String, state: QuestState, needAmount: Int) :
ProgressQuest(QuestCategory.FISHING, fishName, state, needAmount) \ No newline at end of file