Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventManager#unregisterListeners unregisters the plugin main instance #780

Open
hevav opened this issue Jun 30, 2022 · 2 comments · May be fixed by #1211
Open

EventManager#unregisterListeners unregisters the plugin main instance #780

hevav opened this issue Jun 30, 2022 · 2 comments · May be fixed by #1211
Assignees
Labels
type: feature New feature or request

Comments

@hevav
Copy link
Contributor

hevav commented Jun 30, 2022

@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

@electronicboy
Copy link
Member

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

@4drian3d 4drian3d self-assigned this Jan 21, 2024
@4drian3d
Copy link
Contributor

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

@4drian3d 4drian3d added the type: feature New feature or request label Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants