13
0
geforkt von Mirrors/Velocity

Merge pull request #207 from lucko/fix/event-unregister

EventManager fixes
Dieser Commit ist enthalten in:
Andrew Steinborn 2019-05-17 06:06:03 -04:00 committet von GitHub
Commit 586be46bba
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

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