mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 23:24:39 +00:00
Fix handler invocation
This commit is contained in:
parent
9c28ceb8bf
commit
7f5cd1065d
@ -140,13 +140,19 @@ public final class PluginManager {
|
|||||||
* @param event The event to invoke.
|
* @param event The event to invoke.
|
||||||
*/
|
*/
|
||||||
public void invokeEvent(Event event) {
|
public void invokeEvent(Event event) {
|
||||||
Stream<EventHandler> handlers = this.listeners.stream()
|
EnumSet.allOf(HandlerPriority.class)
|
||||||
.filter(handler -> handler.handles().isInstance(event));
|
.forEach(priority -> this.checkAndFilter(event, priority));
|
||||||
handlers.filter(handler -> handler.getPriority() == HandlerPriority.HIGH)
|
}
|
||||||
.toList().forEach(handler -> this.invokeHandler(event, handler));
|
|
||||||
handlers.filter(handler -> handler.getPriority() == HandlerPriority.NORMAL)
|
/**
|
||||||
.toList().forEach(handler -> this.invokeHandler(event, handler));
|
* Check an event to handlers for the priority.
|
||||||
handlers.filter(handler -> handler.getPriority() == HandlerPriority.LOW)
|
* @param event The event being called.
|
||||||
|
* @param priority The priority to call for.
|
||||||
|
*/
|
||||||
|
private void checkAndFilter(Event event, HandlerPriority priority) {
|
||||||
|
this.listeners.stream()
|
||||||
|
.filter(handler -> handler.handles().isInstance(event))
|
||||||
|
.filter(handler -> handler.getPriority() == priority)
|
||||||
.toList().forEach(handler -> this.invokeHandler(event, handler));
|
.toList().forEach(handler -> this.invokeHandler(event, handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user