Skip to content

Commit

Permalink
fix: don't do Quest#onCompleted work twice
Browse files Browse the repository at this point in the history
Can happen if a quest has multiple optional tasks where completing one
task completes the quest.

FTBTeam/FTB-Mods-Issues#1390
  • Loading branch information
desht committed Jan 27, 2025
1 parent 1fd108d commit 663ad97
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions common/src/main/java/dev/ftb/mods/ftbquests/quest/Quest.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,23 @@ public void onStarted(QuestProgressEventData<?> data) {

@Override
public void onCompleted(QuestProgressEventData<?> data) {
data.setCompleted(id);
ObjectCompletedEvent.QUEST.invoker().act(new ObjectCompletedEvent.QuestEvent(data.withObject(this)));
if (!data.getTeamData().isCompleted(this)) {
// it's possible this quest is already completed, if it has one or more optional tasks
data.setCompleted(id);
ObjectCompletedEvent.QUEST.invoker().act(new ObjectCompletedEvent.QuestEvent(data.withObject(this)));

if (!disableToast) {
data.notifyPlayers(id);
}
if (!disableToast) {
data.notifyPlayers(id);
}

if (chapter.isCompletedRaw(data.getTeamData())) {
chapter.onCompleted(data.withObject(chapter));
}
if (chapter.isCompletedRaw(data.getTeamData())) {
chapter.onCompleted(data.withObject(chapter));
}

data.getTeamData().checkAutoCompletion(this);
data.getTeamData().checkAutoCompletion(this);

checkForDependantCompletion(data.getTeamData());
checkForDependantCompletion(data.getTeamData());
}
}

private void checkForDependantCompletion(TeamData data) {
Expand Down

0 comments on commit 663ad97

Please sign in to comment.