Potentially fix #34 (Replace "\" in file paths with File.separatorChar to allow for use on Linux)

I can't currently test if this fixed the problem since I don't have a Linux install to test on.
This commit is contained in:
James Seibel
2021-06-27 13:12:38 -05:00
parent d5ec17551e
commit 46e65704d7
3 changed files with 13 additions and 12 deletions
@@ -20,7 +20,7 @@ import com.seibel.lod.proxy.ClientProxy;
* to file.
*
* @author James Seibel
* @version 6-13-2021
* @version 6-27-2021
*/
public class LodDimensionFileHandler
{
@@ -332,7 +332,7 @@ public class LodDimensionFileHandler
// ".\Super Flat\DIM-1\data"
// or
// ".\Super Flat\data"
return dimensionDataSaveFolder.getCanonicalPath() + "\\" +
return dimensionDataSaveFolder.getCanonicalPath() + File.separatorChar +
FILE_NAME_PREFIX + "." + detail.toString() + "." + regionX + "." + regionZ + FILE_EXTENSION;
}
catch(IOException e)
@@ -17,7 +17,7 @@ import net.minecraft.world.server.ServerWorld;
* for a given dimension.
*
* @author James Seibel
* @version 06-19-2021
* @version 06-27-2021
*/
public class LodDimension
{
@@ -53,14 +53,14 @@ public class LodDimension
// provider needs a separate variable to prevent
// the compiler from complaining
ServerChunkProvider provider = serverWorld.getChunkProvider();
saveDir = new File(provider.getSavedData().folder.getCanonicalFile() + "\\lod");
saveDir = new File(provider.getSavedData().folder.getCanonicalFile().getPath() + File.separatorChar + "lod");
}
else
{
// connected to server
saveDir = new File(mc.gameDir.getCanonicalFile() +
"\\lod server data\\" + LodUtil.getDimensionIDFromWorld(mc.world));
saveDir = new File(mc.gameDir.getCanonicalFile().getPath() +
File.separatorChar + "lod server data" + File.separatorChar + LodUtil.getDimensionIDFromWorld(mc.world));
}
fileHandler = new LodDimensionFileHandler(saveDir, this);
@@ -1,6 +1,7 @@
package com.seibel.lod.util;
import java.awt.Color;
import java.io.File;
import com.seibel.lod.objects.LodRegion;
import com.seibel.lod.objects.RegionPos;
@@ -20,7 +21,7 @@ import net.minecraft.world.server.ServerWorld;
* This class holds methods that may be used in multiple places.
*
* @author James Seibel
* @version 06-19-2021
* @version 06-27-2021
*/
public class LodUtil
{
@@ -143,8 +144,8 @@ public class LodUtil
ServerData server = mc.getCurrentServerData();
return server.serverName + ", IP " +
server.serverIP + ", GameVersion " +
server.gameVersion.getString() + "\\"
+ "dim_" + mc.world.getDimensionType().getEffects().getPath() + "\\";
server.gameVersion.getString() + File.separatorChar
+ "dim_" + mc.world.getDimensionType().getEffects().getPath() + File.separatorChar;
}
}
@@ -181,8 +182,8 @@ public class LodUtil
ServerData server = mc.getCurrentServerData();
return server.serverName + ", IP " +
server.serverIP + ", GameVersion " +
server.gameVersion.getString() + "\\"
+ "dim_" + world.getDimensionType().getEffects().getPath() + "\\";
server.gameVersion.getString() + File.separatorChar
+ "dim_" + world.getDimensionType().getEffects().getPath() + File.separatorChar;
}
}
@@ -200,7 +201,7 @@ public class LodUtil
// get the world name
int saveIndex = dimId.indexOf("saves") + 1 + "saves".length();
int slashIndex = dimId.indexOf('\\', saveIndex);
int slashIndex = dimId.indexOf(File.separatorChar, saveIndex);
dimId = dimId.substring(saveIndex, slashIndex);
return dimId;
}