Class EventHandler<E extends Event>
java.lang.Object
org.polyfrost.oneconfig.api.event.v1.invoke.EventHandler<E>
- Type Parameters:
E- The event type
- All Implemented Interfaces:
Comparable<EventHandler<E>>
public abstract class EventHandler<E extends Event>
extends Object
implements Comparable<EventHandler<E>>
Class which represents an event handler
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intcompareTo(@NotNull EventHandler<E> o) final booleanbooleanequals(EventHandler<?> other) intSet the priority of this event handler
Higher priority handlers are called first
The default priority is 0
Handlers with the same priority run in order of registrationabstract booleanfinal inthashCode()static <E extends Event>
EventHandler<E> static <E extends Event>
EventHandler<E> Create an event handler from a consumer in a fabric-style waystatic <E extends Event>
EventHandler<E> ofRemoving(Class<E> cls, Predicate<? super E> handler) Create an event handler from a consumer in a fabric-style wayfinal booleanonError()final EventHandler<E> register()Convenience method for registering this event handler
Equivalent toEventManager.INSTANCE.register(this)final EventHandler<E>
-
Field Details
-
ERROR_THRESHOLD
public static final byte ERROR_THRESHOLD- See Also:
-
-
Constructor Details
-
EventHandler
public EventHandler()
-
-
Method Details
-
ofRemoving
public static <E extends Event> EventHandler<E> ofRemoving(Class<E> cls, Predicate<? super E> handler) Create an event handler from a consumer in a fabric-style way- Type Parameters:
E- the event type- Parameters:
cls- the event classhandler- the predicate for the event where returning true removes the event handler- Returns:
- the event handler
-
of
Create an event handler from a consumer in a fabric-style way- Type Parameters:
E- the event type- Parameters:
cls- the event classhandler- the consumer- Returns:
- the event handler
-
of
-
handle
-
getEventClass
-
getPriority
public int getPriority()Set the priority of this event handler
Higher priority handlers are called first
The default priority is 0
Handlers with the same priority run in order of registration -
compareTo
- Specified by:
compareToin interfaceComparable<E extends Event>
-
register
Convenience method for registering this event handler
Equivalent toEventManager.INSTANCE.register(this)- Returns:
- this
-
unregister
-
onError
@Internal public final boolean onError() -
equals
-
equals
-
hashCode
public final int hashCode()
-