use of net.pravian.aero.config.YamlConfig in project TotalFreedomMod by TotalFreedom.
the class ConfigConverter method convertSuperadmins.
private void convertSuperadmins(File oldFile) {
if (!oldFile.exists() || !oldFile.isFile()) {
logger.warning("No old superadmin list found!");
return;
}
// Convert old admin list
YamlConfig oldYaml = new YamlConfig(plugin, oldFile, false);
oldYaml.load();
ConfigurationSection admins = oldYaml.getConfigurationSection("admins");
if (admins == null) {
logger.warning("No admin section in superadmin list!");
return;
}
List<Admin> conversions = Lists.newArrayList();
for (String uuid : admins.getKeys(false)) {
ConfigurationSection asec = admins.getConfigurationSection(uuid);
if (asec == null) {
logger.warning("Invalid superadmin format for admin: " + uuid);
continue;
}
String username = asec.getString("last_login_name");
Rank rank;
if (asec.getBoolean("is_senior_admin")) {
rank = Rank.SENIOR_ADMIN;
} else if (asec.getBoolean("is_telnet_admin")) {
rank = Rank.TELNET_ADMIN;
} else {
rank = Rank.SUPER_ADMIN;
}
List<String> ips = asec.getStringList("ips");
String loginMessage = asec.getString("custom_login_message");
boolean active = asec.getBoolean("is_activated");
Admin admin = new Admin(username);
admin.setName(username);
admin.setRank(rank);
admin.addIps(ips);
admin.setLoginMessage(loginMessage);
admin.setActive(active);
admin.setLastLogin(new Date());
conversions.add(admin);
}
YamlConfig newYaml = new YamlConfig(plugin, AdminList.CONFIG_FILENAME);
for (Admin admin : conversions) {
admin.saveTo(newYaml.createSection(admin.getName().toLowerCase()));
}
newYaml.save();
logger.info("Converted " + conversions.size() + " admins");
}
use of net.pravian.aero.config.YamlConfig in project TotalFreedomMod by TotalFreedom.
the class BackupManager method createBackups.
public void createBackups(String file, boolean onlyWeekly) {
final String save = file.split("\\.")[0];
final YamlConfig config = new YamlConfig(plugin, "backup/backup.yml", false);
config.load();
// Weekly
if (!config.isInt(save + ".weekly")) {
performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime());
} else {
int lastBackupWeekly = config.getInt(save + ".weekly");
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime()) {
performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime());
}
}
if (onlyWeekly) {
config.save();
return;
}
// Daily
if (!config.isInt(save + ".daily")) {
performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime());
} else {
int lastBackupDaily = config.getInt(save + ".daily");
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime()) {
performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime());
}
}
config.save();
}
Aggregations