Fix optionsToLoad being changed when overwriting profile

This commit is contained in:
axolotlmaid 2024-07-14 02:07:34 +01:00
parent 4d05bb4958
commit 1526cb9694

View file

@ -121,18 +121,20 @@ public class Profiles {
copyOptionFile(profile, EMBEDDIUM_OPTIONS_FILE);
copyOptionFile(profile, DISTANT_HORIZONS_OPTIONS_FILE);
// Add every option value to configuration
try (Stream<String> lines = Files.lines(profileOptions)) {
List<String> optionsToLoad = profileConfiguration.getOptionsToLoad();
if (!overwriting) {
// Add every option value to configuration
try (Stream<String> lines = Files.lines(profileOptions)) {
List<String> optionsToLoad = profileConfiguration.getOptionsToLoad();
lines.forEach((line) -> {
String[] option = line.split(":");
optionsToLoad.add(option[0]);
});
lines.forEach((line) -> {
String[] option = line.split(":");
optionsToLoad.add(option[0]);
});
profileConfiguration.save();
} catch (IOException e) {
OptionsProfilesMod.LOGGER.error("[Profile '{}']: An error occurred when adding options to the configuration file", profileName, e);
profileConfiguration.save();
} catch (IOException e) {
OptionsProfilesMod.LOGGER.error("[Profile '{}']: An error occurred when adding options to the configuration file", profileName, e);
}
}
}