use of net.pravian.aero.config.YamlConfig in project TotalFreedomMod by TotalFreedom.
the class PlayerList method getData.
// May not return null
public PlayerData getData(Player player) {
// Check already loaded
PlayerData data = dataMap.get(Ips.getIp(player));
if (data != null) {
return data;
}
// Load data
data = getData(player.getName());
// Create data if nonexistent
if (data == null) {
FLog.info("Creating new player data entry for " + player.getName());
// Create new player
final long unix = FUtil.getUnixTime();
data = new PlayerData(player);
data.setFirstJoinUnix(unix);
data.setLastJoinUnix(unix);
data.addIp(Ips.getIp(player));
// Store player
dataMap.put(player.getName().toLowerCase(), data);
// Save player
YamlConfig config = getConfig(data);
data.saveTo(config);
config.save();
}
return data;
}
use of net.pravian.aero.config.YamlConfig in project TotalFreedomMod by TotalFreedom.
the class PlayerList method getConfig.
protected YamlConfig getConfig(PlayerData data) {
final YamlConfig config = new YamlConfig(plugin, getConfigFile(data.getUsername().toLowerCase()), false);
config.load();
return config;
}
use of net.pravian.aero.config.YamlConfig in project TotalFreedomMod by TotalFreedom.
the class PlayerList method save.
public void save() {
for (PlayerData data : dataMap.values()) {
YamlConfig config = getConfig(data);
data.saveTo(config);
config.save();
}
}
use of net.pravian.aero.config.YamlConfig in project TotalFreedomMod by TotalFreedom.
the class PermbanList method onStart.
@Override
protected void onStart() {
permbannedNames.clear();
permbannedIps.clear();
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
config.load();
for (String name : config.getKeys(false)) {
permbannedNames.add(name.toLowerCase().trim());
permbannedIps.addAll(config.getStringList(name));
}
FLog.info("Loaded " + permbannedIps.size() + " perm IP bans and " + permbannedNames.size() + " perm username bans.");
}
use of net.pravian.aero.config.YamlConfig in project TotalFreedomMod by TotalFreedom.
the class ConfigConverter method convert.
public void convert() {
File data = plugin.getDataFolder();
data.mkdirs();
File versionFile = new File(data, "version.yml");
boolean convert = false;
if (!versionFile.exists() && data.listFiles().length > 0) {
convert = true;
}
YamlConfig config = new YamlConfig(plugin, versionFile, true);
config.load();
if (config.getInt("version", -1) < CURRENT_CONFIG_VERSION) {
convert = true;
}
if (!convert) {
return;
}
logger.warning("Converting old configs to new format...");
File backup = new File(data, "backup_old_format");
backup.mkdirs();
for (File file : data.listFiles()) {
if (file.equals(backup) || file.equals(versionFile)) {
continue;
}
try {
Files.move(file, new File(backup, file.getName()));
} catch (IOException ex) {
logger.severe("Could not backup file: " + file.getName());
logger.severe(ex);
}
}
convertSuperadmins(new File(backup, "superadmin.yml"));
convertPermbans(new File(backup, "permban.yml"));
logger.info("Conversion complete!");
}
Aggregations