diff --git a/api/src/main/java/com/seibel/lod/api/DhApiMain.java b/api/src/main/java/com/seibel/lod/api/DhApiMain.java
index 1d1632847..fca00a277 100644
--- a/api/src/main/java/com/seibel/lod/api/DhApiMain.java
+++ b/api/src/main/java/com/seibel/lod/api/DhApiMain.java
@@ -1,42 +1,48 @@
package com.seibel.lod.api;
+import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
+import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
import com.seibel.lod.core.ModInfo;
+import com.seibel.lod.core.interfaces.dependencyInjection.IDhApiEventInjector;
/**
* This holds API methods related to version numbers and other unchanging endpoints.
* This shouldn't change between API versions.
*
* @author James Seibel
- * @version 2022-4-27
+ * @version 2022-9-16
*/
public class DhApiMain
{
+ // only available after core initialization //
+
+ /**
+ * WARNING: will be null until after DH initializes for the first time.
+ *
+ * Use a {@link com.seibel.lod.api.methods.events.abstractEvents.DhApiAfterDhInitEvent DhApiAfterDhInitEvent}
+ * along with the {@link DhApiMain#events ApiCoreInjectors.events} to be notified when this can
+ * be safely used.
+ */
+ public static IDhApiConfig configs;
+
+
+ // always available //
+
+ /** Used to bind/unbind DH Api events. */
+ public static final IDhApiEventInjector events = DhApiEventInjector.INSTANCE;
+
+
/** This version should only be updated when breaking changes are introduced to the DH API */
- public static int getApiMajorVersion()
- {
- return ModInfo.API_MAJOR_VERSION;
- }
+ public static int getApiMajorVersion() { return ModInfo.API_MAJOR_VERSION; }
/** This version should be updated whenever new methods are added to the DH API */
- public static int getApiMinorVersion()
- {
- return ModInfo.API_MINOR_VERSION;
- }
+ public static int getApiMinorVersion() { return ModInfo.API_MINOR_VERSION; }
/** Returns the mod's version number in the format: Major.Minor.Patch */
- public static String getModVersion()
- {
- return ModInfo.VERSION;
- }
+ public static String getModVersion() { return ModInfo.VERSION; }
/** Returns true if the mod is a development version, false if it is a release version. */
- public static boolean getIsDevVersion()
- {
- return ModInfo.IS_DEV_BUILD;
- }
+ public static boolean getIsDevVersion() { return ModInfo.IS_DEV_BUILD; }
/** Returns the network protocol version. */
- public static int getNetworkProtocolVersion()
- {
- return ModInfo.PROTOCOL_VERSION;
- }
+ public static int getNetworkProtocolVersion() { return ModInfo.PROTOCOL_VERSION; }
}
diff --git a/api/src/main/java/com/seibel/lod/api/methods/events/DhApiEventRegister.java b/api/src/main/java/com/seibel/lod/api/methods/events/DhApiEventRegister.java
index 3443687e2..51ba87d9b 100644
--- a/api/src/main/java/com/seibel/lod/api/methods/events/DhApiEventRegister.java
+++ b/api/src/main/java/com/seibel/lod/api/methods/events/DhApiEventRegister.java
@@ -2,19 +2,18 @@ package com.seibel.lod.api.methods.events;
import com.seibel.lod.api.items.objects.DhApiResult;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
-import com.seibel.lod.core.interfaces.dependencyInjection.ApiCoreInjectors;
+import com.seibel.lod.api.DhApiMain;
+import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
import com.seibel.lod.core.interfaces.dependencyInjection.IDhApiEventInjector;
/**
* Handles adding/removing event handlers.
*
* @author James Seibel
- * @version 2022-9-13
+ * @version 2022-9-16
*/
public class DhApiEventRegister
{
- private static final IDhApiEventInjector EVENT_INJECTOR = ApiCoreInjectors.getInstance().events;
-
/**
* Registers the given event handler.
* Only one eventHandler of a specific class can be registered at a time.
@@ -25,7 +24,7 @@ public class DhApiEventRegister
{
try
{
- EVENT_INJECTOR.bind(eventInterface, eventHandlerImplementation);
+ DhApiEventInjector.INSTANCE.bind(eventInterface, eventHandlerImplementation);
return DhApiResult.createSuccess();
}
catch (IllegalStateException e)
@@ -41,7 +40,7 @@ public class DhApiEventRegister
*/
public static DhApiResult off(Class extends IDhApiEvent> eventInterface, Class eventHandlerClass)
{
- if (EVENT_INJECTOR.unbind(eventInterface, eventHandlerClass))
+ if (DhApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
{
return DhApiResult.createSuccess();
}
diff --git a/api/src/main/java/com/seibel/lod/core/DependencyInjection/DhApiEventInjector.java b/api/src/main/java/com/seibel/lod/core/DependencyInjection/DhApiEventInjector.java
index 873e716f5..57b9ed3ec 100644
--- a/api/src/main/java/com/seibel/lod/core/DependencyInjection/DhApiEventInjector.java
+++ b/api/src/main/java/com/seibel/lod/core/DependencyInjection/DhApiEventInjector.java
@@ -41,10 +41,7 @@ public class DhApiEventInjector extends DependencyInjector implemen
- public DhApiEventInjector()
- {
- super(IDhApiEvent.class, true);
- }
+ private DhApiEventInjector() { super(IDhApiEvent.class, true); }
@Override
diff --git a/api/src/main/java/com/seibel/lod/core/interfaces/dependencyInjection/ApiCoreInjectors.java b/api/src/main/java/com/seibel/lod/core/interfaces/dependencyInjection/ApiCoreInjectors.java
deleted file mode 100644
index e40b9724f..000000000
--- a/api/src/main/java/com/seibel/lod/core/interfaces/dependencyInjection/ApiCoreInjectors.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.seibel.lod.core.interfaces.dependencyInjection;
-
-import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
-import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
-
-/**
- * This singleton holds the dependency injectors used
- * between Core and the API.
- * IE: this is how Core and the API talk to each other.
- *
- * @author James Seibel
- * @version 2022-9-15
- */
-public class ApiCoreInjectors
-{
- private static ApiCoreInjectors INSTANCE;
-
-
-
- public final IDhApiEventInjector events = new DhApiEventInjector();
-
- /**
- * WARNING: will be null until after DH initializes for the first time.
- *
- * Use a {@link com.seibel.lod.api.methods.events.abstractEvents.DhApiAfterDhInitEvent DhApiAfterDhInitEvent}
- * along with the {@link ApiCoreInjectors#events ApiCoreInjectors.events} to be notified when this can
- * be safely used.
- */
- public IDhApiConfig configs;
-
-
- public static ApiCoreInjectors getInstance()
- {
- if (INSTANCE == null)
- {
- INSTANCE = new ApiCoreInjectors();
- }
- return INSTANCE;
- }
-
-
-}
diff --git a/api/src/main/java/com/seibel/lod/core/interfaces/dependencyInjection/IDhApiEventInjector.java b/api/src/main/java/com/seibel/lod/core/interfaces/dependencyInjection/IDhApiEventInjector.java
index 2df2d5e08..5a30ff4ab 100644
--- a/api/src/main/java/com/seibel/lod/core/interfaces/dependencyInjection/IDhApiEventInjector.java
+++ b/api/src/main/java/com/seibel/lod/core/interfaces/dependencyInjection/IDhApiEventInjector.java
@@ -27,7 +27,7 @@ import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
* @author James Seibel
* @version 2022-9-13
*/
-public interface IDhApiEventInjector extends IDependencyInjector // Note to self: Don't try adding a generic type to IDhApiEvent, the consturctor won't accept it
+public interface IDhApiEventInjector
{
/**
@@ -36,7 +36,9 @@ public interface IDhApiEventInjector extends IDependencyInjector //
* @throws IllegalArgumentException if the implementation object doesn't implement the interface
* @return true if the handler was unbound, false if the handler wasn't bound.
*/
- public boolean unbind(Class extends IDhApiEvent> dependencyInterface, Class extends IDhApiEvent> dependencyClassToRemove) throws IllegalArgumentException;
+ // Note to self: Don't try adding a generic type to IDhApiEvent, the consturctor won't accept it
+ boolean unbind(Class extends IDhApiEvent> dependencyInterface, Class extends IDhApiEvent> dependencyClassToRemove) throws IllegalArgumentException;
+
/**
* Fires all bound events of the given type (does nothing if no events are bound).
@@ -46,6 +48,6 @@ public interface IDhApiEventInjector extends IDependencyInjector //
* @return if any of the events returned that this event should be canceled.
* @param the parameter type taken by the event handlers.
*/
- public > boolean fireAllEvents(Class dependencyInterface, T eventParameterObject);
+ > boolean fireAllEvents(Class dependencyInterface, T eventParameterObject);
}
diff --git a/api/src/test/java/tests/EventInjectorTest.java b/api/src/test/java/tests/EventInjectorTest.java
index 6a2a6f126..804c74aa1 100644
--- a/api/src/test/java/tests/EventInjectorTest.java
+++ b/api/src/test/java/tests/EventInjectorTest.java
@@ -21,7 +21,7 @@ public class EventInjectorTest
public void testEventDependencies() // this also tests list dependencies since there can be more than one event handler bound per event
{
// Injector setup
- DhApiEventInjector TEST_EVENT_HANDLER = new DhApiEventInjector();
+ DhApiEventInjector TEST_EVENT_HANDLER = DhApiEventInjector.INSTANCE;
// pre-dependency setup
diff --git a/core/src/main/java/com/seibel/lod/core/Initializer.java b/core/src/main/java/com/seibel/lod/core/Initializer.java
index f8c16bd41..453c020b3 100644
--- a/core/src/main/java/com/seibel/lod/core/Initializer.java
+++ b/core/src/main/java/com/seibel/lod/core/Initializer.java
@@ -4,7 +4,7 @@ import com.seibel.lod.core.api.external.methods.config.DhApiConfig;
import com.seibel.lod.core.datatype.column.ColumnRenderLoader;
import com.seibel.lod.core.datatype.full.FullDataLoader;
import com.seibel.lod.core.datatype.full.SparseDataLoader;
-import com.seibel.lod.core.interfaces.dependencyInjection.ApiCoreInjectors;
+import com.seibel.lod.api.DhApiMain;
/**
* Handles first time Core setup.
@@ -22,7 +22,7 @@ public class Initializer
// link Core's config to the API
- ApiCoreInjectors.getInstance().configs = DhApiConfig.INSTANCE;
+ DhApiMain.configs = DhApiConfig.INSTANCE;
}
}