mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-18 18:05:05 +01:00
Slight change on synchronization method. (#2135)
This commit is contained in:
@@ -144,13 +144,15 @@ public class GameMainQuest {
|
|||||||
public void finish() {
|
public void finish() {
|
||||||
// Avoid recursion from child finish() in GameQuest
|
// Avoid recursion from child finish() in GameQuest
|
||||||
// when auto finishing all child quests with QUEST_STATE_UNFINISHED (below)
|
// when auto finishing all child quests with QUEST_STATE_UNFINISHED (below)
|
||||||
if (this.isFinished || this.state == ParentQuestState.PARENT_QUEST_STATE_FINISHED) {
|
synchronized (this) {
|
||||||
Grasscutter.getLogger().debug("Skip main quest finishing because it's already finished");
|
if (this.isFinished || this.state == ParentQuestState.PARENT_QUEST_STATE_FINISHED) {
|
||||||
return;
|
Grasscutter.getLogger().debug("Skip main quest {} finishing because it's already finished",this.getParentQuestId());
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.isFinished = true;
|
this.isFinished = true;
|
||||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We also need to check for unfinished childQuests in this MainQuest
|
* We also need to check for unfinished childQuests in this MainQuest
|
||||||
|
|||||||
@@ -178,14 +178,16 @@ public class GameQuest {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void finish() {
|
public void finish() {
|
||||||
// Check if the quest has been finished.
|
// Check if the quest has been finished.
|
||||||
if (this.state == QuestState.QUEST_STATE_FINISHED) {
|
synchronized (this) {
|
||||||
Grasscutter.getLogger().debug("Quest {} was already finished.", this.getSubQuestId());
|
if (this.state == QuestState.QUEST_STATE_FINISHED) {
|
||||||
return;
|
Grasscutter.getLogger().debug("Quest {} was already finished.", this.getSubQuestId());
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.state = QuestState.QUEST_STATE_FINISHED;
|
this.state = QuestState.QUEST_STATE_FINISHED;
|
||||||
|
}
|
||||||
this.finishTime = Utils.getCurrentSeconds();
|
this.finishTime = Utils.getCurrentSeconds();
|
||||||
|
|
||||||
this.getOwner().sendPacket(new PacketQuestListUpdateNotify(this));
|
this.getOwner().sendPacket(new PacketQuestListUpdateNotify(this));
|
||||||
|
|||||||
Reference in New Issue
Block a user