Rename SingletonHandler -> SingletonInjector

This was done with all Dependency Injection objects because there was a name conflict with DhApi event handlers. (This new name is also more specific and makes sense for dependency injection).
This commit is contained in:
James Seibel
2022-07-16 22:09:22 -05:00
parent 8c0767523d
commit 9a8ed301cb
36 changed files with 85 additions and 107 deletions
@@ -2,7 +2,6 @@ package com.seibel.lod.core;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatLightLaf;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.jar.DarkModeDetector;
import com.seibel.lod.core.jar.gui.BaseJFrame;
import com.seibel.lod.core.jar.gui.cusomJObject.JBox;
@@ -1,27 +1,15 @@
package com.seibel.lod.core.a7.datatype;
import java.util.ConcurrentModificationException;
import java.util.concurrent.*;
import com.seibel.lod.core.a7.datatype.full.ChunkSizedData;
import com.seibel.lod.core.a7.datatype.transform.LodDataBuilder;
import com.seibel.lod.core.a7.level.ILevel;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.ELodDirection;
import com.seibel.lod.core.enums.config.EBlocksToAvoid;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.objects.DHBlockPos;
import com.seibel.lod.core.objects.DHChunkPos;
import com.seibel.lod.core.objects.lod.LodRegion;
import com.seibel.lod.core.util.*;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
import org.apache.logging.log4j.LogManager;
public class LodBuilder {
@@ -22,14 +22,14 @@ package com.seibel.lod.core.a7.datatype.column.render;
import com.seibel.lod.core.a7.datatype.column.accessor.ColumnArrayView;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodQuadBuilder;
import com.seibel.lod.core.enums.ELodDirection;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.util.ColorUtil;
import com.seibel.lod.core.util.DataPointUtil;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
public class ColumnBox
{
private static final IMinecraftClientWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
public static void addBoxQuadsToBuilder(LodQuadBuilder builder, short xSize, short ySize, short zSize, short x,
short y, short z, int color, byte skyLight, byte blockLight, long topData, long botData, ColumnArrayView[][] adjData)
@@ -1,6 +1,6 @@
package com.seibel.lod.core.a7.datatype.full;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.block.IBlockStateWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper;
@@ -12,7 +12,7 @@ import java.util.Objects;
// WARNING: This is not THREAD-SAFE!
public class IdBiomeBlockStateMap {
public static final IWrapperFactory FACTORY = SingletonHandler.INSTANCE.get(IWrapperFactory.class);
public static final IWrapperFactory FACTORY = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
public static final class Entry {
public final IBiomeWrapper biome;
@@ -8,7 +8,7 @@ import com.seibel.lod.core.a7.pos.DhBlockPos2D;
import com.seibel.lod.core.a7.render.RenderBufferHandler;
import com.seibel.lod.core.a7.save.structure.ClientOnlySaveStructure;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.objects.math.Mat4f;
import com.seibel.lod.core.render.a7LodRenderer;
@@ -23,7 +23,7 @@ import java.util.concurrent.CompletableFuture;
public class DhClientLevel implements IClientLevel {
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private static final IMinecraftClientWrapper MC_CLIENT = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
public final ClientOnlySaveStructure save;
public final RemoteDataFileHandler dataFileHandler;
public final RenderFileHandler renderFileHandler;
@@ -8,7 +8,7 @@ import com.seibel.lod.core.a7.pos.DhBlockPos2D;
import com.seibel.lod.core.a7.render.RenderBufferHandler;
import com.seibel.lod.core.a7.save.structure.LocalSaveStructure;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.objects.math.Mat4f;
import com.seibel.lod.core.render.a7LodRenderer;
@@ -23,7 +23,7 @@ import java.util.concurrent.CompletableFuture;
public class DhClientServerLevel implements IClientLevel, IServerLevel {
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private static final IMinecraftClientWrapper MC_CLIENT = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
public final LocalSaveStructure save;
public final LocalDataFileHandler dataFileHandler;
public RenderFileHandler renderFileHandler = null;
@@ -1,7 +1,7 @@
package com.seibel.lod.core.a7.save.io;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.handlers.dimensionFinder.PlayerData;
import com.seibel.lod.core.handlers.dimensionFinder.SubDimCompare;
import com.seibel.lod.core.logging.ConfigBasedLogger;
@@ -20,7 +20,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
public class LevelToFileMatcher implements AutoCloseable {
private static final IMinecraftClientWrapper MC_CLIENT = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
public static final ConfigBasedLogger LOGGER = new ConfigBasedLogger(LogManager.getLogger(),
() -> Config.Client.Advanced.Debugging.DebugSwitch.logFileSubDimEvent.get());
@@ -3,7 +3,7 @@ package com.seibel.lod.core.a7.save.structure;
import com.seibel.lod.core.a7.save.io.LevelToFileMatcher;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EServerFolderNameMode;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.ParsedIp;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
@@ -18,7 +18,7 @@ import java.util.stream.Stream;
public class ClientOnlySaveStructure extends SaveStructure {
final File folder;
private static final IMinecraftClientWrapper MC_CLIENT = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
public static final String INVALID_FILE_CHARACTERS_REGEX = "[\\\\/:*?\"<>|]";
private static String getServerFolderName()
{
@@ -1,15 +1,13 @@
package com.seibel.lod.core.a7.save.structure;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
import java.io.File;
public class LocalSaveStructure extends SaveStructure {
private static final IMinecraftSharedWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftSharedWrapper.class);
private static final IMinecraftSharedWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class);
private File debugPath = new File("");
@@ -2,7 +2,7 @@ package com.seibel.lod.core.api.external.methods.events;
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
import com.seibel.lod.core.api.external.items.objects.DhApiResult;
import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventHandler;
import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector;
/**
* Handles adding/removing event handlers.
@@ -22,7 +22,7 @@ public class DhApiEventRegister
{
try
{
DhApiEventHandler.INSTANCE.bind(eventInterface, eventHandlerImplementation);
DhApiEventInjector.INSTANCE.bind(eventInterface, eventHandlerImplementation);
return new DhApiResult(true, "");
}
catch (IllegalStateException e)
@@ -38,7 +38,7 @@ public class DhApiEventRegister
*/
public static DhApiResult off(Class<? extends IDhApiEvent> eventInterface, Class<IDhApiEvent> eventHandlerClass)
{
if (DhApiEventHandler.INSTANCE.unbind(eventInterface, eventHandlerClass))
if (DhApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
{
return new DhApiResult(true, "");
}
@@ -25,7 +25,7 @@ import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.enums.rendering.EDebugMode;
import com.seibel.lod.core.enums.rendering.ERendererMode;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
import com.seibel.lod.core.logging.SpamReducedLogger;
@@ -60,8 +60,8 @@ public class ClientApi
public static final ClientApi INSTANCE = new ClientApi();
public static RenderSystemTest testRenderer = new RenderSystemTest();
private static final IMinecraftClientWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
public static final boolean ENABLE_LAG_SPIKE_LOGGING = false;
public static final long LAG_SPIKE_THRESHOLD_NS = TimeUnit.NANOSECONDS.convert(16, TimeUnit.MILLISECONDS);
@@ -22,7 +22,7 @@ package com.seibel.lod.core.api.internal.a7;
import com.seibel.lod.core.a7.world.DhClientServerWorld;
import com.seibel.lod.core.a7.world.DhServerWorld;
import com.seibel.lod.core.a7.world.IServerWorld;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
@@ -43,7 +43,7 @@ public class ServerApi
public static final boolean ENABLE_STACK_DUMP_LOGGING = false;
public static final ServerApi INSTANCE = new ServerApi();
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
private static final IVersionConstants VERSION_CONSTANTS = SingletonHandler.INSTANCE.get(IVersionConstants.class);
private static final IVersionConstants VERSION_CONSTANTS = SingletonInjector.INSTANCE.get(IVersionConstants.class);
private ServerApi()
{
@@ -20,7 +20,7 @@
package com.seibel.lod.core.builders.lodBuilding.bufferBuilding;
import com.seibel.lod.core.enums.rendering.EDebugMode;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.LodDataView;
import com.seibel.lod.core.a7.datatype.column.accessor.ColumnArrayView;
import com.seibel.lod.core.a7.datatype.column.render.ColumnBox;
@@ -38,7 +38,7 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
*/
public class CubicLodTemplate
{
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.INSTANCE.get(ILodConfigWrapperSingleton.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonInjector.INSTANCE.get(ILodConfigWrapperSingleton.class);
public static void addLodToBuffer(long data, long topData, long botData, LodDataView[][] adjData,
boolean[] adjFillBlack, byte detailLevel, int offsetPosX, int offsetOosZ, LodQuadBuilder quadBuilder, EDebugMode debugging)
@@ -19,19 +19,17 @@
package com.seibel.lod.core.builders.worldGeneration;
import com.seibel.lod.core.a7.level.IClientLevel;
import com.seibel.lod.core.a7.level.ILevel;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.enums.config.EGenerationPriority;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.objects.PosToGenerateContainer;
import com.seibel.lod.core.util.LevelPosUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper;
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper.Steps;
import org.apache.logging.log4j.Logger;
@@ -42,8 +40,8 @@ public class BatchGenerator
{
public static final boolean ENABLE_GENERATOR_STATS_LOGGING = false;
private static final IMinecraftClientWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IWrapperFactory FACTORY = SingletonHandler.INSTANCE.get(IWrapperFactory.class);
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IWrapperFactory FACTORY = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
public AbstractBatchGenerationEnvionmentWrapper generationGroup;
public ILevel targetLodLevel;
public static final int generationGroupSize = 4;
@@ -6,7 +6,7 @@ import com.seibel.lod.core.api.internal.a7.ClientApi;
import com.seibel.lod.core.config.ConfigBase;
import com.seibel.lod.core.config.types.AbstractConfigType;
import com.seibel.lod.core.config.types.ConfigEntry;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
import org.json.simple.JSONObject;
@@ -24,7 +24,7 @@ import java.nio.file.Path;
* @version 2022-5-26
*/
public class ConfigFileHandling {
public static final Path ConfigPath = SingletonHandler.INSTANCE.get(IMinecraftSharedWrapper.class).getInstallationDirectory().toPath().resolve("config").resolve(ModInfo.NAME+".toml");
public static final Path ConfigPath = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class).getInstallationDirectory().toPath().resolve("config").resolve(ModInfo.NAME+".toml");
/** Saves the config to the file */
public static void saveToFile() {
@@ -170,7 +170,7 @@ public class ConfigFileHandling {
} catch (IOException ex) {
System.out.println("Creating file failed");
ex.printStackTrace();
SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Loading file and resetting config file failed at path ["+ConfigPath+"]. Please check the file is ok and you have the permissions", ex);
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Loading file and resetting config file failed at path ["+ConfigPath+"]. Please check the file is ok and you have the permissions", ex);
}
}
}
@@ -22,7 +22,7 @@ package com.seibel.lod.core.handlers;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import org.apache.logging.log4j.Logger;
@@ -58,7 +58,7 @@ public class ReflectionHandler implements IReflectionHandler
@Override
public void finishDelayedSetup()
{
mcOptionsObject = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class).getOptionsObject();
mcOptionsObject = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).getOptionsObject();
setupFogField(mcOptionsObject.getClass().getDeclaredFields());
this.delayedSetupDone = true;
@@ -30,7 +30,7 @@ import java.util.Map;
* @author James Seibel
* @version 2022-7-16
*/
public class DependencyHandler<BindableType extends IBindable>
public class DependencyInjector<BindableType extends IBindable>
{
protected final Map<Class<? extends BindableType>, ArrayList<BindableType>> dependencies = new HashMap<>();
@@ -40,13 +40,13 @@ public class DependencyHandler<BindableType extends IBindable>
protected final boolean allowDuplicateBindings;
public DependencyHandler(Class<BindableType> newBindableInterface)
public DependencyInjector(Class<BindableType> newBindableInterface)
{
this.bindableInterface = newBindableInterface;
this.allowDuplicateBindings = false;
}
public DependencyHandler(Class<BindableType> newBindableInterface, boolean newAllowDuplicateBindings)
public DependencyInjector(Class<BindableType> newBindableInterface, boolean newAllowDuplicateBindings)
{
this.bindableInterface = newBindableInterface;
this.allowDuplicateBindings = newAllowDuplicateBindings;
@@ -34,12 +34,12 @@ import java.util.ArrayList;
* @author Leetom
* @version 2022-7-16
*/
public class DhApiEventHandler extends DependencyHandler<IDhApiEvent>
public class DhApiEventInjector extends DependencyInjector<IDhApiEvent>
{
public static final DhApiEventHandler INSTANCE = new DhApiEventHandler();
public static final DhApiEventInjector INSTANCE = new DhApiEventInjector();
public DhApiEventHandler()
public DhApiEventInjector()
{
super(IDhApiEvent.class, true);
}
@@ -36,21 +36,21 @@ import java.lang.invoke.MethodHandles;
* @author Leetom
* @version 2022-7-16
*/
public class ModAccessorHandler extends DependencyHandler<IModAccessor>
public class ModAccessorInjector extends DependencyInjector<IModAccessor>
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
public static final ModAccessorHandler INSTANCE = new ModAccessorHandler(IModAccessor.class);
public static final ModAccessorInjector INSTANCE = new ModAccessorInjector(IModAccessor.class);
public ModAccessorHandler(Class<IModAccessor> newBindableInterface)
public ModAccessorInjector(Class<IModAccessor> newBindableInterface)
{
super(newBindableInterface, false);
}
/**
* Go to {@link DependencyHandler#bind(Class, IBindable)} DependencyHandler.bind()}
* Go to {@link DependencyInjector#bind(Class, IBindable)} DependencyHandler.bind()}
* for this method's javadocs.
*/
public void bind(Class<? extends IModAccessor> interfaceClass, IModAccessor modAccessor)
@@ -26,11 +26,11 @@ package com.seibel.lod.core.handlers.dependencyInjection;
* @author James Seibel
* @version 2022-7-16
*/
public class SingletonHandler extends DependencyHandler<IBindable>
public class SingletonInjector extends DependencyInjector<IBindable>
{
public static final SingletonHandler INSTANCE = new SingletonHandler(IBindable.class);
public static final SingletonInjector INSTANCE = new SingletonInjector(IBindable.class);
public SingletonHandler(Class<IBindable> newBindableInterface) { super(newBindableInterface, false); }
public SingletonInjector(Class<IBindable> newBindableInterface) { super(newBindableInterface, false); }
}
@@ -21,11 +21,10 @@ package com.seibel.lod.core.handlers.dimensionFinder;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.DHBlockPos;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import org.lwjgl.system.CallbackI;
import javax.annotation.Nullable;
import java.io.File;
@@ -38,7 +37,7 @@ import java.io.File;
*/
public class PlayerData
{
public static final IWrapperFactory FACTORY = SingletonHandler.INSTANCE.get(IWrapperFactory.class);
public static final IWrapperFactory FACTORY = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
private static final String playerDataFileName = "_playerData.toml";
@@ -1,12 +1,12 @@
package com.seibel.lod.core.jar;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.jar.wrapperInterfaces.config.ConfigWrapper;
import com.seibel.lod.core.wrapperInterfaces.config.IConfigWrapper;
public class JarDependencySetup {
public static void createInitialBindings() {
SingletonHandler.INSTANCE.bind(IConfigWrapper.class, ConfigWrapper.INSTANCE);
SingletonInjector.INSTANCE.bind(IConfigWrapper.class, ConfigWrapper.INSTANCE);
ConfigWrapper.init();
}
}
@@ -4,7 +4,7 @@ import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatLightLaf;
import com.formdev.flatlaf.extras.FlatSVGIcon;
import com.seibel.lod.core.JarMain;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.wrapperInterfaces.config.IConfigWrapper;
import javax.imageio.ImageIO;
@@ -33,7 +33,7 @@ public class BaseJFrame extends JFrame {
}
public void init() {
setTitle(SingletonHandler.INSTANCE.get(IConfigWrapper.class).getLang("lod.title"));
setTitle(SingletonInjector.INSTANCE.get(IConfigWrapper.class).getLang("lod.title"));
try {
setIconImage(new FlatSVGIcon(JarMain.accessFile("icon.svg")).getImage());
} catch (Exception e) {e.printStackTrace();}
@@ -28,7 +28,7 @@ import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.enums.config.EDropoffQuality;
import com.seibel.lod.core.enums.config.EGenerationPriority;
import com.seibel.lod.core.enums.config.EVerticalQuality;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.*;
import com.seibel.lod.core.util.DataPointUtil;
import com.seibel.lod.core.util.DetailDistanceUtil;
@@ -50,7 +50,7 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
* @version 10-10-2021
*/
public class LodRegion {
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.INSTANCE.get(ILodConfigWrapperSingleton.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonInjector.INSTANCE.get(ILodConfigWrapperSingleton.class);
/** Number of detail level supported by a region */
private static final byte POSSIBLE_LOD = LodUtil.DETAIL_OPTIONS;
@@ -332,7 +332,7 @@ public class LodRegion {
private EGenerationPriority getResolvedGenerationPriority() {
EGenerationPriority priority = Config.Client.WorldGenerator.generationPriority.get();
IMinecraftClientWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
if (priority == EGenerationPriority.AUTO)
priority = MC.hasSinglePlayerServer() ? EGenerationPriority.FAR_FIRST : EGenerationPriority.BALANCED;
return priority;
@@ -26,7 +26,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.LodDataView;
import com.seibel.lod.core.util.*;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
@@ -68,7 +68,7 @@ public class VerticalLevelContainer implements LevelContainer
size = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
verticalSize = DetailDistanceUtil.getMaxVerticalData(detailLevel);
dataContainer = new long[size * size * DetailDistanceUtil.getMaxVerticalData(detailLevel)];
minHeight = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class).getWrappedClientWorld().getMinHeight();
minHeight = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).getWrappedClientWorld().getMinHeight();
}
@Override
@@ -319,7 +319,7 @@ public class VerticalLevelContainer implements LevelContainer
}
public VerticalLevelContainer(DataInputStream inputData, int version, byte expectedDetailLevel) throws IOException {
minHeight = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class).getWrappedClientWorld().getMinHeight();
minHeight = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).getWrappedClientWorld().getMinHeight();
detailLevel = inputData.readByte();
if (detailLevel != expectedDetailLevel)
throw new IOException("Invalid Data: The expected detail level should be "+expectedDetailLevel+
@@ -21,7 +21,7 @@ package com.seibel.lod.core.objects.opengl;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodQuadBuilder;
import com.seibel.lod.core.enums.ELodDirection;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.LodDataView;
import com.seibel.lod.core.util.ColorUtil;
import com.seibel.lod.core.util.DataPointUtil;
@@ -29,7 +29,7 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
public class LodBox
{
private static final IMinecraftClientWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
public static void addBoxQuadsToBuilder(LodQuadBuilder builder, short xSize, short ySize, short zSize, short x,
short y, short z, int color, byte skyLight, byte blockLight, long topData, long botData, LodDataView[][] adjData,
@@ -42,7 +42,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.enums.config.EGpuUploadMethod;
import com.seibel.lod.core.enums.rendering.EGLProxyContext;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.util.GLMessage;
import com.seibel.lod.core.util.GLMessageOutputStream;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
@@ -68,7 +68,7 @@ public class GLProxy
{
public static final boolean OVERRIDE_VANILLA_GL_LOGGER = ModInfo.IS_DEV_BUILD;
private static final IMinecraftClientWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private ExecutorService workerThread = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat(GLProxy.class.getSimpleName() + "-Worker-Thread").build());
@@ -24,7 +24,7 @@ import com.seibel.lod.core.enums.rendering.EFogDrawMode;
import com.seibel.lod.core.enums.rendering.EFogDistance;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.handlers.IReflectionHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.FogSettings;
import com.seibel.lod.core.render.objects.Shader;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
@@ -46,8 +46,8 @@ import static com.seibel.lod.core.render.GLProxy.GL_LOGGER;
*/
public class LodFogConfig
{
private static final IReflectionHandler REFLECTION_HANDLER = SingletonHandler.INSTANCE.get(IReflectionHandler.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.INSTANCE.get(ILodConfigWrapperSingleton.class);
private static final IReflectionHandler REFLECTION_HANDLER = SingletonInjector.INSTANCE.get(IReflectionHandler.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonInjector.INSTANCE.get(ILodConfigWrapperSingleton.class);
public static final boolean DEBUG_DUMP_GENERATED_CODE = false;
@@ -21,7 +21,7 @@ package com.seibel.lod.core.render;
import java.awt.Color;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.math.Mat4f;
import com.seibel.lod.core.objects.math.Vec3f;
import com.seibel.lod.core.render.objects.*;
@@ -32,7 +32,7 @@ public class LodRenderProgram extends ShaderProgram {
public static final String VERTEX_SHADER_PATH = "shaders/standard.vert";
public static final String VERTEX_CURVE_SHADER_PATH = "shaders/curve.vert";
public static final String FRAGMENT_SHADER_PATH = "shaders/flat_shaded.frag";
private static final IVersionConstants VERSION_CONSTANTS = SingletonHandler.INSTANCE.get(IVersionConstants.class);
private static final IVersionConstants VERSION_CONSTANTS = SingletonInjector.INSTANCE.get(IVersionConstants.class);
public final VertexAttribute vao;
@@ -21,7 +21,7 @@ package com.seibel.lod.core.render;
import com.seibel.lod.core.enums.config.EGpuUploadMethod;
import com.seibel.lod.core.enums.config.ELoggerMode;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
@@ -45,7 +45,7 @@ public class RenderSystemTest {
LogManager.getLogger(RenderSystemTest.class), () -> ELoggerMode.LOG_ALL_TO_CHAT);
public static final ConfigBasedSpamLogger spamLogger = new ConfigBasedSpamLogger(
LogManager.getLogger(RenderSystemTest.class), () -> ELoggerMode.LOG_ALL_TO_CHAT, 1);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
ShaderProgram basicShader;
GLVertexBuffer sameContextBuffer;
@@ -19,7 +19,7 @@
package com.seibel.lod.core.render;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.DHBlockPos;
import com.seibel.lod.core.objects.DHChunkPos;
import com.seibel.lod.core.objects.math.Vec3f;
@@ -35,7 +35,7 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
*/
public class RenderUtil
{
private static final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
/**
@@ -25,11 +25,10 @@ import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodBufferBuilderF
import com.seibel.lod.core.config.types.ConfigEntry;
import com.seibel.lod.core.enums.rendering.EDebugMode;
import com.seibel.lod.core.enums.rendering.EFogColorMode;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
import com.seibel.lod.core.objects.DHBlockPos;
import com.seibel.lod.core.a7.level.DhClientServerLevel;
import com.seibel.lod.core.a7.render.RenderBufferHandler;
import com.seibel.lod.core.objects.math.Mat4f;
import com.seibel.lod.core.objects.math.Vec3d;
@@ -79,8 +78,8 @@ public class a7LodRenderer
}
}
private static final IMinecraftClientWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
public EDebugMode previousDebugMode = null;
public final IClientLevel level;
@@ -19,9 +19,6 @@
package com.seibel.lod.core.util;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
/**
*
* @author Cola
@@ -27,7 +27,7 @@ import java.util.concurrent.Executors;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EServerFolderNameMode;
import com.seibel.lod.core.enums.config.EVanillaOverdraw;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.DHChunkPos;
import com.seibel.lod.core.objects.ParsedIp;
import com.seibel.lod.core.objects.Pos2D;
@@ -48,8 +48,8 @@ import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
*/
public class LodUtil
{
private static final IMinecraftClientWrapper MC_CLIENT = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
/**
* Vanilla render distances less than or equal to this will not allow partial
@@ -27,7 +27,7 @@ import com.seibel.lod.core.enums.rendering.ERendererMode;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.FogSettings;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
@@ -264,7 +264,7 @@ public interface ILodConfigWrapperSingleton extends IBindable
default EGenerationPriority getResolvedGenerationPriority() {
EGenerationPriority priority = Config.Client.WorldGenerator.generationPriority.get();
IMinecraftClientWrapper MC = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
if (priority == EGenerationPriority.AUTO)
priority = MC.hasSinglePlayerServer() ? EGenerationPriority.FAR_FIRST : EGenerationPriority.BALANCED;
return priority;
@@ -23,8 +23,8 @@ import java.awt.Color;
import java.util.HashSet;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorInjector;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.objects.DHBlockPos;
import com.seibel.lod.core.objects.DHChunkPos;
import com.seibel.lod.core.objects.math.Mat4f;
@@ -85,7 +85,7 @@ public interface IMinecraftRenderWrapper extends IBindable
*/
default HashSet<DHChunkPos> getVanillaRenderedChunks()
{
ISodiumAccessor sodium = ModAccessorHandler.INSTANCE.get(ISodiumAccessor.class);
ISodiumAccessor sodium = ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class);
return sodium==null ? getMaximumRenderedChunks() : sodium.getNormalRenderedChunks();
}
@@ -101,10 +101,10 @@ public interface IMinecraftRenderWrapper extends IBindable
*/
default HashSet<DHChunkPos> getMaximumRenderedChunks()
{
IMinecraftClientWrapper mcWrapper = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
IWrapperFactory factory = SingletonHandler.INSTANCE.get(IWrapperFactory.class);
IVersionConstants versionConstants = SingletonHandler.INSTANCE.get(IVersionConstants.class);
IMinecraftClientWrapper minecraft = SingletonHandler.INSTANCE.get(IMinecraftClientWrapper.class);
IMinecraftClientWrapper mcWrapper = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
IWrapperFactory factory = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
IVersionConstants versionConstants = SingletonInjector.INSTANCE.get(IVersionConstants.class);
IMinecraftClientWrapper minecraft = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
ILevelWrapper clientWorld = minecraft.getWrappedClientWorld();
int chunkDist = this.getRenderDistance() + 1; // For some reason having '+1' is actually closer to real value