Made Screenshots save as soon as the file is ready to allow compatibility with non-unix file systems
Seriously Windows, why do you have to lock the file?
This commit is contained in:
@@ -5,6 +5,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import eu.crushedpixel.replaymod.registry.FileCopyHandler;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -73,6 +74,8 @@ public class ReplayMod
|
|||||||
|
|
||||||
public static final ApiClient apiClient = new ApiClient();
|
public static final ApiClient apiClient = new ApiClient();
|
||||||
|
|
||||||
|
public static FileCopyHandler fileCopyHandler;
|
||||||
|
|
||||||
// The instance of your mod that Forge uses.
|
// The instance of your mod that Forge uses.
|
||||||
@Instance(value = "ReplayModID")
|
@Instance(value = "ReplayModID")
|
||||||
public static ReplayMod instance;
|
public static ReplayMod instance;
|
||||||
@@ -84,6 +87,9 @@ public class ReplayMod
|
|||||||
|
|
||||||
replaySettings = new ReplaySettings();
|
replaySettings = new ReplaySettings();
|
||||||
replaySettings.readValues();
|
replaySettings.readValues();
|
||||||
|
|
||||||
|
fileCopyHandler = new FileCopyHandler();
|
||||||
|
fileCopyHandler.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -119,7 +125,7 @@ public class ReplayMod
|
|||||||
//clean up replay_recordings folder
|
//clean up replay_recordings folder
|
||||||
removeTmcprFiles();
|
removeTmcprFiles();
|
||||||
|
|
||||||
/*
|
|
||||||
boolean auth = false;
|
boolean auth = false;
|
||||||
try {
|
try {
|
||||||
auth = AuthenticationHandler.hasDonated(Minecraft.getMinecraft().getSession().getPlayerID());
|
auth = AuthenticationHandler.hasDonated(Minecraft.getMinecraft().getSession().getPlayerID());
|
||||||
@@ -132,7 +138,7 @@ public class ReplayMod
|
|||||||
JOptionPane.showMessageDialog(null, "It seems like you didn't donate, so you can't use the Replay Mod yet.");
|
JOptionPane.showMessageDialog(null, "It seems like you didn't donate, so you can't use the Replay Mod yet.");
|
||||||
FMLCommonHandler.instance().exitJava(0, false);
|
FMLCommonHandler.instance().exitJava(0, false);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeTmcprFiles() {
|
private void removeTmcprFiles() {
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ import org.apache.commons.compress.archivers.zip.ZipFile;
|
|||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.file.CopyOption;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -309,16 +312,13 @@ public class ReplayFileIO {
|
|||||||
|
|
||||||
public static void addThumbToZip(File zipFile, File thumb) throws IOException {
|
public static void addThumbToZip(File zipFile, File thumb) throws IOException {
|
||||||
// get a temp file
|
// get a temp file
|
||||||
File tempFile = File.createTempFile(zipFile.getName(), null);
|
File tempFile = File.createTempFile(zipFile.getName(), null, zipFile.getParentFile());
|
||||||
// delete it, otherwise you cannot rename your existing zip to it.
|
// delete it, otherwise you cannot rename your existing zip to it.
|
||||||
tempFile.delete();
|
|
||||||
|
|
||||||
zipFile.renameTo(tempFile);
|
|
||||||
|
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
|
|
||||||
ZipInputStream zin = new ZipInputStream(new FileInputStream(tempFile));
|
ZipInputStream zin = new ZipInputStream(new FileInputStream(zipFile));
|
||||||
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
|
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(tempFile));
|
||||||
|
|
||||||
ZipEntry entry = zin.getNextEntry();
|
ZipEntry entry = zin.getNextEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
@@ -356,6 +356,7 @@ public class ReplayFileIO {
|
|||||||
|
|
||||||
// Complete the ZIP file
|
// Complete the ZIP file
|
||||||
out.close();
|
out.close();
|
||||||
tempFile.delete();
|
|
||||||
|
ReplayMod.fileCopyHandler.registerModifiedFile(tempFile, zipFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user