diff --git a/src/main/java/com/seibel/lod/core/enums/config/VerticalQuality.java b/src/main/java/com/seibel/lod/core/enums/config/VerticalQuality.java index a620ee620..551ed0702 100644 --- a/src/main/java/com/seibel/lod/core/enums/config/VerticalQuality.java +++ b/src/main/java/com/seibel/lod/core/enums/config/VerticalQuality.java @@ -24,7 +24,7 @@ package com.seibel.lod.core.enums.config; * multi_lod
* * @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.
+ * Returns null if no enums match the name.
+ * 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; + } + } + } \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/core/handlers/LodDimensionFinder.java b/src/main/java/com/seibel/lod/core/handlers/LodDimensionFinder.java index 9426b3a86..35090230f 100644 --- a/src/main/java/com/seibel/lod/core/handlers/LodDimensionFinder.java +++ b/src/main/java/com/seibel/lod/core/handlers/LodDimensionFinder.java @@ -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;