Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 13:30:17 +01:00
Merge pull request #207 from lucko/fix/event-unregister
EventManager fixes
Dieser Commit ist enthalten in:
Commit
586be46bba
@ -97,6 +97,8 @@ public class VelocityEventManager implements EventManager {
|
|||||||
Preconditions.checkNotNull(eventClass, "eventClass");
|
Preconditions.checkNotNull(eventClass, "eventClass");
|
||||||
Preconditions.checkNotNull(postOrder, "postOrder");
|
Preconditions.checkNotNull(postOrder, "postOrder");
|
||||||
Preconditions.checkNotNull(handler, "listener");
|
Preconditions.checkNotNull(handler, "listener");
|
||||||
|
|
||||||
|
registeredHandlersByPlugin.put(plugin, handler);
|
||||||
bus.register(eventClass, new KyoriToVelocityHandler<>(handler, postOrder));
|
bus.register(eventClass, new KyoriToVelocityHandler<>(handler, postOrder));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,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 {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren