MCPcopy Create free account
hub / github.com/Hypejet/Jet / call

Method call

api/src/main/java/net/hypejet/jet/event/node/EventNode.java:218–236  ·  view source on GitHub ↗

Calls all plain EventListener event listeners including those from plain EventNode children event nodes of this event node with an event specified. @param event the event to pass as an argument of the calls @return this event node @since 1.0

(@NonNull E event)

Source from the content-addressed store, hash-verified

216 * @since 1.0
217 */
218 public @NonNull EventNode<E> call(@NonNull E event) {
219 if (!this.eventClass.isAssignableFrom(event.getClass())) {
220 throw new IllegalArgumentException("You cannot call an event in an event node, of which event class is" +
221 " not assignable from an event class of the event");
222 }
223
224 try (CollectionAcquisition<EventListener<? extends E>, ?> listenersAcquisition = this.listeners.acquireRead();
225 CollectionAcquisition<EventNode<? extends E>, ?> childrenAcquisition = this.children.acquireRead()) {
226 List<EventListener<? extends E>> copiedListeners = new ArrayList<>(listenersAcquisition.collection());
227 Collections.sort(copiedListeners);
228 copiedListeners.forEach(listener -> this.callListener(listener, event));
229
230 List<EventNode<? extends E>> copiedChildren = new ArrayList<>(childrenAcquisition.collection());
231 Collections.sort(copiedChildren);
232 copiedChildren.forEach(node -> this.callChild(node, event));
233 }
234
235 return this;
236 }
237
238 /**
239 * Creates {@linkplain CollectionAcquisition a collection acquisition} of listeners that were registered to this

Callers 15

testCallingMethod · 0.95
callListenerMethod · 0.45
callChildMethod · 0.45
JetMinecraftServerMethod · 0.45
createShutdownThreadMethod · 0.45
putMethod · 0.45
executeMethod · 0.45
runVirtualThreadTaskMethod · 0.45
runVirtualThreadTaskMethod · 0.45
handleMethod · 0.45
handleMethod · 0.45

Calls 4

callListenerMethod · 0.95
callChildMethod · 0.95
collectionMethod · 0.80
forEachMethod · 0.80

Tested by 1

testCallingMethod · 0.76