diff --git a/build.gradle b/build.gradle index b707758..dabdbc4 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { } } plugins { - id 'net.neoforged.gradleutils' version '3.0.0-alpha.5' + id 'net.neoforged.gradleutils' version '3.0.0-alpha.10' id 'com.github.ben-manes.versions' version '0.42.0' id 'net.neoforged.licenser' version '0.7.2' apply false } diff --git a/bus-test/src/test/java/net/neoforged/bus/test/TestNoLoader.java b/bus-test/src/test/java/net/neoforged/bus/test/TestNoLoader.java index 9c29580..60166de 100644 --- a/bus-test/src/test/java/net/neoforged/bus/test/TestNoLoader.java +++ b/bus-test/src/test/java/net/neoforged/bus/test/TestNoLoader.java @@ -88,21 +88,6 @@ public void testThreadedEventFiring() { doTest(new ThreadedListenerExceptionTest() {}); } - @Test - public void testGenericListener() { - doTest(new GenericListenerTests.Basic() {}); - } - - @Test - public void testGenericListenerRegisteredIncorrectly() { - doTest(new GenericListenerTests.IncorrectRegistration() {}); - } - - @Test - public void testGenericListenerWildcard() { - doTest(new GenericListenerTests.Wildcard() {}); - } - @Test public void testNonPublicEventHandler() { doTest(new NonPublicEventHandler() {}); diff --git a/bus-test/src/test/java/net/neoforged/bus/test/general/GenericListenerTests.java b/bus-test/src/test/java/net/neoforged/bus/test/general/GenericListenerTests.java deleted file mode 100644 index 1e4fd57..0000000 --- a/bus-test/src/test/java/net/neoforged/bus/test/general/GenericListenerTests.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) NeoForged and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.bus.test.general; - -import java.lang.reflect.Type; -import java.util.List; -import java.util.function.Supplier; - -import net.neoforged.bus.api.BusBuilder; -import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.bus.test.ITestHandler; -import org.junit.jupiter.api.Assertions; -import net.neoforged.bus.api.GenericEvent; -import net.neoforged.bus.api.IEventBus; - -import static org.junit.jupiter.api.Assertions.*; - -public abstract class GenericListenerTests implements ITestHandler { - boolean genericEventHandled = false; - protected void handleGenericEvent(GenericEvent> evt) { - genericEventHandled = true; - } - - public static class Basic extends GenericListenerTests { - @Override - public void test(Supplier builder) { - IEventBus bus = builder.get().build(); - bus.addGenericListener(List.class, this::handleGenericEvent); - bus.post(new GenericEvent>() { - public Type getGenericType() { - return List.class; - } - }); - assertTrue(genericEventHandled); - } - } - - public static class IncorrectRegistration extends GenericListenerTests { - @Override - public void test(Supplier builder) { - IEventBus bus = builder.get().build(); - Assertions.assertThrows(IllegalArgumentException.class, () -> bus.addListener(this::handleGenericEvent)); - } - } - - public static class Wildcard extends GenericListenerTests { - @Override - public void test(Supplier builder) { - IEventBus bus = builder.get().build(); - var hdl = new GenericHandler(); - bus.register(hdl); - bus.post(new GenericEvent<>()); - Assertions.assertTrue(hdl.hit, "Generic event handler was not called"); - } - } - - public static class GenericHandler { - boolean hit; - @SubscribeEvent - public void handleWildcardGeneric(GenericEvent ge) { - hit = true; - } - } -} diff --git a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/BenchmarkArmsLength.java b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/BenchmarkArmsLength.java index cc17dcb..85a607b 100644 --- a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/BenchmarkArmsLength.java +++ b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/BenchmarkArmsLength.java @@ -64,7 +64,6 @@ public static void postCombined(Object bus) private static void postAll(IEventBus bus) { bus.post(new CancellableEvent()); - bus.post(new ResultEvent()); bus.post(new EventWithData("Foo", 5, true)); //Some example data } } diff --git a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/ResultEvent.java b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/ResultEvent.java deleted file mode 100644 index 8565f72..0000000 --- a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/ResultEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) NeoForged and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.bus.benchmarks.compiled; - -import net.neoforged.bus.api.Event; - -@Event.HasResult -public class ResultEvent extends Event -{ -} diff --git a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberDynamic.java b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberDynamic.java index f0f1e5d..2aab9f3 100644 --- a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberDynamic.java +++ b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberDynamic.java @@ -10,19 +10,12 @@ public class SubscriberDynamic { - @SubscribeEvent public void onCancellableEvent(CancellableEvent event) { } - @SubscribeEvent - public void onResultEvent(ResultEvent event) - { - - } - @SubscribeEvent public void onSimpleEvent(EventWithData event) { diff --git a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberLambda.java b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberLambda.java index 76c0cf8..32ac28b 100644 --- a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberLambda.java +++ b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberLambda.java @@ -9,11 +9,9 @@ public class SubscriberLambda { - public static void register(IEventBus bus) { bus.addListener(SubscriberLambda::onCancellableEvent); - bus.addListener(SubscriberLambda::onResultEvent); bus.addListener(SubscriberLambda::onSimpleEvent); } @@ -22,11 +20,6 @@ public static void onCancellableEvent(CancellableEvent event) } - public static void onResultEvent(ResultEvent event) - { - - } - public static void onSimpleEvent(EventWithData event) { diff --git a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberStatic.java b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberStatic.java index a4ccb25..aaa6a8d 100644 --- a/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberStatic.java +++ b/bus-testjars/src/main/java/net/neoforged/bus/benchmarks/compiled/SubscriberStatic.java @@ -10,19 +10,12 @@ public class SubscriberStatic { - @SubscribeEvent public static void onCancellableEvent(CancellableEvent event) { } - @SubscribeEvent - public static void onResultEvent(ResultEvent event) - { - - } - @SubscribeEvent public static void onSimpleEvent(EventWithData event) { diff --git a/bus-testjars/src/main/java/net/neoforged/bus/testjar/DummyEvent.java b/bus-testjars/src/main/java/net/neoforged/bus/testjar/DummyEvent.java index d235492..cbf8fd5 100644 --- a/bus-testjars/src/main/java/net/neoforged/bus/testjar/DummyEvent.java +++ b/bus-testjars/src/main/java/net/neoforged/bus/testjar/DummyEvent.java @@ -12,6 +12,4 @@ public class DummyEvent extends Event { public static class GoodEvent extends DummyEvent {} public static class BadEvent extends DummyEvent {} public static class CancellableEvent extends DummyEvent implements ICancellableEvent {} - @HasResult - public static class ResultEvent extends DummyEvent {} } diff --git a/bus-testjars/src/main/java/net/neoforged/bus/testjar/EventBusTestClass.java b/bus-testjars/src/main/java/net/neoforged/bus/testjar/EventBusTestClass.java index 9497db6..46c8cb3 100644 --- a/bus-testjars/src/main/java/net/neoforged/bus/testjar/EventBusTestClass.java +++ b/bus-testjars/src/main/java/net/neoforged/bus/testjar/EventBusTestClass.java @@ -25,12 +25,6 @@ public void evtMethod3(DummyEvent.CancellableEvent evt) { } - @SubscribeEvent - public void evtMethod4(DummyEvent.ResultEvent evt) { - - } - - @SubscribeEvent public void badEventMethod(DummyEvent.BadEvent evt) { throw new RuntimeException("BARF"); diff --git a/src/main/java/net/neoforged/bus/EventBus.java b/src/main/java/net/neoforged/bus/EventBus.java index 6084b17..032c375 100644 --- a/src/main/java/net/neoforged/bus/EventBus.java +++ b/src/main/java/net/neoforged/bus/EventBus.java @@ -175,20 +175,6 @@ private Predicate passNotGenericFilter(boolean receiveCance return receiveCanceled ? null : e -> !((ICancellableEvent) e).isCanceled(); } - private , F> Predicate passGenericFilter(Class type, boolean receiveCanceled) { - return receiveCanceled ? e -> e.getGenericType() == type : e -> e.getGenericType() == type && !(e instanceof ICancellableEvent cancellable && cancellable.isCanceled()); - } - - private void checkNotGeneric(final Consumer consumer) { - checkNotGeneric(getEventClass(consumer)); - } - - private void checkNotGeneric(final Class eventType) { - if (IGenericEvent.class.isAssignableFrom(eventType)) { - throw new IllegalArgumentException("Cannot register a generic event listener with addListener, use addGenericListener"); - } - } - @Override public void addListener(final Consumer consumer) { addListener(EventPriority.NORMAL, consumer); @@ -201,7 +187,6 @@ public void addListener(final EventPriority priority, final Co @Override public void addListener(final EventPriority priority, final boolean receiveCanceled, final Consumer consumer) { - checkNotGeneric(consumer); addListener(priority, passNotGenericFilter(receiveCanceled), consumer); } @@ -227,30 +212,9 @@ public void addListener(Class eventType, Consumer consum @Override public void addListener(final EventPriority priority, final boolean receiveCanceled, final Class eventType, final Consumer consumer) { - checkNotGeneric(eventType); addListener(priority, passNotGenericFilter(receiveCanceled), eventType, consumer); } - @Override - public , F> void addGenericListener(final Class genericClassFilter, final Consumer consumer) { - addGenericListener(genericClassFilter, EventPriority.NORMAL, consumer); - } - - @Override - public , F> void addGenericListener(final Class genericClassFilter, final EventPriority priority, final Consumer consumer) { - addGenericListener(genericClassFilter, priority, false, consumer); - } - - @Override - public , F> void addGenericListener(final Class genericClassFilter, final EventPriority priority, final boolean receiveCanceled, final Consumer consumer) { - addListener(priority, passGenericFilter(genericClassFilter, receiveCanceled), consumer); - } - - @Override - public , F> void addGenericListener(final Class genericClassFilter, final EventPriority priority, final boolean receiveCanceled, final Class eventType, final Consumer consumer) { - addListener(priority, passGenericFilter(genericClassFilter, receiveCanceled), eventType, consumer); - } - @SuppressWarnings("unchecked") private Class getEventClass(Consumer consumer) { final Class eventClass = (Class) TypeResolver.resolveRawArgument(Consumer.class, consumer.getClass()); @@ -285,7 +249,7 @@ private void addListener(final EventPriority priority, @Nullab private void register(Class eventType, Object target, Method method) { - SubscribeEventListener listener = new SubscribeEventListener(target, method, IGenericEvent.class.isAssignableFrom(eventType)); + SubscribeEventListener listener = new SubscribeEventListener(target, method); addToListeners(target, eventType, listener, listener.getPriority()); } diff --git a/src/main/java/net/neoforged/bus/EventListenerHelper.java b/src/main/java/net/neoforged/bus/EventListenerHelper.java deleted file mode 100644 index 07fb303..0000000 --- a/src/main/java/net/neoforged/bus/EventListenerHelper.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.neoforged.bus; - -import net.neoforged.bus.api.Event; -import net.neoforged.bus.api.Event.HasResult; - -import java.lang.annotation.Annotation; - -public class EventListenerHelper -{ - private static final LockHelper, Boolean> hasResult = LockHelper.withIdentityHashMap(); - - public static boolean hasResult(Class eventClass) { - return hasAnnotation(eventClass, HasResult.class, hasResult); - } - - private static boolean hasAnnotation(Class eventClass, Class annotation, LockHelper, Boolean> lock) { - if (eventClass == Event.class) - return false; - - // Skip allocating lambda if possible - var result = lock.get(eventClass); - if (result != null) - return result; - - return lock.computeIfAbsent(eventClass, e -> { - var parent = eventClass.getSuperclass(); - return eventClass.isAnnotationPresent(annotation) || (parent != null && hasAnnotation(parent, annotation, lock)); - }); - } -} diff --git a/src/main/java/net/neoforged/bus/ListenerList.java b/src/main/java/net/neoforged/bus/ListenerList.java index b73cd2b..b90b3ed 100644 --- a/src/main/java/net/neoforged/bus/ListenerList.java +++ b/src/main/java/net/neoforged/bus/ListenerList.java @@ -22,7 +22,6 @@ import net.neoforged.bus.api.*; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.Semaphore; @@ -47,8 +46,8 @@ public class ListenerList { priorities.add(new ArrayList<>()); } - // Unwrap if the event is not cancellable and not generic - canUnwrapListeners = !ICancellableEvent.class.isAssignableFrom(eventClass) && !IGenericEvent.class.isAssignableFrom(eventClass); + // Unwrap if the event is not cancellable + canUnwrapListeners = !ICancellableEvent.class.isAssignableFrom(eventClass); this.buildPerPhaseList = buildPerPhaseList; } diff --git a/src/main/java/net/neoforged/bus/SubscribeEventListener.java b/src/main/java/net/neoforged/bus/SubscribeEventListener.java index f91002b..882a295 100644 --- a/src/main/java/net/neoforged/bus/SubscribeEventListener.java +++ b/src/main/java/net/neoforged/bus/SubscribeEventListener.java @@ -30,56 +30,23 @@ public final class SubscribeEventListener extends EventListener implements IWrapperListener { private final EventListener handler; private final SubscribeEvent subInfo; - private final boolean isGeneric; private String readable; - private Type filter = null; - public SubscribeEventListener(Object target, Method method, boolean isGeneric) { + public SubscribeEventListener(Object target, Method method) { handler = EventListenerFactory.create(method, target); subInfo = method.getAnnotation(SubscribeEvent.class); readable = "@SubscribeEvent: " + target + " " + method.getName() + getMethodDescriptor(method); - this.isGeneric = isGeneric; - if (isGeneric) - { - Type type = method.getGenericParameterTypes()[0]; - if (type instanceof ParameterizedType) - { - filter = ((ParameterizedType)type).getActualTypeArguments()[0]; - if (filter instanceof ParameterizedType) // Unlikely that nested generics will ever be relevant for event filtering, so discard them - { - filter = ((ParameterizedType)filter).getRawType(); - } - else if (filter instanceof WildcardType) - { - // If there's a wildcard filter of Object.class, then remove the filter. - final WildcardType wfilter = (WildcardType) filter; - if (wfilter.getUpperBounds().length == 1 && wfilter.getUpperBounds()[0] == Object.class && wfilter.getLowerBounds().length == 0) { - filter = null; - } - } - } - } } - @SuppressWarnings("rawtypes") @Override public void invoke(Event event) { if (handler != null) { - if (isGeneric) - { - if (filter == null || filter == ((IGenericEvent)event).getGenericType()) { - if (!(event instanceof ICancellableEvent cancellableEvent) || !cancellableEvent.isCanceled()) { - handler.invoke(event); - } - } - } else { - // The cast is safe because the check is removed if the event is not cancellable - if (!((ICancellableEvent) event).isCanceled()) { - handler.invoke(event); - } + // The cast is safe because the check is removed if the event is not cancellable + if (!((ICancellableEvent) event).isCanceled()) { + handler.invoke(event); } } } diff --git a/src/main/java/net/neoforged/bus/api/Event.java b/src/main/java/net/neoforged/bus/api/Event.java index 88221b3..ce324f8 100644 --- a/src/main/java/net/neoforged/bus/api/Event.java +++ b/src/main/java/net/neoforged/bus/api/Event.java @@ -1,32 +1,21 @@ /* * Minecraft Forge * Copyright (c) 2016. - * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation version 2.1 * of the License. - * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package net.neoforged.bus.api; -import net.neoforged.bus.EventListenerHelper; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - /** * Base Event class that all other events are derived from. *
@@ -42,64 +31,8 @@ *

* All the parents of abstract event classes until {@link Event} must also be abstract. */ -public abstract class Event -{ - /** - * @deprecated Use a custom type and custom methods appropriate for your event, - * instead of the overly general {@link Event.Result} enum. - * {@link Event#getResult()} and {@link Event#setResult(Result)} - * will be removed in a future version. - */ - @Deprecated(forRemoval = true) - @Retention(value = RUNTIME) - @Target(value = TYPE) - public @interface HasResult{} - - public enum Result - { - DENY, - DEFAULT, - ALLOW - } - +public abstract class Event { boolean isCanceled = false; - private Result result = Result.DEFAULT; - - protected Event() { } - - /** - * Determines if this event expects a significant result value. - */ - public final boolean hasResult() - { - return EventListenerHelper.hasResult(this.getClass()); - } - - /** - * Returns the value set as the result of this event - */ - public final Result getResult() - { - return result; - } - /** - * Sets the result value for this event, not all events can have a result set, and any attempt to - * set a result for a event that isn't expecting it will result in a IllegalArgumentException. - * - * The functionality of setting the result is defined on a per-event bases. - * - * @param value The new result - */ - public void setResult(Result value) - { - if (!hasResult()) - { - throw new UnsupportedOperationException( - "Attempted to call Event#setResult() on an event without result of type: " - + this.getClass().getCanonicalName() - ); - } - result = value; - } + protected Event() {} } diff --git a/src/main/java/net/neoforged/bus/api/GenericEvent.java b/src/main/java/net/neoforged/bus/api/GenericEvent.java deleted file mode 100644 index ed5a50b..0000000 --- a/src/main/java/net/neoforged/bus/api/GenericEvent.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.neoforged.bus.api; - -import java.lang.reflect.Type; - -/** - * Implements {@link IGenericEvent} to provide filterable events based on generic type data. - * - * Subclasses should extend this if they wish to expose a secondary type based filter (the generic type). - * - * @param The type to filter this generic event for - * @deprecated Use non-generic events instead, or another system. - */ -@Deprecated(forRemoval = true) -public class GenericEvent extends Event implements IGenericEvent -{ - private Class type; - public GenericEvent() {} - protected GenericEvent(Class type) - { - this.type = type; - } - - @Override - public Type getGenericType() - { - return type; - } -} diff --git a/src/main/java/net/neoforged/bus/api/IEventBus.java b/src/main/java/net/neoforged/bus/api/IEventBus.java index ca951c6..50b5163 100644 --- a/src/main/java/net/neoforged/bus/api/IEventBus.java +++ b/src/main/java/net/neoforged/bus/api/IEventBus.java @@ -134,70 +134,6 @@ public interface IEventBus { */ void addListener(boolean receiveCanceled, Class eventType, Consumer consumer); - /** - * Add a consumer listener for a {@link GenericEvent} subclass, filtered to only be called for the specified - * filter {@link Class}. - * - * @param genericClassFilter A {@link Class} which the {@link GenericEvent} should be filtered for - * @param consumer Callback to invoke when a matching event is received - * @param The {@link GenericEvent} subclass to listen for - * @param The {@link Class} to filter the {@link GenericEvent} for - * @deprecated Use non-generic events instead, or another system. - */ - @Deprecated(forRemoval = true) - , F> void addGenericListener(Class genericClassFilter, Consumer consumer); - - /** - * Add a consumer listener with the specified {@link EventPriority} and not receiving canceled events, - * for a {@link GenericEvent} subclass, filtered to only be called for the specified - * filter {@link Class}. - * - * @param genericClassFilter A {@link Class} which the {@link GenericEvent} should be filtered for - * @param priority {@link EventPriority} for this listener - * @param consumer Callback to invoke when a matching event is received - * @param The {@link GenericEvent} subclass to listen for - * @param The {@link Class} to filter the {@link GenericEvent} for - * @deprecated Use non-generic events instead, or another system. - */ - @Deprecated(forRemoval = true) - , F> void addGenericListener(Class genericClassFilter, EventPriority priority, Consumer consumer); - - /** - * Add a consumer listener with the specified {@link EventPriority} and potentially canceled events, - * for a {@link GenericEvent} subclass, filtered to only be called for the specified - * filter {@link Class}. - * - * @param genericClassFilter A {@link Class} which the {@link GenericEvent} should be filtered for - * @param priority {@link EventPriority} for this listener - * @param receiveCanceled Indicate if this listener should receive events that have been {@link ICancellableEvent} canceled - * @param consumer Callback to invoke when a matching event is received - * @param The {@link GenericEvent} subclass to listen for - * @param The {@link Class} to filter the {@link GenericEvent} for - * @deprecated Use non-generic events instead, or another system. - */ - @Deprecated(forRemoval = true) - , F> void addGenericListener(Class genericClassFilter, EventPriority priority, boolean receiveCanceled, Consumer consumer); - - /** - * Add a consumer listener with the specified {@link EventPriority} and potentially canceled events, - * for a {@link GenericEvent} subclass, filtered to only be called for the specified - * filter {@link Class}. - - * Use this method when one of the other methods fails to determine the concrete {@link GenericEvent} subclass that is - * intended to be subscribed to. - * - * @param genericClassFilter A {@link Class} which the {@link GenericEvent} should be filtered for - * @param priority {@link EventPriority} for this listener - * @param receiveCanceled Indicate if this listener should receive events that have been {@link ICancellableEvent} canceled - * @param eventType The concrete {@link GenericEvent} subclass to subscribe to - * @param consumer Callback to invoke when a matching event is received - * @param The {@link GenericEvent} subclass to listen for - * @param The {@link Class} to filter the {@link GenericEvent} for - * @deprecated Use non-generic events instead, or another system. - */ - @Deprecated(forRemoval = true) - , F> void addGenericListener(Class genericClassFilter, EventPriority priority, boolean receiveCanceled, Class eventType, Consumer consumer); - /** * Unregister the supplied listener from this EventBus. * diff --git a/src/main/java/net/neoforged/bus/api/IGenericEvent.java b/src/main/java/net/neoforged/bus/api/IGenericEvent.java deleted file mode 100644 index 93a00ba..0000000 --- a/src/main/java/net/neoforged/bus/api/IGenericEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.neoforged.bus.api; - -import java.lang.reflect.Type; - -/** - * Provides a generic event - one that is able to be filtered based on the supplied Generic type - * - * @param The filtering type - * @deprecated Use non-generic events instead, or another system. - */ -@Deprecated(forRemoval = true) -public interface IGenericEvent -{ - Type getGenericType(); -}