Skip to content

Commit

Permalink
Change backup system
Browse files Browse the repository at this point in the history
  • Loading branch information
MertUnverdi authored Oct 12, 2023
1 parent 88d31e7 commit e78fddc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugin/src/main/java/com/iridium/iridiumcore/Persist.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ public <T> T load(Class<T> clazz, File file) {
return objectMapper.readValue(file, clazz);
} catch (IOException e) {
javaPlugin.getLogger().severe("Failed to parse " + file + ": " + e.getMessage());
file.delete();
load(clazz, file);
javaPlugin.getLogger().severe("Getting a backup for " + file + " into backups folder");
configFile.renameTo(new File(javaPlugin.getDataFolder(), "broken_" + name + persistType.getExtension()));
File backupFolder = new File(pluginFolder.getPath(), "backups");
backupFolder.mkdirs();
Files.move(configFile.toPath(), backupFolder.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}
try {
Expand Down

0 comments on commit e78fddc

Please sign in to comment.