Skip to content

Commit d1692a6

Browse files
ScribbleScribble
authored andcommitted
Started working on #112
Too tired to continue... -Moved FileThread.class to util package
1 parent 1b020f8 commit d1692a6

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dependencies {
6868
compile 'org.msgpack:msgpack-core:0.8.16'
6969
compile 'org.msgpack:jackson-dataformat-msgpack:0.8.16'
7070
compile files('libs/KillTheRNG-1.12.2-1.0-deobf.jar')
71+
//compile files('libs/BigArrayList-1.3.jar')
7172
compile 'com.dselent:bigarraylist:1.0'
7273
// real examples
7374
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env

src/main/java/de/scribble/lp/tasmod/savestates/server/SavestateHandler.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.scribble.lp.tasmod.savestates.server;
22

33
import java.io.File;
4+
import java.io.FileFilter;
45
import java.io.IOException;
56

67
import org.apache.commons.io.FileUtils;
@@ -46,10 +47,11 @@ public class SavestateHandler {
4647
* Called in {@link SavestatePacketHandler}<br>
4748
* <br>
4849
* Side: Server
50+
* @param savestateIndex The index where the mod will save the savestate -1 if it should load the latest
4951
* @throws SavestateException
5052
* @throws IOException
5153
*/
52-
public static void saveState() throws SavestateException, IOException {
54+
public static void saveState(int savestateIndex) throws SavestateException, IOException {
5355
if(state==SavestateState.SAVING) {
5456
throw new SavestateException("A savestating operation is already being carried out");
5557
}
@@ -107,13 +109,28 @@ public static void saveState() throws SavestateException, IOException {
107109
state=SavestateState.NONE;
108110
}
109111

112+
private static String nextSaveName(String worldname, int index) {
113+
File[] listofFiles=savestateDirectory.listFiles(new FileFilter() {
114+
115+
@Override
116+
public boolean accept(File pathname) {
117+
return pathname.getName().startsWith(worldname);
118+
}
119+
120+
});
121+
if(index<0) {
122+
}
123+
return "";
124+
}
125+
110126
/**
111127
* Searches through the savestate folder to look for the next possible savestate foldername <br>
112128
* Savestate equivalent to {@link SavestateHandler#getLatestSavestateLocation(String)}
113129
* @param worldname The worldname of the current world
114130
* @return targetsavefolder The file where the savestate should be copied to
115131
* @throws SavestateException if the found savestates count is greater or equal than 300
116132
*/
133+
@Deprecated
117134
private static File getNextSaveFolderLocation(String worldname) throws SavestateException {
118135
int i = 1;
119136
int limit=300;
@@ -138,6 +155,7 @@ private static File getNextSaveFolderLocation(String worldname) throws Savestate
138155
* @param worldname the name of the world currently on the server
139156
* @return The correct name of the next savestate
140157
*/
158+
@Deprecated
141159
private static String nameWhenSaving(String worldname) {
142160
int i = 1;
143161
int limit=300;

src/main/java/de/scribble/lp/tasmod/savestates/server/SavestatePacketHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public IMessage onMessage(SavestatePacket message, MessageContext ctx) {
3030
return;
3131
}
3232
try {
33-
SavestateHandler.saveState();
33+
SavestateHandler.saveState(-1);
3434
} catch (SavestateException e) {
3535
player.sendMessage(new TextComponentString(TextFormatting.RED+"Failed to create a savestate: "+ e.getMessage()));
3636

src/main/java/de/scribble/lp/tasmod/util/ContainerSerialiser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import com.dselent.bigarraylist.BigArrayList;
1313

14-
import de.scribble.lp.tasmod.commands.savetas.FileThread;
1514
import de.scribble.lp.tasmod.inputcontainer.InputContainer;
1615
import de.scribble.lp.tasmod.inputcontainer.TickInputContainer;
1716
import de.scribble.lp.tasmod.monitoring.DesyncMonitoring;

src/main/java/de/scribble/lp/tasmod/commands/savetas/FileThread.java renamed to src/main/java/de/scribble/lp/tasmod/util/FileThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package de.scribble.lp.tasmod.commands.savetas;
1+
package de.scribble.lp.tasmod.util;
22

33
import java.io.File;
44
import java.io.FileNotFoundException;

0 commit comments

Comments
 (0)