Skip to content

Commit b0b19f3

Browse files
committed
fix: little mistakes in Modrinth app compat
1 parent 382d422 commit b0b19f3

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

common/src/main/java/io/github/thebossmagnus/mods/config_manager/common_coremod/CopyConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static void init(Path gameDir) {
3030
int fullscreenSetting = ModrinthAppCompat.getFullScreenSetting(gameDir);
3131
if (fullscreenSetting != -1) {
3232
try {
33-
Files.deleteIfExists(configDir.resolve("options.txt"));
33+
Files.deleteIfExists(gameDir.resolve("options.txt"));
3434
} catch (IOException e) {
3535
throw new RuntimeException(e);
3636
}

common/src/main/java/io/github/thebossmagnus/mods/config_manager/common_coremod/compat/ModrinthAppCompat.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.nio.file.Files;
66
import java.nio.file.Path;
7+
import java.nio.file.StandardOpenOption;
78

89
import static io.github.thebossmagnus.mods.config_manager.common.Constants.LOGGER;
910

@@ -51,6 +52,9 @@ public static void reapplyFullScreenSetting(@NotNull Path gameDir, int status) {
5152
boolean replaced = false;
5253
for (int i = 0; i < lines.size(); i++) {
5354
if (lines.get(i).startsWith("fullscreen:")) {
55+
if (!lines.get(i).equals(fullscreenSetting)) {
56+
LOGGER.warn("Overriding modpack fullscreen preference ({}) with launcher preference ({})", lines.get(i), fullscreenSetting);
57+
}
5458
lines.set(i, fullscreenSetting);
5559
replaced = true;
5660
break;
@@ -59,11 +63,9 @@ public static void reapplyFullScreenSetting(@NotNull Path gameDir, int status) {
5963
if (!replaced) {
6064
lines.add(fullscreenSetting);
6165
}
62-
Path tmp = Files.createTempFile(gameDir, "options", ".tmp");
63-
Files.write(tmp, lines);
64-
java.nio.file.Files.move(tmp, optionsFile, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
66+
Files.write(optionsFile, lines, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
6567
} catch (Exception e) {
66-
throw new RuntimeException("Could not reapply fullscreen preference chosen by the launcher", e);
68+
LOGGER.error("Could not reapply fullscreen preference chosen by the launcher", e);
6769
}
6870
}
6971
}

0 commit comments

Comments
 (0)