rename DhApiEventInjector -> ApiEventInjector
This renaming was because the injector isn't designed to be used from the API, only internally; and externally available objects all start with "DhApi"
This commit is contained in:
@@ -5,11 +5,11 @@ import com.seibel.lod.api.interfaces.override.IDhApiOverrideable;
|
|||||||
import com.seibel.lod.api.interfaces.override.worldGenerator.IDhApiWorldGeneratorOverrideRegister;
|
import com.seibel.lod.api.interfaces.override.worldGenerator.IDhApiWorldGeneratorOverrideRegister;
|
||||||
import com.seibel.lod.api.interfaces.world.IDhApiWorldProxy;
|
import com.seibel.lod.api.interfaces.world.IDhApiWorldProxy;
|
||||||
import com.seibel.lod.api.methods.override.DhApiWorldGeneratorOverrideRegister;
|
import com.seibel.lod.api.methods.override.DhApiWorldGeneratorOverrideRegister;
|
||||||
import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
|
import com.seibel.lod.core.DependencyInjection.ApiEventInjector;
|
||||||
import com.seibel.lod.core.DependencyInjection.OverrideInjector;
|
import com.seibel.lod.core.DependencyInjection.OverrideInjector;
|
||||||
import com.seibel.lod.core.ModInfo;
|
import com.seibel.lod.core.ModInfo;
|
||||||
import com.seibel.lod.api.interfaces.data.IDhApiTerrainDataRepo;
|
import com.seibel.lod.api.interfaces.data.IDhApiTerrainDataRepo;
|
||||||
import com.seibel.lod.core.interfaces.dependencyInjection.IDhApiEventInjector;
|
import com.seibel.lod.api.interfaces.events.IDhApiEventInjector;
|
||||||
import com.seibel.lod.core.interfaces.dependencyInjection.IOverrideInjector;
|
import com.seibel.lod.core.interfaces.dependencyInjection.IOverrideInjector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +71,7 @@ public class DhApiMain
|
|||||||
// always available //
|
// always available //
|
||||||
|
|
||||||
/** Used to bind/unbind Distant Horizons Api events. */
|
/** Used to bind/unbind Distant Horizons Api events. */
|
||||||
public static final IDhApiEventInjector events = DhApiEventInjector.INSTANCE;
|
public static final IDhApiEventInjector events = ApiEventInjector.INSTANCE;
|
||||||
|
|
||||||
/** Used to bind/unbind Distant Horizons Api events. */
|
/** Used to bind/unbind Distant Horizons Api events. */
|
||||||
public static final IDhApiWorldGeneratorOverrideRegister worldGenOverrides = DhApiWorldGeneratorOverrideRegister.INSTANCE;
|
public static final IDhApiWorldGeneratorOverrideRegister worldGenOverrides = DhApiWorldGeneratorOverrideRegister.INSTANCE;
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.seibel.lod.core.interfaces.dependencyInjection;
|
package com.seibel.lod.api.interfaces.events;
|
||||||
|
|
||||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@ package com.seibel.lod.api.methods.events;
|
|||||||
|
|
||||||
import com.seibel.lod.api.objects.DhApiResult;
|
import com.seibel.lod.api.objects.DhApiResult;
|
||||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||||
import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
|
import com.seibel.lod.core.DependencyInjection.ApiEventInjector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles adding/removing event handlers.
|
* Handles adding/removing event handlers.
|
||||||
@@ -22,7 +22,7 @@ public class DhApiEventRegister
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DhApiEventInjector.INSTANCE.bind(eventInterface, eventHandlerImplementation);
|
ApiEventInjector.INSTANCE.bind(eventInterface, eventHandlerImplementation);
|
||||||
return DhApiResult.createSuccess();
|
return DhApiResult.createSuccess();
|
||||||
}
|
}
|
||||||
catch (IllegalStateException e)
|
catch (IllegalStateException e)
|
||||||
@@ -38,7 +38,7 @@ public class DhApiEventRegister
|
|||||||
*/
|
*/
|
||||||
public static DhApiResult<Void> off(Class<? extends IDhApiEvent> eventInterface, Class<IDhApiEvent> eventHandlerClass)
|
public static DhApiResult<Void> off(Class<? extends IDhApiEvent> eventInterface, Class<IDhApiEvent> eventHandlerClass)
|
||||||
{
|
{
|
||||||
if (DhApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
|
if (ApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
|
||||||
{
|
{
|
||||||
return DhApiResult.createSuccess();
|
return DhApiResult.createSuccess();
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -22,7 +22,7 @@ package com.seibel.lod.core.DependencyInjection;
|
|||||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||||
import com.seibel.lod.core.events.ApiEventDefinitionHandler;
|
import com.seibel.lod.core.events.ApiEventDefinitionHandler;
|
||||||
import com.seibel.lod.core.interfaces.dependencyInjection.IBindable;
|
import com.seibel.lod.core.interfaces.dependencyInjection.IBindable;
|
||||||
import com.seibel.lod.core.interfaces.dependencyInjection.IDhApiEventInjector;
|
import com.seibel.lod.api.interfaces.events.IDhApiEventInjector;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@@ -35,16 +35,16 @@ import java.util.HashMap;
|
|||||||
* @author James Seibel
|
* @author James Seibel
|
||||||
* @version 2022-11-20
|
* @version 2022-11-20
|
||||||
*/
|
*/
|
||||||
public class DhApiEventInjector extends DependencyInjector<IDhApiEvent> implements IDhApiEventInjector // Note to self: Don't try adding a generic type to IDhApiEvent, the consturctor won't accept it
|
public class ApiEventInjector extends DependencyInjector<IDhApiEvent> implements IDhApiEventInjector // Note to self: Don't try adding a generic type to IDhApiEvent, the consturctor won't accept it
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger(DhApiEventInjector.class.getSimpleName());
|
private static final Logger LOGGER = LogManager.getLogger(ApiEventInjector.class.getSimpleName());
|
||||||
private static final HashMap<Class<? extends IDhApiEvent>, Object> FIRED_ONE_TIME_EVENT_PARAMETERS_BY_EVENT_INTERFACE = new HashMap<>();
|
private static final HashMap<Class<? extends IDhApiEvent>, Object> FIRED_ONE_TIME_EVENT_PARAMETERS_BY_EVENT_INTERFACE = new HashMap<>();
|
||||||
|
|
||||||
public static final DhApiEventInjector INSTANCE = new DhApiEventInjector();
|
public static final ApiEventInjector INSTANCE = new ApiEventInjector();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private DhApiEventInjector() { super(IDhApiEvent.class, true); }
|
private ApiEventInjector() { super(IDhApiEvent.class, true); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package tests;
|
package tests;
|
||||||
|
|
||||||
import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
|
import com.seibel.lod.core.DependencyInjection.ApiEventInjector;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import testItems.events.abstractObjects.DhApiOneTimeTestEvent;
|
import testItems.events.abstractObjects.DhApiOneTimeTestEvent;
|
||||||
@@ -24,7 +24,7 @@ public class EventInjectorTest
|
|||||||
public void testGeneralAndRecurringEvents() // this also tests list dependencies since there can be more than one event handler bound per event
|
public void testGeneralAndRecurringEvents() // this also tests list dependencies since there can be more than one event handler bound per event
|
||||||
{
|
{
|
||||||
// Injector setup
|
// Injector setup
|
||||||
DhApiEventInjector TEST_EVENT_HANDLER = DhApiEventInjector.INSTANCE;
|
ApiEventInjector TEST_EVENT_HANDLER = ApiEventInjector.INSTANCE;
|
||||||
TEST_EVENT_HANDLER.clear();
|
TEST_EVENT_HANDLER.clear();
|
||||||
|
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class EventInjectorTest
|
|||||||
public void testOneTimeEventFiring()
|
public void testOneTimeEventFiring()
|
||||||
{
|
{
|
||||||
// Injector setup
|
// Injector setup
|
||||||
DhApiEventInjector TEST_EVENT_HANDLER = DhApiEventInjector.INSTANCE;
|
ApiEventInjector TEST_EVENT_HANDLER = ApiEventInjector.INSTANCE;
|
||||||
TEST_EVENT_HANDLER.clear();
|
TEST_EVENT_HANDLER.clear();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ package com.seibel.lod.core.api.internal;
|
|||||||
|
|
||||||
import com.seibel.lod.api.methods.events.abstractEvents.*;
|
import com.seibel.lod.api.methods.events.abstractEvents.*;
|
||||||
import com.seibel.lod.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
import com.seibel.lod.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
|
import com.seibel.lod.core.DependencyInjection.ApiEventInjector;
|
||||||
import com.seibel.lod.core.level.IDhClientLevel;
|
import com.seibel.lod.core.level.IDhClientLevel;
|
||||||
import com.seibel.lod.core.config.Config;
|
import com.seibel.lod.core.config.Config;
|
||||||
import com.seibel.lod.core.ModInfo;
|
import com.seibel.lod.core.ModInfo;
|
||||||
@@ -131,7 +131,7 @@ public class ClientApi
|
|||||||
//TODO: Implement
|
//TODO: Implement
|
||||||
|
|
||||||
// TODO: potentially add a list of chunks that were updated during the save
|
// TODO: potentially add a list of chunks that were updated during the save
|
||||||
DhApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelSaveEvent.class, new DhApiLevelSaveEvent.EventParam(level));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelSaveEvent.class, new DhApiLevelSaveEvent.EventParam(level));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ public class ClientApi
|
|||||||
if (SharedApi.currentWorld != null)
|
if (SharedApi.currentWorld != null)
|
||||||
{
|
{
|
||||||
SharedApi.currentWorld.unloadLevel(level);
|
SharedApi.currentWorld.unloadLevel(level);
|
||||||
DhApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelUnloadEvent.class, new DhApiLevelUnloadEvent.EventParam(level));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelUnloadEvent.class, new DhApiLevelUnloadEvent.EventParam(level));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ public class ClientApi
|
|||||||
if (SharedApi.currentWorld != null)
|
if (SharedApi.currentWorld != null)
|
||||||
{
|
{
|
||||||
SharedApi.currentWorld.getOrLoadLevel(level);
|
SharedApi.currentWorld.getOrLoadLevel(level);
|
||||||
DhApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelLoadEvent.class, new DhApiLevelLoadEvent.EventParam(level));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelLoadEvent.class, new DhApiLevelLoadEvent.EventParam(level));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,11 +247,11 @@ public class ClientApi
|
|||||||
RenderUtil.createLodProjectionMatrix(mcProjectionMatrix, partialTicks),
|
RenderUtil.createLodProjectionMatrix(mcProjectionMatrix, partialTicks),
|
||||||
RenderUtil.createLodModelViewMatrix(mcModelViewMatrix), partialTicks);
|
RenderUtil.createLodModelViewMatrix(mcModelViewMatrix), partialTicks);
|
||||||
|
|
||||||
boolean renderingCanceled = DhApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderEvent.class, new DhApiBeforeRenderEvent.EventParam(renderEventParam));
|
boolean renderingCanceled = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderEvent.class, new DhApiBeforeRenderEvent.EventParam(renderEventParam));
|
||||||
if (!rendererDisabledBecauseOfExceptions && !renderingCanceled)
|
if (!rendererDisabledBecauseOfExceptions && !renderingCanceled)
|
||||||
{
|
{
|
||||||
level.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, profiler);
|
level.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, profiler);
|
||||||
DhApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterRenderEvent.class, new DhApiAfterRenderEvent.EventParam(renderEventParam));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterRenderEvent.class, new DhApiAfterRenderEvent.EventParam(renderEventParam));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Config.Client.Advanced.Debugging.rendererMode.get() == ERendererMode.DEBUG)
|
else if (Config.Client.Advanced.Debugging.rendererMode.get() == ERendererMode.DEBUG)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package com.seibel.lod.core.api.internal;
|
|||||||
import com.seibel.lod.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
|
import com.seibel.lod.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
|
||||||
import com.seibel.lod.api.methods.events.abstractEvents.DhApiLevelSaveEvent;
|
import com.seibel.lod.api.methods.events.abstractEvents.DhApiLevelSaveEvent;
|
||||||
import com.seibel.lod.api.methods.events.abstractEvents.DhApiLevelUnloadEvent;
|
import com.seibel.lod.api.methods.events.abstractEvents.DhApiLevelUnloadEvent;
|
||||||
import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
|
import com.seibel.lod.core.DependencyInjection.ApiEventInjector;
|
||||||
import com.seibel.lod.core.level.IDhLevel;
|
import com.seibel.lod.core.level.IDhLevel;
|
||||||
import com.seibel.lod.core.world.DhClientServerWorld;
|
import com.seibel.lod.core.world.DhClientServerWorld;
|
||||||
import com.seibel.lod.core.world.DhServerWorld;
|
import com.seibel.lod.core.world.DhServerWorld;
|
||||||
@@ -102,7 +102,7 @@ public class ServerApi
|
|||||||
if (SharedApi.currentWorld != null)
|
if (SharedApi.currentWorld != null)
|
||||||
{
|
{
|
||||||
SharedApi.currentWorld.getOrLoadLevel(level);
|
SharedApi.currentWorld.getOrLoadLevel(level);
|
||||||
DhApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelLoadEvent.class, new DhApiLevelLoadEvent.EventParam(level));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelLoadEvent.class, new DhApiLevelLoadEvent.EventParam(level));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void serverLevelUnloadEvent(IServerLevelWrapper level) {
|
public void serverLevelUnloadEvent(IServerLevelWrapper level) {
|
||||||
@@ -110,7 +110,7 @@ public class ServerApi
|
|||||||
if (SharedApi.currentWorld != null)
|
if (SharedApi.currentWorld != null)
|
||||||
{
|
{
|
||||||
SharedApi.currentWorld.unloadLevel(level);
|
SharedApi.currentWorld.unloadLevel(level);
|
||||||
DhApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelUnloadEvent.class, new DhApiLevelUnloadEvent.EventParam(level));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelUnloadEvent.class, new DhApiLevelUnloadEvent.EventParam(level));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public class ServerApi
|
|||||||
|
|
||||||
for (IDhLevel level : SharedApi.currentWorld.getAllLoadedLevels())
|
for (IDhLevel level : SharedApi.currentWorld.getAllLoadedLevels())
|
||||||
{
|
{
|
||||||
DhApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelSaveEvent.class, new DhApiLevelSaveEvent.EventParam(level.getLevelWrapper()));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelSaveEvent.class, new DhApiLevelSaveEvent.EventParam(level.getLevelWrapper()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user