Support listener interception

Open
#87 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Start by reviewing the EventBus registration and listener invocation paths, then compare them with the referenced SpongeEventBus implementation and its invocation wrapper. Define the interceptor service boundary and verify that Sponge can intercept listener registration or invocation without replacing the EventBus through reflection.

Written by the indexing model from the issue text.

Description

For Sponge we would like to be able to intercept either the listener registration or the invocation of it. For EB6 we are using reflection to replace the EventBus with our own implementation just to wrap the individual listener invocation with our own phase tracker system, this is not ideal.

To support our needs I'm proposing to add a service that can be implemented to provide an interceptor for this scenario. We are fine with either being able to wrap the listener function itself or the invocation of it.

The benefit of being able to wrap the registration itself is that we might be able to extract more information upfront about which mod registered the listener that we can then bake in to the wrapper function itself. This is a bit of moot point as EB doesn't require to provide any context objects like the ModInfo that we can easily rely on.

// Rough example of invocation interception.
public interface EventBusInterceptorProvider {
    Consumer<Runnable> createInvocationInterceptor(BusGroup group, EventBus<?> bus);
}
Dominant language
Java
Stars
46
Forks
39
Avg merge
2d 22h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MinecraftForge/EventBus

All issues in MinecraftForge/EventBus

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.