The entire event system in Mixson revolves around using the EventContext
. Each subsection of the wiki page will detail
a method and its purpose.
getFile
JsonElement getFile();
Returns: a modifiable JsonElement
of the resource the event is targeting.
getResourceId
Identifier getResourceId();
Returns: an Identifier
for the resource the event is acting upon. This may be different from the resourceId
specified when the event is declared due to wildcard modifiers.
getEventName
String getEventName();
Returns: a String
of the eventName
given to the event during registration.
getEvent
BuiltMixsonEvent<JsonElement> getEvent();
Returns: a BuiltMixsonEvent
for the given event. This object is used internally but can be used to retrieve
additional information such as the event uuid
.
getPriority
int getPriority();
Returns: a int
from the priority
of the given event.
getReference
BuiltResourceReference<JsonElement> getReference(String id);
Parameter "id": the id
is to be the same variable used when declaring a ResourceReference
in the referenceId
field.
Returns: a BuiltResourceReference
generated for the given event.
markForDeletion
void markForDeletion(boolean shouldDelete);
Parameter "shouldDelete": the shouldDelete
is to be a boolean value stating if the resource being acted upon
should be deleted at the end of runtime. Proceeding calls to EventContext#markForDeletion
override the previous calls.
createResource(ResourceLocation, JsonElement)
void createResource(Identifier id, JsonElement elem);
Parameter "id": the id
is to be an Identifier
for the new resource.
Parameter "elem": the elem
is to be a JsonElement
of the resource to be created.
Throws: throws IllegalCallerException
if used when processing an indexed resource.
createResource(JsonElement)
void createResource(JsonElement elem);
Parameter "elem": the elem
is to be a JsonElement
of the resource to be created.
Throws: throws IllegalCallerException
if used when processing an identified resource.
cancelFutureEvent
void cancelFutureEvent(UUID uuid);
Parameter "uuid": the uuid
of the event to be canceled for the given runtime.
registerRuntimeEvent
void registerRuntimeEvent(int priority, String resourceId, String eventName, MixsonEvent event, boolean failSilently, ResourceReference... references);
Parameters: takes in all normal values for event registration.
Runtime events are not saved with the other events and are discarded at the end of runtime.
registerDualEvent
void registerDualEvent(int priority, String resourceId, String eventName, MixsonEvent event, boolean failSilently, ResourceReference... references);
Parameters: takes in all normal values for event registration.
Dual events are both saved with the other events and are added to the runtime.
getCreationType
ContextCreationType getCreationType();
Returns: the ContextCreationType
for the given context.
ContextCreationType
ContextCreationType
is defined as follows:
public enum ContextCreationType {IDENTIFIED,INDEXED}
The type is used to determine which EventContext#createResource
is to be used.