Skip to content

Support listener interception #87

Description

@aromaa

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);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions