13
0
geforkt von Mirrors/Velocity

Only unregister event handlers/listeners if the correct matching plugin is given

Currently, unregister will succeed & unregister a handler/listener if any valid plugin is given, not necessarily the one the handler was registered with.
Dieser Commit ist enthalten in:
Luck 2019-05-17 10:59:35 +01:00
Ursprung 21a79d8142
Commit 72c668c048
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EFA9B3EC5FD90F8B

Datei anzeigen

@ -161,16 +161,18 @@ public class VelocityEventManager implements EventManager {
public void unregisterListener(Object plugin, Object listener) { public void unregisterListener(Object plugin, Object listener) {
ensurePlugin(plugin); ensurePlugin(plugin);
Preconditions.checkNotNull(listener, "listener"); Preconditions.checkNotNull(listener, "listener");
registeredListenersByPlugin.remove(plugin, listener); if (registeredListenersByPlugin.remove(plugin, listener)) {
methodAdapter.unregister(listener); methodAdapter.unregister(listener);
}
} }
@Override @Override
public <E> void unregister(Object plugin, EventHandler<E> handler) { public <E> void unregister(Object plugin, EventHandler<E> handler) {
ensurePlugin(plugin); ensurePlugin(plugin);
Preconditions.checkNotNull(handler, "listener"); Preconditions.checkNotNull(handler, "listener");
registeredHandlersByPlugin.remove(plugin, handler); if (registeredHandlersByPlugin.remove(plugin, handler)) {
unregisterHandler(handler); unregisterHandler(handler);
}
} }
public boolean shutdown() throws InterruptedException { public boolean shutdown() throws InterruptedException {