MCPcopy Index your code
hub / github.com/egg82/fetcharr / fetcharrEvent

Method fetcharrEvent

Webhook/src/main/java/me/egg82/fwebhook/Webhook.java:159–188  ·  view source on GitHub ↗
(@NotNull FetcharrEvent event)

Source from the content-addressed store, hash-verified

157 }
158
159 private void fetcharrEvent(@NotNull FetcharrEvent event) {
160 if (!started) {
161 // Don't handle events unless the plugin is in a "running" state
162 // ie. don't attempt to handle events before Fetcharr starts plugins or after it stops them
163 return;
164 }
165
166 WebhookAPI api = FetcharrAPIProvider.instance().registry().getFirst(WebhookAPI.class); // Be nice and let other plugins take over the API if they want to try
167 if (api == null) {
168 // Something went very wrong, and we still need an API, so fall back to one we know we control
169 logger.warn("Fetcharr registry did not return valid WebhookAPI while handling event {}", event.eventType().getName());
170 api = WebhookAPIProvider.instance();
171 }
172
173 for (WebhookDestination d : api.destinations()) {
174 try {
175 if (!d.accepts(event)) {
176 continue;
177 }
178
179 if (d.handle(event)) {
180 logger.debug("Destination {} ({}) handled event type {}", d.id(), d.type(), event.eventType().getName());
181 } else {
182 logger.debug("Destination {} ({}) did not handle event type {}", d.id(), d.type(), event.eventType().getName());
183 }
184 } catch (Exception ex) {
185 logger.warn("Destination {} ({}) threw an exception during handling of event {}", d.id(), d.type(), event.eventType().getName(), ex);
186 }
187 }
188 }
189}

Callers

nothing calls this directly

Calls 10

instanceMethod · 0.95
instanceMethod · 0.95
destinationsMethod · 0.95
getFirstMethod · 0.65
registryMethod · 0.65
eventTypeMethod · 0.65
acceptsMethod · 0.65
handleMethod · 0.65
idMethod · 0.65
typeMethod · 0.65

Tested by

no test coverage detected