Skip to content

Commit

Permalink
Updated Persist class to avoid stack overflow
Browse files Browse the repository at this point in the history
this issue happened when there was a config option that did not exist in the plugin, as we were simply reloading the config instead of clearing it and reading from default values

- removed renaming the file because we're already backing it up
- moved success message to try/catch to indicate success
  • Loading branch information
sh0inx committed Jun 14, 2024
1 parent a609357 commit 2271d09
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions plugin/src/main/java/com/iridium/iridiumcore/Persist.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ public <T> T load(Class<T> clazz, File file) {
try {
if (!backupFolder.exists()) backupFolder.mkdir();
Files.copy(file.toPath(), backupConfigFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
file.renameTo(new File(javaPlugin.getDataFolder(), file.getName() + "_BROKEN"));

Files.delete(file.toPath());
javaPlugin.getLogger().info("Success! Backup \"" + file.getName() + "\" created, check \"" + backupFolder.getPath() + "\".");
} catch (IOException exception) {
javaPlugin.getLogger().severe(
"Failed to move " + file + " to "
Expand All @@ -205,10 +205,7 @@ public <T> T load(Class<T> clazz, File file) {
+ exception.getMessage());
Bukkit.getPluginManager().disablePlugin(javaPlugin);
}

javaPlugin.getLogger().info("Success! Backup \"" + file.getName() + "\" created, check \"" + backupFolder.getPath() + "\".");
load(clazz, file);

}
}

Expand Down

0 comments on commit 2271d09

Please sign in to comment.