Skip to content

Commit

Permalink
Untrack Quest after event
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Dec 27, 2024
1 parent 57d6482 commit e7d07f0
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.typewritermc.quest

import com.typewritermc.core.entries.Query
import com.typewritermc.core.entries.Ref
import com.typewritermc.core.entries.priority
import com.typewritermc.core.entries.ref
import com.typewritermc.core.extension.annotations.Factory
import com.typewritermc.core.extension.annotations.Parameter
Expand Down Expand Up @@ -47,7 +48,9 @@ class QuestTracker(
)
}

override fun tick() {}
override fun tick() {
Query.find<QuestEntry>().forEach { refresh(it.ref()) }
}

override fun teardown() {
factWatchSubscription?.cancel(player)
Expand All @@ -63,13 +66,18 @@ class QuestTracker(
if (oldStatus == status) return

if (oldStatus != QuestStatus.ACTIVE && status == QuestStatus.ACTIVE) {
// We always want to track the quest if it becomes active
// Even if the previous quest priority was higher
// Because this is responding to the player's action more accurately
trackQuest(ref)
} else if (trackedQuest == ref) {
unTrackQuest()
}

DISPATCHERS_ASYNC.launch {
AsyncQuestStatusUpdate(player, ref, oldStatus, status).callEvent()

if (trackedQuest == ref && status == QuestStatus.COMPLETED) {
unTrackQuest()
}
}
}

Expand Down

0 comments on commit e7d07f0

Please sign in to comment.