Skip to content

Commit

Permalink
Update HotJoin.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Jab125 committed Oct 18, 2024
1 parent 60ff106 commit ca739a8
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/main/java/dev/jab125/hotjoin/HotJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.client.server.IntegratedServer;
import org.apache.commons.io.file.PathUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -425,6 +426,29 @@ public static UUID launchMinecraftClient(String compat, String magic, String leg

// Transfer stuff into this folder
private static void transfer(Path second) {
PathTransfer pathTransfer = getPathTransfer(second);
try {
Minecraft.getInstance().options.save();
Assort.save();
pathTransfer.copyFile(Path.of("resource_assorts.json"));
pathTransfer.clearDirectoryRecursive(Path.of("resource_assorts"));
pathTransfer.copyFolderRecursive(Path.of("resource_assorts"));
pathTransfer.clearDirectoryRecursive(Path.of("resourcepacks"));
pathTransfer.copyFolderRecursive(Path.of("resourcepacks"));

pathTransfer.clearDirectoryRecursive(Path.of("config"));
pathTransfer.copyFolderRecursive(Path.of("config"));

pathTransfer.clearDirectoryRecursive(Path.of("shaderpacks"));
pathTransfer.copyFolderRecursive(Path.of("shaderpacks"));

pathTransfer.copyFile(Path.of("options.txt"));
} catch (Throwable t) {

}
}

private static @NotNull PathTransfer getPathTransfer(Path second) {
Path gameDir = FabricLoader.getInstance().getGameDir();
PathTransfer pathTransfer = new PathTransfer() {

Expand All @@ -450,25 +474,7 @@ public void copyFolderRecursive(Path path) throws IOException {
PathUtils.copyDirectory(original, resolve);
}
};
try {
Minecraft.getInstance().options.save();
Assort.save();
pathTransfer.copyFile(Path.of("resource_assorts.json"));
pathTransfer.clearDirectoryRecursive(Path.of("resource_assorts"));
pathTransfer.copyFolderRecursive(Path.of("resource_assorts"));
pathTransfer.clearDirectoryRecursive(Path.of("resourcepacks"));
pathTransfer.copyFolderRecursive(Path.of("resourcepacks"));

pathTransfer.clearDirectoryRecursive(Path.of("config"));
pathTransfer.copyFolderRecursive(Path.of("config"));

pathTransfer.clearDirectoryRecursive(Path.of("shaderpacks"));
pathTransfer.copyFolderRecursive(Path.of("shaderpacks"));

pathTransfer.copyFile(Path.of("options.txt"));
} catch (Throwable t) {

}
return pathTransfer;
}

interface PathTransfer {
Expand Down

0 comments on commit ca739a8

Please sign in to comment.