Fix all warnings
Add and make use of Lombok Remove Mojang API Remove ZipFileUtils Remove StreamTools in favor of Apache IOUtils Keyframe should be abstract all derivatives final Replace clone in Keyframe with copy Move some constants from GuiReplaySetttings to GuiConstants
This commit is contained in:
@@ -3,9 +3,11 @@ package eu.crushedpixel.replaymod.registry;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DownloadedFileHandler {
|
||||
@@ -16,18 +18,19 @@ public class DownloadedFileHandler {
|
||||
|
||||
public DownloadedFileHandler() {
|
||||
downloadFolder = new File(ReplayMod.replaySettings.getDownloadPath());
|
||||
downloadFolder.mkdirs();
|
||||
try {
|
||||
FileUtils.forceMkdir(downloadFolder);
|
||||
|
||||
for(File f : downloadFolder.listFiles()) {
|
||||
if(!FilenameUtils.getExtension(f.getAbsolutePath()).equals("mcpr")) continue;
|
||||
try {
|
||||
Integer i = Integer.valueOf(FilenameUtils.getBaseName(f.getAbsolutePath()));
|
||||
if(i != null) {
|
||||
downloadedFiles.put(i, f);
|
||||
for(File f : FileUtils.listFiles(downloadFolder, new String[]{"mcpr"}, false)) {
|
||||
try {
|
||||
int id = Integer.parseInt(FilenameUtils.getBaseName(f.getAbsolutePath()));
|
||||
downloadedFiles.put(id, f);
|
||||
} catch(NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ public class PlayerHandler {
|
||||
private static Predicate<EntityPlayer> playerPredicate = new Predicate<EntityPlayer>() {
|
||||
@Override
|
||||
public boolean apply(EntityPlayer input) {
|
||||
if(input instanceof CameraEntity || input == mc.thePlayer) return false;
|
||||
return true;
|
||||
return !(input instanceof CameraEntity || input == mc.thePlayer);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,7 +41,7 @@ public class PlayerHandler {
|
||||
resetHiddenPlayers();
|
||||
if(visibility != null) {
|
||||
GuiPlayerOverview.defaultSave = true;
|
||||
Collections.addAll(hidden, visibility.getHiddenPlayers());
|
||||
Collections.addAll(hidden, visibility.getHidden());
|
||||
} else {
|
||||
GuiPlayerOverview.defaultSave = false;
|
||||
}
|
||||
@@ -65,6 +64,7 @@ public class PlayerHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityPlayer> players = mc.theWorld.getEntities(EntityPlayer.class, playerPredicate);
|
||||
mc.displayGuiScreen(new GuiPlayerOverview(players));
|
||||
}
|
||||
|
||||
@@ -19,10 +19,6 @@ public class RatedFileHandler {
|
||||
reloadRatings();
|
||||
}
|
||||
|
||||
public HashMap<Integer, Boolean> getRated() {
|
||||
return rated;
|
||||
}
|
||||
|
||||
public Rating.RatingType getRating(int id) {
|
||||
return Rating.RatingType.fromBoolean(rated.get(id));
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import eu.crushedpixel.replaymod.gui.GuiReplaySaving;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
@@ -17,7 +19,6 @@ public class ReplayFileAppender extends Thread {
|
||||
private Multimap<File, Pair<File, String>> filesToMove = ArrayListMultimap.create();
|
||||
private Queue<File> filesToRewrite = new ConcurrentLinkedQueue<File>();
|
||||
|
||||
private boolean shutdown = false;
|
||||
private List<GuiReplaySaving> listeners = new ArrayList<GuiReplaySaving>();
|
||||
|
||||
//this is true if the DataListener is currently busy saving a newly recorded Replay File
|
||||
@@ -53,11 +54,9 @@ public class ReplayFileAppender extends Thread {
|
||||
|
||||
public void registerModifiedFile(File toAdd, String name, File replayFile) {
|
||||
//first, remove any files with the same name assigned to this Replay File
|
||||
if(filesToMove.get(replayFile) != null) {
|
||||
for(Pair<File, String> p : new ArrayList<Pair<File, String>>((Collection<Pair<File, String>>)filesToMove.get(replayFile))) {
|
||||
if(p.getRight().equals(name)) {
|
||||
filesToMove.remove(replayFile, p);
|
||||
}
|
||||
for (Iterator<Pair<File, String>> iter = filesToMove.get(replayFile).iterator(); iter.hasNext(); ) {
|
||||
if (iter.next().getRight().equals(name)) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +70,7 @@ public class ReplayFileAppender extends Thread {
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
shutdown = true;
|
||||
interrupt();
|
||||
}
|
||||
|
||||
public void addFinishListener(GuiReplaySaving gui) {
|
||||
@@ -80,7 +79,7 @@ public class ReplayFileAppender extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while(!shutdown || !filesToRewrite.isEmpty()) {
|
||||
while(!Thread.interrupted() || !filesToRewrite.isEmpty()) {
|
||||
File replayFile = filesToRewrite.poll();
|
||||
if(replayFile != null) {
|
||||
if(replayFile.canWrite()) {
|
||||
@@ -96,7 +95,11 @@ public class ReplayFileAppender extends Thread {
|
||||
//delete all written files
|
||||
for(Pair<File, String> p : filesToMove.get(replayFile)) {
|
||||
if(p.getLeft() != null) {
|
||||
p.getLeft().delete();
|
||||
try {
|
||||
FileUtils.forceDelete(p.getLeft());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +117,9 @@ public class ReplayFileAppender extends Thread {
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch(Exception e) {}
|
||||
} catch (InterruptedException e) {
|
||||
interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class UploadedFileHandler {
|
||||
public UploadedFileHandler(File confDir) {
|
||||
try {
|
||||
File confFile = new File(confDir, "uploaded");
|
||||
confFile.createNewFile();
|
||||
FileUtils.touch(confFile);
|
||||
configuration = new Configuration(confFile);
|
||||
configuration.load();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user