}
// Persistence-related methods
private YAMLProcessor getUserConfiguration(String type, String commander, boolean create) {
Map<String, YAMLProcessor> typeMap = getDataStore(type);
YAMLProcessor processor = typeMap.get(commander);
if (processor == null) {
File userFile = new File(sessionsDir.getPath() + File.separator + type + File.separator + commander + ".yml");
if (!userFile.exists()) {
File dir = userFile.getParentFile();
if (!dir.exists()) {
dir.mkdirs();
}
if (!migrate(commander, userFile)) {
if (!create) {
return null;
}
try {
userFile.createNewFile();
} catch (IOException e) {
CommandBook.logger().log(Level.WARNING, "Could not create sessions persistence file for user " + commander, e);
}
}
}
processor = new YAMLProcessor(userFile, false, YAMLFormat.COMPACT);
try {
processor.load();
} catch (IOException e) {
CommandBook.logger().log(Level.WARNING, "Error loading sessions persistence file for user " + commander, e);
}
typeMap.put(commander, processor);
}