Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
FileManager: fix load old configs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Aug 29, 2023
1 parent e4dad19 commit f46e3d2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/net/flectone/managers/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ private static void migrate(FYamlConfiguration fileConfiguration) {
YamlConfiguration internalLangConfig = YamlConfiguration.loadConfiguration(defConfigStream);

internalLangConfig.getKeys(true).parallelStream()
.filter(string -> !fileConfiguration.contains(string)
|| (fileConfiguration.get(string) != null
&&!fileConfiguration.get(string).getClass().equals(internalLangConfig.get(string).getClass())))
.filter(string -> {
if (!fileConfiguration.contains(string)) return true;

Object objectA = fileConfiguration.get(string);
Object objectB = internalLangConfig.get(string);

return objectA != null && objectB != null && !objectA.getClass().equals(objectB.getClass());
})
.forEach(string -> fileConfiguration.set(string, internalLangConfig.get(string)));

fileConfiguration.save();
Expand Down

0 comments on commit f46e3d2

Please sign in to comment.