mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-09 06:18:20 +08:00
Delete quests from the player if there are errors loading them from the db
This commit is contained in:
parent
c53697da82
commit
1e649cd804
@ -346,6 +346,10 @@ public class GameMainQuest {
|
|||||||
public void save() {
|
public void save() {
|
||||||
DatabaseHelper.saveQuest(this);
|
DatabaseHelper.saveQuest(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
DatabaseHelper.deleteQuest(this);
|
||||||
|
}
|
||||||
|
|
||||||
public ParentQuest toProto() {
|
public ParentQuest toProto() {
|
||||||
ParentQuest.Builder proto = ParentQuest.newBuilder()
|
ParentQuest.Builder proto = ParentQuest.newBuilder()
|
||||||
|
@ -181,6 +181,7 @@ public class GameQuest {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
getMainQuest().save();
|
getMainQuest().save();
|
||||||
}
|
}
|
||||||
|
@ -313,16 +313,27 @@ public class QuestManager extends BasePlayerManager {
|
|||||||
}
|
}
|
||||||
public void loadFromDatabase() {
|
public void loadFromDatabase() {
|
||||||
List<GameMainQuest> quests = DatabaseHelper.getAllQuests(getPlayer());
|
List<GameMainQuest> quests = DatabaseHelper.getAllQuests(getPlayer());
|
||||||
|
|
||||||
for (GameMainQuest mainQuest : quests) {
|
for (GameMainQuest mainQuest : quests) {
|
||||||
|
boolean cancelAdd = false;
|
||||||
mainQuest.setOwner(this.getPlayer());
|
mainQuest.setOwner(this.getPlayer());
|
||||||
|
|
||||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||||
|
QuestData questConfig = GameData.getQuestDataMap().get(quest.getSubQuestId());
|
||||||
|
|
||||||
|
if (questConfig == null) {
|
||||||
|
mainQuest.delete();
|
||||||
|
cancelAdd = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
quest.setMainQuest(mainQuest);
|
quest.setMainQuest(mainQuest);
|
||||||
quest.setConfig(GameData.getQuestDataMap().get(quest.getSubQuestId()));
|
quest.setConfig(questConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
if (!cancelAdd) {
|
||||||
|
this.getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user