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