Velocity
Velocity copied to clipboard
EventManager#unregisterListeners unregisters the plugin main instance
@Plugin(
id = "testplugin"
)
public class TestPlugin {
@Inject
private ProxyServer server;
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
EventManager eventManager = this.server.getEventManager();
eventManager.unregisterListeners(this);
System.out.println("test123");
}
@Subscribe
public void onProxyReload(ProxyReloadEvent event) {
System.out.println("test321");
}
}
Excepted behaviour:
- It writes
test123
on startup - It writes
test321
after/velocity reload
Current behaviour:
- It writes
test123
on startup - It doesn't write
test321
after/velocity reload
We can't register the main instance again (eventManager.registerListeners(this, this)
) as the "The plugin main instance is automatically registered." error appears
Not really sure I consider this a bug, I mean, maybe it should allow you to re-register the main class if it's been unregistered, and only then
The main class cannot be excluded from the unregistration since the method explicitly indicates that it unregisters all the listeners of the plugin. But we could allow to register the main class as a listener as electronicboy said #1211