Skip to content

Commit

Permalink
Started working on #112
Browse files Browse the repository at this point in the history
Too tired to continue...

-Moved FileThread.class to util package
  • Loading branch information
Scribble authored and Scribble committed Oct 1, 2021
1 parent 1b020f8 commit d1692a6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ dependencies {
compile 'org.msgpack:msgpack-core:0.8.16'
compile 'org.msgpack:jackson-dataformat-msgpack:0.8.16'
compile files('libs/KillTheRNG-1.12.2-1.0-deobf.jar')
//compile files('libs/BigArrayList-1.3.jar')
compile 'com.dselent:bigarraylist:1.0'
// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.scribble.lp.tasmod.savestates.server;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

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

private static String nextSaveName(String worldname, int index) {
File[] listofFiles=savestateDirectory.listFiles(new FileFilter() {

@Override
public boolean accept(File pathname) {
return pathname.getName().startsWith(worldname);
}

});
if(index<0) {
}
return "";
}

/**
* Searches through the savestate folder to look for the next possible savestate foldername <br>
* Savestate equivalent to {@link SavestateHandler#getLatestSavestateLocation(String)}
* @param worldname The worldname of the current world
* @return targetsavefolder The file where the savestate should be copied to
* @throws SavestateException if the found savestates count is greater or equal than 300
*/
@Deprecated
private static File getNextSaveFolderLocation(String worldname) throws SavestateException {
int i = 1;
int limit=300;
Expand All @@ -138,6 +155,7 @@ private static File getNextSaveFolderLocation(String worldname) throws Savestate
* @param worldname the name of the world currently on the server
* @return The correct name of the next savestate
*/
@Deprecated
private static String nameWhenSaving(String worldname) {
int i = 1;
int limit=300;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public IMessage onMessage(SavestatePacket message, MessageContext ctx) {
return;
}
try {
SavestateHandler.saveState();
SavestateHandler.saveState(-1);
} catch (SavestateException e) {
player.sendMessage(new TextComponentString(TextFormatting.RED+"Failed to create a savestate: "+ e.getMessage()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import com.dselent.bigarraylist.BigArrayList;

import de.scribble.lp.tasmod.commands.savetas.FileThread;
import de.scribble.lp.tasmod.inputcontainer.InputContainer;
import de.scribble.lp.tasmod.inputcontainer.TickInputContainer;
import de.scribble.lp.tasmod.monitoring.DesyncMonitoring;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.scribble.lp.tasmod.commands.savetas;
package de.scribble.lp.tasmod.util;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down

0 comments on commit d1692a6

Please sign in to comment.