mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-01 01:30:00 -04:00
Allows generic event declaration
Signed-off-by: liach <liach@users.noreply.github.com>
This commit is contained in:
parent
d2e3099f39
commit
67f1526c06
3 changed files with 5 additions and 5 deletions
fabric-api-base/src/main/java/net/fabricmc/fabric
|
@ -55,7 +55,7 @@ public final class EventFactory {
|
|||
* @param <T> The listener type.
|
||||
* @return The Event instance.
|
||||
*/
|
||||
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> invokerFactory) {
|
||||
public static <T> Event<T> createArrayBacked(Class<? super T> type, Function<T[], T> invokerFactory) {
|
||||
return EventFactoryImpl.createArrayBacked(type, invokerFactory);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,12 @@ import java.util.Arrays;
|
|||
import java.util.function.Function;
|
||||
|
||||
class ArrayBackedEvent<T> extends Event<T> {
|
||||
private final Class<T> type;
|
||||
private final Class<? super T> type;
|
||||
private final Function<T[], T> invokerFactory;
|
||||
private final T dummyInvoker;
|
||||
private T[] handlers;
|
||||
|
||||
ArrayBackedEvent(Class<T> type, T dummyInvoker, Function<T[], T> invokerFactory) {
|
||||
ArrayBackedEvent(Class<? super T> type, T dummyInvoker, Function<T[], T> invokerFactory) {
|
||||
this.type = type;
|
||||
this.dummyInvoker = dummyInvoker;
|
||||
this.invokerFactory = invokerFactory;
|
||||
|
|
|
@ -40,11 +40,11 @@ public final class EventFactoryImpl {
|
|||
ARRAY_BACKED_EVENTS.forEach(ArrayBackedEvent::update);
|
||||
}
|
||||
|
||||
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> invokerFactory) {
|
||||
public static <T> Event<T> createArrayBacked(Class<? super T> type, Function<T[], T> invokerFactory) {
|
||||
return createArrayBacked(type, null /* buildEmptyInvoker(type, invokerFactory) */, invokerFactory);
|
||||
}
|
||||
|
||||
public static <T> Event<T> createArrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> invokerFactory) {
|
||||
public static <T> Event<T> createArrayBacked(Class<? super T> type, T emptyInvoker, Function<T[], T> invokerFactory) {
|
||||
ArrayBackedEvent<T> event = new ArrayBackedEvent<>(type, emptyInvoker, invokerFactory);
|
||||
ARRAY_BACKED_EVENTS.add(event);
|
||||
return event;
|
||||
|
|
Loading…
Add table
Reference in a new issue