Fix an issue where config.yml was now being overwritten...
This commit is contained in:
parent
e6f2e2c25a
commit
8416fafa45
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>eu.mathiasl</groupId>
|
||||
<artifactId>LegacyChatFix</artifactId>
|
||||
<version>0.5-SNAPSHOT</version>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>LegacyChatFix</name>
|
||||
|
|
|
@ -70,30 +70,5 @@ public class ConfigManager {
|
|||
plugin.saveResource(configName, false);
|
||||
return;
|
||||
}
|
||||
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
String configVersion = config.getString("ConfigVersion", "0"); // Default to "0" if not found
|
||||
if (!"1.0".equals(configVersion)) {
|
||||
backupAndReplaceConfig(configName);
|
||||
|
||||
// After backing up and copying new ones, you might want to reload these configs into your ConfigManager
|
||||
// assuming you have such a method in your ConfigManager
|
||||
reloadConfig(configName);
|
||||
}
|
||||
}
|
||||
|
||||
private void backupAndReplaceConfig(String fileName) {
|
||||
File configFile = new File(plugin.getDataFolder(), fileName);
|
||||
File backupFile = new File(plugin.getDataFolder(), fileName + ".BACKUP");
|
||||
|
||||
// Backup the old file
|
||||
try {
|
||||
Files.move(configFile.toPath(), backupFile.toPath());
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Could not backup " + fileName + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
// Copy new file from resources
|
||||
plugin.saveResource(fileName, false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue