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;
|
||||
Reference in New Issue
Block a user