private void saveYml() throws IOException {
File saveFolder = new File(dataFolder, "Save");
File worldFolder = new File(saveFolder, "Worlds");
worldFolder.mkdirs();
YMLSaveHelper yml;
Map<String, Object> save = rmanager.save();
for (Entry<String, Object> entry : save.entrySet()) {
File ymlSaveLoc = new File(worldFolder, "res_" + entry.getKey() + ".yml");
File tmpFile = new File(worldFolder, "tmp_res_" + entry.getKey() + ".yml");
yml = new YMLSaveHelper(tmpFile);
yml.getRoot().put("Version", saveVersion);
World world = server.getWorld(entry.getKey());
if (world != null)
yml.getRoot().put("Seed", world.getSeed());
yml.getRoot().put("Residences", (Map) entry.getValue());
yml.save();
if (ymlSaveLoc.isFile()) {
File backupFolder = new File(worldFolder, "Backup");
backupFolder.mkdirs();
File backupFile = new File(backupFolder, "res_" + entry.getKey() + ".yml");
if (backupFile.isFile()) {
backupFile.delete();
}
ymlSaveLoc.renameTo(backupFile);
}
tmpFile.renameTo(ymlSaveLoc);
}
// For Sale save
File ymlSaveLoc = new File(saveFolder, "forsale.yml");
File tmpFile = new File(saveFolder, "tmp_forsale.yml");
yml = new YMLSaveHelper(tmpFile);
yml.save();
yml.getRoot().put("Version", saveVersion);
yml.getRoot().put("Economy", tmanager.save());
yml.save();
if (ymlSaveLoc.isFile()) {
File backupFolder = new File(saveFolder, "Backup");
backupFolder.mkdirs();
File backupFile = new File(backupFolder, "forsale.yml");
if (backupFile.isFile()) {
backupFile.delete();
}
ymlSaveLoc.renameTo(backupFile);
}
tmpFile.renameTo(ymlSaveLoc);
// Leases save
ymlSaveLoc = new File(saveFolder, "leases.yml");
tmpFile = new File(saveFolder, "tmp_leases.yml");
yml = new YMLSaveHelper(tmpFile);
yml.getRoot().put("Version", saveVersion);
yml.getRoot().put("Leases", leasemanager.save());
yml.save();
if (ymlSaveLoc.isFile()) {
File backupFolder = new File(saveFolder, "Backup");
backupFolder.mkdirs();
File backupFile = new File(backupFolder, "leases.yml");
if (backupFile.isFile()) {
backupFile.delete();
}
ymlSaveLoc.renameTo(backupFile);
}
tmpFile.renameTo(ymlSaveLoc);
// permlist save
ymlSaveLoc = new File(saveFolder, "permlists.yml");
tmpFile = new File(saveFolder, "tmp_permlists.yml");
yml = new YMLSaveHelper(tmpFile);
yml.getRoot().put("Version", saveVersion);
yml.getRoot().put("PermissionLists", pmanager.save());
yml.save();
if (ymlSaveLoc.isFile()) {
File backupFolder = new File(saveFolder, "Backup");
backupFolder.mkdirs();
File backupFile = new File(backupFolder, "permlists.yml");
if (backupFile.isFile()) {
backupFile.delete();
}
ymlSaveLoc.renameTo(backupFile);
}
tmpFile.renameTo(ymlSaveLoc);
// rent save
ymlSaveLoc = new File(saveFolder, "rent.yml");
tmpFile = new File(saveFolder, "tmp_rent.yml");
yml = new YMLSaveHelper(tmpFile);
yml.getRoot().put("Version", saveVersion);
yml.getRoot().put("RentSystem", rentmanager.save());
yml.save();
if (ymlSaveLoc.isFile()) {
File backupFolder = new File(saveFolder, "Backup");
backupFolder.mkdirs();
File backupFile = new File(backupFolder, "rent.yml");
if (backupFile.isFile()) {