commit
9ecfb686aa
3 changed files with 12 additions and 20 deletions
|
@ -621,8 +621,7 @@ public class PocketManager
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("Pocket dimensions have already been unloaded!");
|
throw new IllegalStateException("Pocket dimensions have already been unloaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
save(false);
|
|
||||||
unregisterPockets();
|
unregisterPockets();
|
||||||
dimensionData = null;
|
dimensionData = null;
|
||||||
rootDimensions = null;
|
rootDimensions = null;
|
||||||
|
|
|
@ -2,16 +2,11 @@ package StevenDimDoors.mod_pocketDim.saving;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
@ -21,10 +16,7 @@ import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
|
||||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.util.ConfigurationProcessingException;
|
|
||||||
import StevenDimDoors.mod_pocketDim.util.DDLogger;
|
import StevenDimDoors.mod_pocketDim.util.DDLogger;
|
||||||
import StevenDimDoors.mod_pocketDim.util.FileFilters;
|
import StevenDimDoors.mod_pocketDim.util.FileFilters;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
@ -258,8 +250,10 @@ public class DDSaveHandler
|
||||||
|
|
||||||
// Get the save directory path
|
// Get the save directory path
|
||||||
File saveDirectory = new File(mod_pocketDim.instance.getCurrentSavePath() + "/DimensionalDoors/data/");
|
File saveDirectory = new File(mod_pocketDim.instance.getCurrentSavePath() + "/DimensionalDoors/data/");
|
||||||
File backupDir = new File(saveDirectory+"/backup");
|
File backupDirectory = new File(saveDirectory + "/backup");
|
||||||
String savePath = saveDirectory.getAbsolutePath();
|
String savePath = saveDirectory.getAbsolutePath();
|
||||||
|
String baseSavePath = savePath + "/dim_";
|
||||||
|
String baseBackupPath = backupDirectory.getAbsolutePath() + "/dim_";
|
||||||
|
|
||||||
if(!saveDirectory.exists())
|
if(!saveDirectory.exists())
|
||||||
{
|
{
|
||||||
|
@ -276,11 +270,10 @@ public class DDSaveHandler
|
||||||
DimDataProcessor writer = new DimDataProcessor();
|
DimDataProcessor writer = new DimDataProcessor();
|
||||||
for (IPackable<PackedDimData> dimension : dimensions)
|
for (IPackable<PackedDimData> dimension : dimensions)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check if the dimension should be saved
|
// Check if the dimension should be saved
|
||||||
if (!checkModified || dimension.isModified())
|
if (!checkModified || dimension.isModified())
|
||||||
{
|
{
|
||||||
if (writeDimension(dimension, writer, savePath + "/dim_",backupDir))
|
if (writeDimension(dimension, writer, baseSavePath, baseBackupPath))
|
||||||
{
|
{
|
||||||
dimension.clearModified();
|
dimension.clearModified();
|
||||||
}
|
}
|
||||||
|
@ -314,17 +307,16 @@ public class DDSaveHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean writeDimension(IPackable<PackedDimData> dimension, DimDataProcessor writer, String basePath, File backupDir)
|
private static boolean writeDimension(IPackable<PackedDimData> dimension, DimDataProcessor writer, String basePath, String backupPath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File saveFile = new File(basePath + (dimension.name() + ".txt"));
|
File saveFile = new File(basePath + dimension.name() + ".txt");
|
||||||
|
|
||||||
//If the savefile already exists, back it up.
|
// If the save file already exists, back it up.
|
||||||
if(saveFile.exists())
|
if (saveFile.exists())
|
||||||
{
|
{
|
||||||
FileUtils.copyFileToDirectory(saveFile, backupDir);
|
Files.move(saveFile, new File(backupPath + dimension.name() + ".txt"));
|
||||||
saveFile.delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.writeToFile(saveFile, dimension.pack());
|
writer.writeToFile(saveFile, dimension.pack());
|
||||||
|
|
|
@ -15,7 +15,8 @@ public class DDLogger
|
||||||
this.log.append("Logger started.\n");
|
this.log.append("Logger started.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DDLogger logger()
|
// SenseiKiwi: I changed this to private to guarantee that the logger isn't being used anywhere.
|
||||||
|
private static DDLogger logger()
|
||||||
{
|
{
|
||||||
if( instance == null)
|
if( instance == null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue