Move level (subDim) matching into its own package
This commit is contained in:
@@ -7,7 +7,7 @@ import com.seibel.lod.core.datatype.full.ChunkSizedData;
|
||||
import com.seibel.lod.core.datatype.full.FullDataSource;
|
||||
import com.seibel.lod.core.datatype.full.SparseDataSource;
|
||||
import com.seibel.lod.core.datatype.full.SpottyDataSource;
|
||||
import com.seibel.lod.core.file.MetaFile;
|
||||
import com.seibel.lod.core.file.subDimMatching.MetaFile;
|
||||
import com.seibel.lod.core.level.IDhLevel;
|
||||
import com.seibel.lod.core.pos.DhLodPos;
|
||||
import com.seibel.lod.core.pos.DhSectionPos;
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.io.*;
|
||||
import java.lang.ref.*;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@@ -13,7 +12,7 @@ import com.seibel.lod.core.datatype.ILodDataSource;
|
||||
import com.seibel.lod.core.datatype.AbstractDataSourceLoader;
|
||||
import com.seibel.lod.core.datatype.full.ChunkSizedData;
|
||||
import com.seibel.lod.core.pos.DhLodPos;
|
||||
import com.seibel.lod.core.file.MetaFile;
|
||||
import com.seibel.lod.core.file.subDimMatching.MetaFile;
|
||||
import com.seibel.lod.core.level.IDhLevel;
|
||||
import com.seibel.lod.core.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.seibel.lod.core.file.datafile;
|
||||
|
||||
import com.seibel.lod.core.datatype.ILodDataSource;
|
||||
import com.seibel.lod.core.datatype.full.ChunkSizedData;
|
||||
import com.seibel.lod.core.file.MetaFile;
|
||||
import com.seibel.lod.core.file.subDimMatching.MetaFile;
|
||||
import com.seibel.lod.core.pos.DhSectionPos;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.seibel.lod.core.datatype.full.ChunkSizedData;
|
||||
import com.seibel.lod.core.level.IDhClientLevel;
|
||||
import com.seibel.lod.core.level.IDhLevel;
|
||||
import com.seibel.lod.core.pos.DhLodPos;
|
||||
import com.seibel.lod.core.file.MetaFile;
|
||||
import com.seibel.lod.core.file.subDimMatching.MetaFile;
|
||||
import com.seibel.lod.core.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.seibel.lod.core.file.structure;
|
||||
|
||||
import com.google.common.net.PercentEscaper;
|
||||
import com.seibel.lod.core.file.LevelToFileMatcher;
|
||||
import com.seibel.lod.core.file.subDimMatching.SubDimensionLevelMatcher;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.seibel.lod.api.enums.config.EServerFolderNameMode;
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
@@ -71,7 +71,7 @@ public class ClientOnlySaveStructure extends SaveStructure {
|
||||
return new PercentEscaper("", true).escape(folderName);
|
||||
}
|
||||
|
||||
LevelToFileMatcher fileMatcher = null;
|
||||
SubDimensionLevelMatcher fileMatcher = null;
|
||||
final HashMap<ILevelWrapper, File> levelToFileMap = new HashMap<>();
|
||||
|
||||
// Fit for Client_Only environment
|
||||
@@ -93,7 +93,7 @@ public class ClientOnlySaveStructure extends SaveStructure {
|
||||
}
|
||||
if (fileMatcher == null || !fileMatcher.isFindingLevel(l)) {
|
||||
LOGGER.info("Loading level for world " + l.getDimensionType().getDimensionName());
|
||||
fileMatcher = new LevelToFileMatcher(l, folder,
|
||||
fileMatcher = new SubDimensionLevelMatcher(l, folder,
|
||||
(File[]) getMatchingLevelFolders(l).toArray());
|
||||
}
|
||||
File levelFile = fileMatcher.tryGetLevel();
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.core.file;
|
||||
package com.seibel.lod.core.file.subDimMatching;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.core.file;
|
||||
package com.seibel.lod.core.file.subDimMatching;
|
||||
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+7
-7
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.core.file;
|
||||
package com.seibel.lod.core.file.subDimMatching;
|
||||
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.seibel.lod.core.datatype.ILodDataSource;
|
||||
@@ -37,7 +37,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* @author James Seibel
|
||||
* @version 12-17-2022
|
||||
*/
|
||||
public class LevelToFileMatcher implements AutoCloseable
|
||||
public class SubDimensionLevelMatcher implements AutoCloseable
|
||||
{
|
||||
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||
public static final ConfigBasedLogger LOGGER = new ConfigBasedLogger(LogManager.getLogger(),
|
||||
@@ -45,8 +45,8 @@ public class LevelToFileMatcher implements AutoCloseable
|
||||
|
||||
private final ExecutorService matcherThread = LodUtil.makeSingleThreadPool("Level-To-File-Matcher");
|
||||
|
||||
private PlayerData playerData = null;
|
||||
private PlayerData firstSeenPlayerData = null;
|
||||
private SubDimensionPlayerData playerData = null;
|
||||
private SubDimensionPlayerData firstSeenPlayerData = null;
|
||||
|
||||
/** If true the LodDimensionFileHelper is attempting to determine the folder for this dimension */
|
||||
private final AtomicBoolean determiningWorldFolder = new AtomicBoolean(false);
|
||||
@@ -57,7 +57,7 @@ public class LevelToFileMatcher implements AutoCloseable
|
||||
|
||||
|
||||
|
||||
public LevelToFileMatcher(ILevelWrapper targetWorld, File levelsFolder, File[] potentialFiles)
|
||||
public SubDimensionLevelMatcher(ILevelWrapper targetWorld, File levelsFolder, File[] potentialFiles)
|
||||
{
|
||||
this.currentLevel = targetWorld;
|
||||
this.potentialFiles = potentialFiles;
|
||||
@@ -128,7 +128,7 @@ public class LevelToFileMatcher implements AutoCloseable
|
||||
public File attemptToDetermineSubDimensionFolder() throws IOException
|
||||
{
|
||||
{ // Update PlayerData
|
||||
PlayerData data = PlayerData.tryGetPlayerData(MC_CLIENT);
|
||||
SubDimensionPlayerData data = SubDimensionPlayerData.tryGetPlayerData(MC_CLIENT);
|
||||
if (data != null)
|
||||
{
|
||||
if (this.firstSeenPlayerData == null)
|
||||
@@ -269,7 +269,7 @@ public class LevelToFileMatcher implements AutoCloseable
|
||||
|
||||
|
||||
// get the player data for this dimension folder
|
||||
PlayerData testPlayerData = new PlayerData(testLevelFolder);
|
||||
SubDimensionPlayerData testPlayerData = new SubDimensionPlayerData(testLevelFolder);
|
||||
LOGGER.info("Last known player pos: [" + testPlayerData.playerBlockPos.getX() + "," + testPlayerData.playerBlockPos.getY() + "," + testPlayerData.playerBlockPos.getZ() + "]");
|
||||
|
||||
// check if the block positions are close
|
||||
+6
-6
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.core.file;
|
||||
package com.seibel.lod.core.file.subDimMatching;
|
||||
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
@@ -35,7 +35,7 @@ import java.io.File;
|
||||
* @author James Seibel
|
||||
* @version 2022-3-26
|
||||
*/
|
||||
public class PlayerData
|
||||
public class SubDimensionPlayerData
|
||||
{
|
||||
public static final IWrapperFactory FACTORY = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PlayerData
|
||||
|
||||
|
||||
@Nullable
|
||||
public static PlayerData tryGetPlayerData(IMinecraftClientWrapper mcClient)
|
||||
public static SubDimensionPlayerData tryGetPlayerData(IMinecraftClientWrapper mcClient)
|
||||
{
|
||||
if (!mcClient.playerExists())
|
||||
{
|
||||
@@ -69,7 +69,7 @@ public class PlayerData
|
||||
|
||||
try
|
||||
{
|
||||
return new PlayerData(mcClient);
|
||||
return new SubDimensionPlayerData(mcClient);
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
@@ -78,12 +78,12 @@ public class PlayerData
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerData(IMinecraftClientWrapper mc)
|
||||
private SubDimensionPlayerData(IMinecraftClientWrapper mc)
|
||||
{
|
||||
this.updateData(mc);
|
||||
}
|
||||
|
||||
public PlayerData(File dimensionFolder)
|
||||
public SubDimensionPlayerData(File dimensionFolder)
|
||||
{
|
||||
File file = getFileForDimensionFolder(dimensionFolder);
|
||||
try (CommentedFileConfig toml = CommentedFileConfig.builder(file).build()) {
|
||||
Reference in New Issue
Block a user