public CompletableFuture < Void > accept ( T event ) { List < CompletableFuture < Void >> futures = new ArrayList <> ( listeners . size ( ) ) ; for ( ListenerHolder listener : listeners ) { if ( listener . context != null ) { futures . add ( listener . context . execute ( ( ) -> listener . listener . accept ( event ) ) ) ; } else { listener . listener . accept ( event ) ; } } return CompletableFuture . allOf ( futures . toArray ( new CompletableFuture [ futures . size ( ) ] ) ) ; }
Applies an event to all listeners .