Split replay folder and file management into their own classes

This commit is contained in:
Jonas Herzig
2021-11-28 14:50:39 +01:00
parent ce5886a427
commit 31817bcf11
12 changed files with 245 additions and 204 deletions

View File

@@ -154,7 +154,7 @@ public class GuiSavingReplay {
}
try {
Path replaysFolder = core.getReplayFolder();
Path replaysFolder = core.folders.getReplayFolder();
Path newPath = replaysFolder.resolve(Utils.replayNameToFileName(newName));
for (int i = 1; Files.exists(newPath); i++) {
newPath = replaysFolder.resolve(Utils.replayNameToFileName(newName + " (" + i + ")"));

View File

@@ -127,8 +127,8 @@ public class ConnectionEventHandler {
}
String name = sdf.format(Calendar.getInstance().getTime());
Path outputPath = core.getRecordingFolder().resolve(Utils.replayNameToFileName(name));
ReplayFile replayFile = core.openReplay(outputPath);
Path outputPath = core.folders.getRecordingFolder().resolve(Utils.replayNameToFileName(name));
ReplayFile replayFile = core.files.open(outputPath);
replayFile.writeModInfo(ModCompat.getInstalledNetworkMods());

View File

@@ -280,7 +280,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
// We still have the replay, so we just save it (at least for a few weeks) in case they change their mind
String replayName = FilenameUtils.getBaseName(outputPath.getFileName().toString());
Path rawFolder = ReplayMod.instance.getRawReplayFolder();
Path rawFolder = ReplayMod.instance.folders.getRawReplayFolder();
Path rawPath = rawFolder.resolve(outputPath.getFileName());
for (int i = 1; Files.exists(rawPath); i++) {
rawPath = rawPath.resolveSibling(replayName + "." + i + ".mcpr");