Closed Technici4n closed 10 months ago
Relaying from discord:
There exists a valid usecase for reception of subclass listeners in NeoForge itself: EntityTeleportEvent
It can be fired as itself, with no additional context, or as a subclass providing additional context. Listeners often opt to receive the supertype instead of a subclass to receive all teleports.
This can be remedied by having an arbitrary context object attached to the teleport event, but is more gracefully solved through subclassing the event.
That said a means to prevent a class from being listened to (so that consumers do not accidentally listen to a parent event where this is not the intention) should be invented. To that end, only two solutions are viable:
@Unlistenable
annotation to mark unlistenable classes.The second approach is most flexible. Other approaches are not viable as the unlistenable property must be attached to the class, and introducing a static class-keyed data structure is inadvisable.
Yes, @Unlistenable
seems to be the solution.
See #21.
I don't see the use case, and it makes the implementation of
ListenerList
a lot more painful.