Move and update API Events to the API sub-project
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
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.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
import com.seibel.lod.core.api.external.items.objects.DhApiResult;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class DhApiEventRegister
|
||||
* If multiple of the same eventHandler are added DhApiResult will return
|
||||
* the name of the already added handler and success = false.
|
||||
*/
|
||||
public static DhApiResult on(Class<? extends IDhApiEvent> eventInterface, IDhApiEvent eventHandlerImplementation)
|
||||
public static DhApiResult on(Class<? extends ICoreDhApiEvent> eventInterface, ICoreDhApiEvent eventHandlerImplementation)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -36,7 +36,7 @@ public class DhApiEventRegister
|
||||
* If no eventHandler of the given class has been registered the result will return
|
||||
* success = false.
|
||||
*/
|
||||
public static DhApiResult off(Class<? extends IDhApiEvent> eventInterface, Class<IDhApiEvent> eventHandlerClass)
|
||||
public static DhApiResult off(Class<? extends ICoreDhApiEvent> eventInterface, Class<ICoreDhApiEvent> eventHandlerClass)
|
||||
{
|
||||
if (DhApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
|
||||
{
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.seibel.lod.api.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiAfterDhInitEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class DhApiAfterDhInitEvent
|
||||
extends CoreDhApiAfterDhInitEvent
|
||||
implements IDhApiEvent<Void, Void>
|
||||
{
|
||||
/** Fired after Distant Horizons finishes its initial setup on Minecraft startup. */
|
||||
public abstract void afterDistantHorizonsInit();
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.seibel.lod.api.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.lod.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.CoreDhApiRenderParam;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiAfterRenderEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class DhApiAfterRenderEvent
|
||||
extends CoreDhApiAfterRenderEvent
|
||||
implements IDhApiEvent<DhApiAfterRenderEvent.EventParam, CoreDhApiAfterRenderEvent.CoreEventParam>
|
||||
{
|
||||
/** Fired after Distant Horizons finishes rendering fake chunks. */
|
||||
public abstract void afterRender(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean fireEvent(CoreEventParam input)
|
||||
{
|
||||
afterRender(new EventParam(input));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam extends DhApiRenderParam
|
||||
{
|
||||
public EventParam(CoreEventParam dhApiRenderParam) { super(dhApiRenderParam); }
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.seibel.lod.api.methods.events.abstractEvents;
|
||||
|
||||
|
||||
|
||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiBeforeDhInitEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class DhApiBeforeDhInitEvent
|
||||
extends CoreDhApiBeforeDhInitEvent
|
||||
implements IDhApiEvent<Void, Void>
|
||||
{
|
||||
/** Fired before Distant Horizons starts its initial setup on Minecraft startup. */
|
||||
public abstract void beforeDistantHorizonsInit();
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean fireEvent(Void ignoredParam)
|
||||
{
|
||||
beforeDistantHorizonsInit();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.seibel.lod.api.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.lod.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.CoreDhApiRenderParam;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiAfterRenderEvent;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiBeforeRenderEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class DhApiBeforeRenderEvent
|
||||
extends CoreDhApiBeforeRenderEvent
|
||||
implements IDhApiEvent<DhApiBeforeRenderEvent.EventParam, CoreDhApiBeforeRenderEvent.CoreEventParam>
|
||||
{
|
||||
/**
|
||||
* Fired before Distant Horizons renders fake chunks.
|
||||
*
|
||||
* @return whether the event should be canceled or not.
|
||||
*/
|
||||
public abstract boolean beforeRender(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean fireEvent(CoreEventParam input) { return beforeRender(new EventParam(input)); }
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return true; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam extends DhApiRenderParam
|
||||
{
|
||||
public EventParam(CoreEventParam dhApiRenderParam) { super(dhApiRenderParam); }
|
||||
}
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.seibel.lod.api.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiLevelLoadEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class DhApiLevelLoadEvent
|
||||
extends CoreDhApiLevelLoadEvent
|
||||
implements IDhApiEvent<DhApiLevelLoadEvent.EventParam, CoreDhApiLevelLoadEvent.CoreEventParam>
|
||||
{
|
||||
/** Fired after Distant Horizons loads a new level. */
|
||||
public abstract void onLevelLoad(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean fireEvent(CoreEventParam input)
|
||||
{
|
||||
onLevelLoad(new EventParam());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam
|
||||
{
|
||||
/** The newly loaded level. */
|
||||
//public final IDhApiLevelWrapper levelWrapper;
|
||||
|
||||
|
||||
// TODO
|
||||
//public EventParam(ILevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.seibel.lod.api.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiLevelSaveEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class DhApiLevelSaveEvent
|
||||
extends CoreDhApiLevelSaveEvent
|
||||
implements IDhApiEvent<DhApiLevelSaveEvent.EventParam, CoreDhApiLevelSaveEvent.CoreEventParam>
|
||||
{
|
||||
/** Fired after Distant Horizons saves LOD data for the server. */
|
||||
public abstract void onLevelSave(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean fireEvent(CoreDhApiLevelSaveEvent.CoreEventParam input)
|
||||
{
|
||||
onLevelSave(new EventParam());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam
|
||||
{
|
||||
/** The newly loaded level. */
|
||||
//public final IDhApiLevelWrapper levelWrapper;
|
||||
|
||||
// TODO
|
||||
//public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
|
||||
}
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.seibel.lod.api.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiLevelUnloadEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class DhApiLevelUnloadEvent
|
||||
extends CoreDhApiLevelUnloadEvent
|
||||
implements IDhApiEvent<DhApiLevelUnloadEvent.EventParam, CoreDhApiLevelUnloadEvent.CoreEventParam>
|
||||
{
|
||||
/** Fired before Distant Horizons unloads a level. */
|
||||
public abstract void onLevelUnload(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean fireEvent(CoreDhApiLevelUnloadEvent.CoreEventParam input)
|
||||
{
|
||||
onLevelUnload(new EventParam());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam
|
||||
{
|
||||
/** The recently unloaded level. */
|
||||
// public final IDhApiLevelWrapper levelWrapper;
|
||||
|
||||
|
||||
// TODO
|
||||
// public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.seibel.lod.api.methods.events.interfaces;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
|
||||
|
||||
/**
|
||||
* A combination of all interfaces required by all
|
||||
* DH Api events.
|
||||
*
|
||||
* @param <ApiInputType> This is the datatype that will be passed into the
|
||||
* event handler's method.
|
||||
* @param <CoreInputType> This is the datatype that will be passed in from Core
|
||||
* when the event is fired.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public interface IDhApiEvent<ApiInputType, CoreInputType> extends ICoreDhApiEvent<CoreInputType>, IBindable
|
||||
{
|
||||
/**
|
||||
* Returns if the event should be automatically unbound
|
||||
* after firing. <br>
|
||||
* Can be useful for one time setup events or waiting for a specific game state. <br> <Br>
|
||||
*
|
||||
* Defaults to False (the event will not be removed after firing).
|
||||
*/
|
||||
@Override
|
||||
default boolean removeAfterFiring() { return false; };
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.seibel.lod.api.items.objects.events;
|
||||
package com.seibel.lod.api.methods.events.sharedParameterObjects;
|
||||
|
||||
import com.seibel.lod.api.items.objects.math.DhApiMat4f;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.CoreDhApiRenderParam;
|
||||
@@ -21,7 +21,6 @@ package com.seibel.lod.core.api.internal.a7;
|
||||
|
||||
import com.seibel.lod.core.a7.level.IClientLevel;
|
||||
import com.seibel.lod.core.a7.world.*;
|
||||
import com.seibel.lod.core.api.external.methods.events.abstractEvents.*;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.CoreDhApiRenderParam;
|
||||
import com.seibel.lod.core.api.implementation.wrappers.DhApiLevelWrapper;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.seibel.lod.core.api.external.methods.events.abstractEvents.DhApiLevel
|
||||
import com.seibel.lod.core.api.implementation.wrappers.DhApiLevelWrapper;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.logging.ConfigBasedLogger;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class CoreDhApiAfterDhInitEvent implements ICoreDhApiEvent<Void>
|
||||
{
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.CoreDhApiRenderParam;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class CoreDhApiAfterRenderEvent implements ICoreDhApiEvent<CoreDhApiAfterRenderEvent.CoreEventParam>
|
||||
{
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class CoreEventParam extends CoreDhApiRenderParam
|
||||
{
|
||||
public CoreEventParam(CoreDhApiRenderParam dhApiRenderParam)
|
||||
{
|
||||
super(dhApiRenderParam.mcProjectionMatrix, dhApiRenderParam.mcModelViewMatrix,
|
||||
dhApiRenderParam.dhProjectionMatrix, dhApiRenderParam.dhModelViewMatrix,
|
||||
dhApiRenderParam.partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class CoreDhApiBeforeDhInitEvent implements ICoreDhApiEvent<Void>
|
||||
{
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.CoreDhApiRenderParam;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class CoreDhApiBeforeRenderEvent implements ICoreDhApiEvent<CoreDhApiBeforeRenderEvent.CoreEventParam>
|
||||
{
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class CoreEventParam extends CoreDhApiRenderParam
|
||||
{
|
||||
public CoreEventParam(CoreDhApiRenderParam dhApiRenderParam)
|
||||
{
|
||||
super(dhApiRenderParam.mcProjectionMatrix, dhApiRenderParam.mcModelViewMatrix,
|
||||
dhApiRenderParam.dhProjectionMatrix, dhApiRenderParam.dhModelViewMatrix,
|
||||
dhApiRenderParam.partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class CoreDhApiLevelLoadEvent implements ICoreDhApiEvent<CoreDhApiLevelLoadEvent.CoreEventParam>
|
||||
{
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class CoreEventParam
|
||||
{
|
||||
/** The newly loaded level. */
|
||||
public final ILevelWrapper levelWrapper;
|
||||
|
||||
|
||||
public CoreEventParam(ILevelWrapper newLevelWrapper)
|
||||
{
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class CoreDhApiLevelSaveEvent implements ICoreDhApiEvent<CoreDhApiLevelSaveEvent.CoreEventParam>
|
||||
{
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class CoreEventParam
|
||||
{
|
||||
/** The newly loaded level. */
|
||||
public final ILevelWrapper levelWrapper;
|
||||
|
||||
|
||||
public CoreEventParam(ILevelWrapper newLevelWrapper)
|
||||
{
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public abstract class CoreDhApiLevelUnloadEvent implements ICoreDhApiEvent<CoreDhApiLevelUnloadEvent.CoreEventParam>
|
||||
{
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class CoreEventParam
|
||||
{
|
||||
/** The recently unloaded level. */
|
||||
public final ILevelWrapper levelWrapper;
|
||||
|
||||
|
||||
public CoreEventParam(ILevelWrapper newLevelWrapper)
|
||||
{
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-7-17
|
||||
*/
|
||||
public abstract class DhApiAfterDhInitEvent implements IDhApiEvent<Void>
|
||||
{
|
||||
/** Fired after Distant Horizons finishes its initial setup on Minecraft startup. */
|
||||
public abstract void afterDistantHorizonsInit();
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean onEvent(Void ignoredParam)
|
||||
{
|
||||
afterDistantHorizonsInit();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.CoreDhApiRenderParam;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-8-21
|
||||
*/
|
||||
public abstract class DhApiAfterRenderEvent implements IDhApiEvent<DhApiAfterRenderEvent.EventParam>
|
||||
{
|
||||
/** Fired after Distant Horizons finishes rendering fake chunks. */
|
||||
public abstract void afterRender(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean onEvent(EventParam input)
|
||||
{
|
||||
afterRender(input);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam extends CoreDhApiRenderParam
|
||||
{
|
||||
public EventParam(CoreDhApiRenderParam dhApiRenderParam)
|
||||
{
|
||||
super(dhApiRenderParam.mcProjectionMatrix, dhApiRenderParam.mcModelViewMatrix,
|
||||
dhApiRenderParam.dhProjectionMatrix, dhApiRenderParam.dhModelViewMatrix,
|
||||
dhApiRenderParam.partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-7-17
|
||||
*/
|
||||
public abstract class DhApiBeforeDhInitEvent implements IDhApiEvent<Void>
|
||||
{
|
||||
/** Fired before Distant Horizons starts its initial setup on Minecraft startup. */
|
||||
public abstract void beforeDistantHorizonsInit();
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean onEvent(Void ignoredParam)
|
||||
{
|
||||
beforeDistantHorizonsInit();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.events.CoreDhApiRenderParam;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-8-21
|
||||
*/
|
||||
public abstract class DhApiBeforeRenderEvent implements IDhApiEvent<DhApiBeforeRenderEvent.EventParam>
|
||||
{
|
||||
/**
|
||||
* Fired before Distant Horizons renders fake chunks.
|
||||
*
|
||||
* @return whether the event should be canceled or not.
|
||||
*/
|
||||
public abstract boolean beforeRender(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean onEvent(EventParam input)
|
||||
{
|
||||
return beforeRender(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return true; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam extends CoreDhApiRenderParam
|
||||
{
|
||||
public EventParam(CoreDhApiRenderParam dhApiRenderParam)
|
||||
{
|
||||
super(dhApiRenderParam.mcProjectionMatrix, dhApiRenderParam.mcModelViewMatrix,
|
||||
dhApiRenderParam.dhProjectionMatrix, dhApiRenderParam.dhModelViewMatrix,
|
||||
dhApiRenderParam.partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-7-17
|
||||
*/
|
||||
public abstract class DhApiLevelLoadEvent implements IDhApiEvent<DhApiLevelLoadEvent.EventParam>
|
||||
{
|
||||
/** Fired after Distant Horizons loads a new level. */
|
||||
public abstract void levelLoad(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean onEvent(EventParam input)
|
||||
{
|
||||
levelLoad(input);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam
|
||||
{
|
||||
/** The newly loaded level. */
|
||||
public final IDhApiLevelWrapper levelWrapper;
|
||||
|
||||
|
||||
public EventParam(IDhApiLevelWrapper newLevelWrapper)
|
||||
{
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-8-23
|
||||
*/
|
||||
public abstract class DhApiLevelSaveEvent implements IDhApiEvent<DhApiLevelSaveEvent.EventParam>
|
||||
{
|
||||
/** Fired after Distant Horizons saves LOD data for the server. */
|
||||
public abstract void save(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean onEvent(EventParam input)
|
||||
{
|
||||
save(input);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam
|
||||
{
|
||||
/** The newly loaded level. */
|
||||
public final IDhApiLevelWrapper levelWrapper;
|
||||
|
||||
|
||||
public EventParam(IDhApiLevelWrapper newLevelWrapper)
|
||||
{
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-8-23
|
||||
*/
|
||||
public abstract class DhApiLevelUnloadEvent implements IDhApiEvent<DhApiLevelUnloadEvent.EventParam>
|
||||
{
|
||||
/** Fired before Distant Horizons unloads a level. */
|
||||
public abstract void levelUnload(EventParam input);
|
||||
|
||||
|
||||
//=========================//
|
||||
// internal DH API methods //
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean onEvent(EventParam input)
|
||||
{
|
||||
levelUnload(input);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getCancelable() { return false; }
|
||||
|
||||
|
||||
//==================//
|
||||
// parameter object //
|
||||
//==================//
|
||||
|
||||
public static class EventParam
|
||||
{
|
||||
/** The recently unloaded level. */
|
||||
public final IDhApiLevelWrapper levelWrapper;
|
||||
|
||||
|
||||
public EventParam(IDhApiLevelWrapper newLevelWrapper)
|
||||
{
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.seibel.lod.core.api.implementation.interfaces.events;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
|
||||
|
||||
/**
|
||||
* A combination of all interfaces required by all
|
||||
* DH Api events.
|
||||
*
|
||||
* @param <CoreInputType> This is the datatype that will be passed in from Core
|
||||
* when the event is fired.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-9-6
|
||||
*/
|
||||
public interface ICoreDhApiEvent<CoreInputType> extends IBindable
|
||||
{
|
||||
//==========//
|
||||
// internal //
|
||||
//==========//
|
||||
|
||||
/** Returns true if the event can be canceled. */
|
||||
boolean getCancelable();
|
||||
|
||||
/**
|
||||
* Called internally by Distant Horizons when the event happens.
|
||||
* This method shouldn't directly be overridden and
|
||||
* should call a more specific method instead.
|
||||
*
|
||||
* @param input the parameter object passed in from the event source. Can be null.
|
||||
* @return whether the event should be canceled or not.
|
||||
* A canceled event will still fire the other event handlers that are queued.
|
||||
*/
|
||||
boolean fireEvent(CoreInputType input);
|
||||
|
||||
|
||||
|
||||
//==========//
|
||||
// external //
|
||||
//==========//
|
||||
|
||||
/**
|
||||
* Returns if the event should be automatically unbound
|
||||
* after firing. <br>
|
||||
* Can be useful for one time setup events or waiting for a specific game state. <br> <Br>
|
||||
*
|
||||
* Defaults to False (the event will not be removed after firing).
|
||||
*/
|
||||
boolean removeAfterFiring();
|
||||
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package com.seibel.lod.core.api.implementation.interfaces.events;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
|
||||
|
||||
/**
|
||||
* A combination of all interfaces required by
|
||||
* DH Api events.
|
||||
*
|
||||
* @param <InputType> This is the datatype that should be passed into the
|
||||
* event handler's method.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-7-16
|
||||
*/
|
||||
public interface IDhApiEvent<InputType> extends IDhApiEventExternal<InputType>, IDhApiEventInternal<InputType>, IBindable
|
||||
{
|
||||
// Don't add any methods here.
|
||||
// Add them to: IDhApiEventExternal or IDhApiEventInternal
|
||||
// (depending on if they should be available to
|
||||
// implementing developers or only DH devs)
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.seibel.lod.core.api.implementation.interfaces.events;
|
||||
|
||||
/**
|
||||
* Contains any methods that can be implemented by
|
||||
* mod developers that wish to register events with the DH Api. <br> <br>
|
||||
*
|
||||
* All Api events should implement this.
|
||||
*
|
||||
* @param <InputType> This is the datatype that should be passed into the
|
||||
* event handler's method.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-7-16
|
||||
*/
|
||||
public interface IDhApiEventExternal<InputType> extends IDhApiEventInternal<InputType>
|
||||
{
|
||||
/**
|
||||
* Returns if the event should be automatically unbound
|
||||
* after firing. <br>
|
||||
* Can be useful for one time setup events or waiting for a specific game state. <br> <Br>
|
||||
*
|
||||
* Defaults to False (the event will not be removed after firing).
|
||||
*/
|
||||
default boolean removeAfterFiring() { return false; };
|
||||
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.seibel.lod.core.api.implementation.interfaces.events;
|
||||
|
||||
/**
|
||||
* Contains methods that should only be used internally
|
||||
* by Distant Horizons and should all be locked with
|
||||
* the "final" keyword. <br>
|
||||
* (IE: whether an event is cancelable or not should only be defined by the DH API) <br> <br>
|
||||
*
|
||||
* All Api events should implement this.
|
||||
*
|
||||
* @param <InputType> This is the datatype that should be passed into the
|
||||
* event handler's method.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-7-16
|
||||
*/
|
||||
public interface IDhApiEventInternal<InputType>
|
||||
{
|
||||
/** Returns true if the event can be canceled. */
|
||||
boolean getCancelable();
|
||||
|
||||
/**
|
||||
* Called internally by Distant Horizons when the event happens.
|
||||
* This method shouldn't directly be overridden and instead
|
||||
* should point to the more specific event method.
|
||||
*
|
||||
* @param input the parameter object passed in from the event source. Can be null.
|
||||
* @return whether the event should be canceled or not.
|
||||
* A canceled event will still fire the other event handlers that are queued.
|
||||
*/
|
||||
boolean onEvent(InputType input);
|
||||
|
||||
}
|
||||
+8
-8
@@ -19,7 +19,7 @@
|
||||
|
||||
package com.seibel.lod.core.handlers.dependencyInjection;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.util.ArrayList;
|
||||
* @author Leetom
|
||||
* @version 2022-8-15
|
||||
*/
|
||||
public class DhApiEventInjector extends DependencyInjector<IDhApiEvent> // Note to self: Don't try adding a generic type to IDhApiEvent, the consturctor won't accept it
|
||||
public class DhApiEventInjector extends DependencyInjector<ICoreDhApiEvent> // 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());
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DhApiEventInjector extends DependencyInjector<IDhApiEvent> // Note
|
||||
|
||||
public DhApiEventInjector()
|
||||
{
|
||||
super(IDhApiEvent.class, true);
|
||||
super(ICoreDhApiEvent.class, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class DhApiEventInjector extends DependencyInjector<IDhApiEvent> // Note
|
||||
* @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
|
||||
public boolean unbind(Class<? extends ICoreDhApiEvent> dependencyInterface, Class<? extends ICoreDhApiEvent> dependencyClassToRemove) throws IllegalArgumentException
|
||||
{
|
||||
// make sure the given dependency implements the necessary interfaces
|
||||
boolean implementsInterface = checkIfClassImplements(dependencyClassToRemove, dependencyInterface)
|
||||
@@ -77,7 +77,7 @@ public class DhApiEventInjector extends DependencyInjector<IDhApiEvent> // Note
|
||||
// actually remove the dependency
|
||||
if (this.dependencies.containsKey(dependencyInterface))
|
||||
{
|
||||
ArrayList<IDhApiEvent> dependencyList = this.dependencies.get(dependencyInterface);
|
||||
ArrayList<ICoreDhApiEvent> dependencyList = this.dependencies.get(dependencyInterface);
|
||||
int indexToRemove = -1;
|
||||
for(int i = 0; i < dependencyList.size(); i++)
|
||||
{
|
||||
@@ -107,12 +107,12 @@ public class DhApiEventInjector extends DependencyInjector<IDhApiEvent> // Note
|
||||
* @return if any of the events returned that this event should be canceled.
|
||||
* @param <T> the parameter type taken by the event handlers.
|
||||
*/
|
||||
public <T, U extends IDhApiEvent<T>> boolean fireAllEvents(Class<U> dependencyInterface, T eventParameterObject)
|
||||
public <T, U extends ICoreDhApiEvent<T>> boolean fireAllEvents(Class<U> dependencyInterface, T eventParameterObject)
|
||||
{
|
||||
boolean cancelEvent = false;
|
||||
|
||||
ArrayList<U> eventList = this.getAll(dependencyInterface);
|
||||
for (IDhApiEvent<T> event : eventList)
|
||||
for (ICoreDhApiEvent<T> event : eventList)
|
||||
{
|
||||
if (event != null)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ public class DhApiEventInjector extends DependencyInjector<IDhApiEvent> // Note
|
||||
{
|
||||
// fire each event and record if any of them
|
||||
// request to cancel the event.
|
||||
cancelEvent |= event.onEvent(eventParameterObject);
|
||||
cancelEvent |= event.fireEvent(eventParameterObject);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package testItems.eventInjection.abstractObjects;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.ICoreDhApiEvent;
|
||||
|
||||
/**
|
||||
* A dummy event implementation used for unit testing.
|
||||
@@ -8,7 +8,7 @@ import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
* @author James Seibel
|
||||
* @version 2022-7-16
|
||||
*/
|
||||
public abstract class DhApiTestEvent implements IDhApiEvent<Boolean>
|
||||
public abstract class DhApiTestEvent implements ICoreDhApiEvent<Boolean>
|
||||
{
|
||||
/**
|
||||
* Test event.
|
||||
@@ -30,7 +30,7 @@ public abstract class DhApiTestEvent implements IDhApiEvent<Boolean>
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final boolean onEvent(Boolean input)
|
||||
public final boolean fireEvent(Boolean input)
|
||||
{
|
||||
return test(input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user