use of delta.games.lotro.lore.quests.io.xml.QuestXMLWriter in project lotro-tools by dmorcellet.
the class QuestsLoader method loadQuestsDefinition.
/**
* Load quest definitions.
* @param key Quest key.
* @return Number of loaded quests.
*/
private int loadQuestsDefinition(String key) {
int nbQuests = 0;
QuestPageParser parser = new QuestPageParser();
String url = urlFromIdentifier(key);
List<QuestDescription> quests = parser.parseQuestPage(url);
if ((quests != null) && (quests.size() > 0)) {
QuestXMLWriter writer = new QuestXMLWriter();
for (QuestDescription quest : quests) {
int id = quest.getIdentifier();
String fileName = String.valueOf(id) + ".xml";
File questFile = new File(_questsDir, fileName);
if (!questFile.getParentFile().exists()) {
questFile.getParentFile().mkdirs();
}
boolean ok = writer.write(questFile, quest, EncodingNames.UTF_8);
if (ok) {
nbQuests++;
} else {
String title = quest.getTitle();
_logger.error("Write failed for quest [" + title + "]!");
}
}
} else {
_logger.error("Cannot parse quests [" + key + "] at URL [" + url + "]!");
}
return nbQuests;
}
use of delta.games.lotro.lore.quests.io.xml.QuestXMLWriter in project lotro-tools by dmorcellet.
the class QuestsItemsLoader method writeQuestsDatabase.
private void writeQuestsDatabase(List<QuestDescription> quests) {
QuestsDatabaseGenerator dbBuilder = new QuestsDatabaseGenerator();
File questsDir = dbBuilder.getQuestsDir();
questsDir.mkdirs();
QuestXMLWriter writer = new QuestXMLWriter();
for (QuestDescription quest : quests) {
int id = quest.getIdentifier();
String fileName = String.valueOf(id) + ".xml";
File questFile = new File(questsDir, fileName);
writer.write(questFile, quest, EncodingNames.UTF_8);
}
dbBuilder.writeDatabase();
}
Aggregations