mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-11-01 08:39:31 +01:00
Remove unnecessary code in EventBus
This commit is contained in:
parent
29e01878b2
commit
627ec3045c
@ -75,12 +75,11 @@ public class EventBusImpl implements EventBus {
|
|||||||
|
|
||||||
List<Throwable> suppressedMethods = new ArrayList<>();
|
List<Throwable> suppressedMethods = new ArrayList<>();
|
||||||
List<EventListenerImpl> methods = new ArrayList<>();
|
List<EventListenerImpl> methods = new ArrayList<>();
|
||||||
EnumMap<EventPriority, List<EventListenerImpl>> methodsByPriority = new EnumMap<>(EventPriority.class);
|
|
||||||
|
|
||||||
Class<?> currentClass = listenerClass;
|
Class<?> currentClass = listenerClass;
|
||||||
do {
|
do {
|
||||||
for (Method method : currentClass.getDeclaredMethods()) {
|
for (Method method : currentClass.getDeclaredMethods()) {
|
||||||
checkMethod(eventListener, listenerClass, method, suppressedMethods, methods, methodsByPriority);
|
checkMethod(eventListener, listenerClass, method, suppressedMethods, methods);
|
||||||
}
|
}
|
||||||
} while ((currentClass = currentClass.getSuperclass()) != null);
|
} while ((currentClass = currentClass.getSuperclass()) != null);
|
||||||
|
|
||||||
@ -97,8 +96,7 @@ public class EventBusImpl implements EventBus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkMethod(Object eventListener, Class<?> listenerClass, Method method,
|
private void checkMethod(Object eventListener, Class<?> listenerClass, Method method,
|
||||||
List<Throwable> suppressedMethods, List<EventListenerImpl> methods,
|
List<Throwable> suppressedMethods, List<EventListenerImpl> methods) {
|
||||||
EnumMap<EventPriority, List<EventListenerImpl>> methodsByPriority) {
|
|
||||||
Subscribe annotation = method.getAnnotation(Subscribe.class);
|
Subscribe annotation = method.getAnnotation(Subscribe.class);
|
||||||
if (annotation == null) {
|
if (annotation == null) {
|
||||||
return;
|
return;
|
||||||
@ -144,12 +142,8 @@ public class EventBusImpl implements EventBus {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventPriority eventPriority = annotation.priority();
|
|
||||||
EventListenerImpl listener = new EventListenerImpl(eventListener, listenerClass, annotation, firstParameter, method);
|
EventListenerImpl listener = new EventListenerImpl(eventListener, listenerClass, annotation, firstParameter, method);
|
||||||
|
|
||||||
methods.add(listener);
|
methods.add(listener);
|
||||||
methodsByPriority.computeIfAbsent(eventPriority, key -> new CopyOnWriteArrayList<>())
|
|
||||||
.add(listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Throwable createReasonException(String message) {
|
private Throwable createReasonException(String message) {
|
||||||
|
Loading…
Reference in New Issue
Block a user