Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Allow the same EventHandler to be registered with different PostOrders
The #equals implementations in KyoriToVelocityHandler silently prevented this previously.
Dieser Commit ist enthalten in:
Ursprung
5b9a8f160b
Commit
43da3d4541
@ -123,14 +123,18 @@ public class VelocityEventManager implements EventManager {
|
|||||||
return eventFuture;
|
return eventFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unregisterHandler(EventHandler<?> handler) {
|
||||||
|
bus.unregister(s -> s instanceof KyoriToVelocityHandler &&
|
||||||
|
((KyoriToVelocityHandler<?>) s).handler == handler);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unregisterListeners(Object plugin) {
|
public void unregisterListeners(Object plugin) {
|
||||||
ensurePlugin(plugin);
|
ensurePlugin(plugin);
|
||||||
Collection<Object> listeners = registeredListenersByPlugin.removeAll(plugin);
|
Collection<Object> listeners = registeredListenersByPlugin.removeAll(plugin);
|
||||||
listeners.forEach(methodAdapter::unregister);
|
listeners.forEach(methodAdapter::unregister);
|
||||||
Collection<EventHandler<?>> handlers = registeredHandlersByPlugin.removeAll(plugin);
|
Collection<EventHandler<?>> handlers = registeredHandlersByPlugin.removeAll(plugin);
|
||||||
handlers
|
handlers.forEach(this::unregisterHandler);
|
||||||
.forEach(handler -> bus.unregister(new KyoriToVelocityHandler<>(handler, PostOrder.LAST)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -146,7 +150,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
ensurePlugin(plugin);
|
ensurePlugin(plugin);
|
||||||
Preconditions.checkNotNull(handler, "listener");
|
Preconditions.checkNotNull(handler, "listener");
|
||||||
registeredHandlersByPlugin.remove(plugin, handler);
|
registeredHandlersByPlugin.remove(plugin, handler);
|
||||||
bus.unregister(new KyoriToVelocityHandler<>(handler, PostOrder.LAST));
|
unregisterHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shutdown() throws InterruptedException {
|
public boolean shutdown() throws InterruptedException {
|
||||||
@ -196,26 +200,5 @@ public class VelocityEventManager implements EventManager {
|
|||||||
public int postOrder() {
|
public int postOrder() {
|
||||||
return postOrder;
|
return postOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventHandler<E> getHandler() {
|
|
||||||
return handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
KyoriToVelocityHandler<?> that = (KyoriToVelocityHandler<?>) o;
|
|
||||||
return Objects.equals(handler, that.handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(handler);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren