Automatically move old files to the new sub-dim system

This commit is contained in:
James Seibel
2022-03-26 20:50:57 -05:00
parent bc72142659
commit 03f5a086f0
2 changed files with 55 additions and 9 deletions
@@ -24,7 +24,7 @@ package com.seibel.lod.core.enums.config;
* multi_lod <br>
*
* @author Leonardo Amato
* @version 10-07-2021
* @version 2022-3-26
*/
public enum VerticalQuality
{
@@ -59,7 +59,7 @@ public enum VerticalQuality
this.maxConnectedLods = maxConnectedLods;
}
// Note: return null if out of range
/** returns null if out of range */
public static VerticalQuality previous(VerticalQuality mode)
{
switch (mode)
@@ -76,7 +76,7 @@ public enum VerticalQuality
}
}
// Note: return null if out of range
/** returns null if out of range */
public static VerticalQuality next(VerticalQuality mode)
{
switch (mode)
@@ -92,4 +92,28 @@ public enum VerticalQuality
return null;
}
}
/**
* Returns the value with the given name, case-insensitive. <br>
* Returns null if no enums match the name. <br>
* Similar to valueOf(String value)
*/
public static VerticalQuality getByName(String name)
{
switch (name.toUpperCase())
{
case "ULTRA":
return VerticalQuality.ULTRA;
case "HIGH":
return VerticalQuality.HIGH;
case "MEDIUM":
return VerticalQuality.MEDIUM;
case "LOW":
return VerticalQuality.LOW;
default:
return null;
}
}
}
@@ -26,6 +26,8 @@ import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
import java.io.File;
import java.io.IOException;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.util.UUID;
/**
@@ -131,11 +133,6 @@ public class LodDimensionFinder
playerData = new PlayerData(MC);
}
// TODO check based on the dimension's last seen location instead of the first seen player data
// hopefully this should fix entering a dimension in two different locations
// relevant positions
AbstractChunkPosWrapper playerChunkPos = FACTORY.createChunkPos(firstSeenPlayerData.playerBlockPos);
int startingBlockPosX = playerChunkPos.getMinBlockX();
@@ -211,7 +208,28 @@ public class LodDimensionFinder
}
}
// TODO move any old files if they exist
// move any old data folders if they exist
String moveId = UUID.randomUUID().toString();
for (File folder : dimensionFolder.listFiles())
{
if (VerticalQuality.getByName(folder.getName()) != null)
{
// this is a LOD save folder
// create a new sub dimension and move the data into it
File newDimension = GetDimensionFolder(newlyLoadedDim.dimension, moveId);
newDimension.mkdirs();
File oldDataNewPath = new File(newDimension.getPath() + File.separatorChar + folder.getName());
Files.move(folder.toPath(), oldDataNewPath.toPath());
}
else
{
// ignore this folder
}
}
@@ -291,6 +309,10 @@ public class LodDimensionFinder
LOGGER.info(message);
}
// TODO if two sub dimensions contain the same LODs merge them
// the first seen player data is no longer needed, the sub dimension has been determined
firstSeenPlayerData = null;