Keep original quest ID after editing, fixes #1070

This commit is contained in:
PikaMug 2020-02-13 04:51:24 -05:00
parent f5ac927641
commit feb6fd1527

View File

@ -1396,15 +1396,23 @@ public class QuestFactory implements ConversationAbandonedListener {
if (questSection == null) { if (questSection == null) {
questSection = data.createSection("quests"); questSection = data.createSection("quests");
} }
int customNum = 1; System.out.println("id= " + context.getSessionData(CK.Q_ID));
while (true) { ConfigurationSection newSection;
if (questSection.contains("custom" + customNum)) { if (context.getSessionData(CK.Q_ID) == null) {
customNum++; // Creating
} else { int customNum = 1;
break; while (true) {
if (questSection.contains("custom" + customNum)) {
customNum++;
} else {
break;
}
} }
newSection = questSection.createSection("custom" + customNum);
} else {
// Editing
newSection = questSection.createSection((String)context.getSessionData(CK.Q_ID));
} }
ConfigurationSection newSection = questSection.createSection("custom" + customNum);
saveQuest(context, newSection); saveQuest(context, newSection);
data.save(new File(plugin.getDataFolder(), "quests.yml")); data.save(new File(plugin.getDataFolder(), "quests.yml"));
context.getForWhom().sendRawMessage(ChatColor.GREEN context.getForWhom().sendRawMessage(ChatColor.GREEN