refactor and comment

This commit is contained in:
James Seibel
2023-02-28 21:43:08 -06:00
parent 70369fa468
commit cc474caf33
6 changed files with 21 additions and 21 deletions
@@ -4,10 +4,10 @@ import com.seibel.lod.core.Initializer;
import com.seibel.lod.core.world.*;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
/** Contains code and variables used by both {@link ClientApi} and {@link ServerApi} */
public class SharedApi
{
public static IMinecraftSharedWrapper MC;
public static IMinecraftSharedWrapper MC; // TODO remove if possible, it is only used in one odd spot
private static AbstractDhWorld currentWorld;
@@ -9,7 +9,7 @@ import com.seibel.lod.core.util.LodUtil;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
//TODO: Merge this with FullToColumnTransformer
/** TODO: Merge this with {@link FullToColumnTransformer} */
public class DataRenderTransformer
{
public static final ExecutorService TRANSFORMER_THREADS
@@ -195,19 +195,19 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
return data;
})
.thenApply((data) -> this.handler.onDataFileLoaded(data, this.metaData, this::saveChanges, this::applyWriteQueue))
.whenComplete((v, e) ->
.whenComplete((fullDataSource, exception) ->
{
if (e != null)
if (exception != null)
{
LOGGER.error("Uncaught error on creation {}: ", this.file, e);
LOGGER.error("Uncaught error on creation "+this.file+": ", exception);
future.complete(null);
this.data.set(null);
}
else
{
future.complete(v);
new DataObjTracker(v);
this.data.set(new SoftReference<>(v));
future.complete(fullDataSource);
new DataObjTracker(fullDataSource);
this.data.set(new SoftReference<>(fullDataSource));
}
});
}
@@ -343,7 +343,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
{
if (file.exists() && !file.delete())
{
LOGGER.warn("Failed to delete data file at {}", file);
LOGGER.warn("Failed to delete data file at {}", file);
}
doesFileExist = false;
}
@@ -49,7 +49,7 @@ public class DhApiWorldProxy implements IDhApiWorldProxy
}
if (!SharedApi.MC.isDedicatedServer())
if (!SharedApi.MC.isDedicatedServer()) // TODO why isn't this thrown a null pointer? when is SharedApi.MC being set?
{
return MC.getWrappedClientWorld();
}
@@ -114,17 +114,14 @@ public class DhClientServerWorld extends AbstractDhWorld implements IDhClientWor
//LOGGER.info("Client world tick");
this.eventLoop.tick();
}
public void serverTick() { this.dhLevels.forEach(DhClientServerLevel::serverTick); }
public void doWorldGen() { this.dhLevels.forEach(DhClientServerLevel::doWorldGen); }
@Override
public CompletableFuture<Void> saveAndFlush()
{
return CompletableFuture.allOf(this.dhLevels.stream().map(DhClientServerLevel::saveAsync).toArray(CompletableFuture[]::new));
}
public CompletableFuture<Void> saveAndFlush() { return CompletableFuture.allOf(this.dhLevels.stream().map(DhClientServerLevel::saveAsync).toArray(CompletableFuture[]::new)); }
@Override
public void close()
{
@@ -132,7 +129,7 @@ public class DhClientServerWorld extends AbstractDhWorld implements IDhClientWor
for (DhClientServerLevel level : this.dhLevels)
{
LOGGER.info("Unloading level " + level.serverLevelWrapper.getDimensionType().getDimensionName());
LOGGER.info("Unloading level "+level.serverLevelWrapper.getDimensionType().getDimensionName());
level.close();
}
@@ -75,7 +75,10 @@ public interface IMinecraftClientWrapper extends IBindable
DhChunkPos getPlayerChunkPos();
/** Returns the level the client is currently in. */
/**
* Returns the level the client is currently in. <br>
* Returns null if the client isn't in a level.
*/
ILevelWrapper getWrappedClientWorld();
File getGameDirectory();