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;
|
||||
}
|
||||
|
||||
private void unregisterHandler(EventHandler<?> handler) {
|
||||
bus.unregister(s -> s instanceof KyoriToVelocityHandler &&
|
||||
((KyoriToVelocityHandler<?>) s).handler == handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterListeners(Object plugin) {
|
||||
ensurePlugin(plugin);
|
||||
Collection<Object> listeners = registeredListenersByPlugin.removeAll(plugin);
|
||||
listeners.forEach(methodAdapter::unregister);
|
||||
Collection<EventHandler<?>> handlers = registeredHandlersByPlugin.removeAll(plugin);
|
||||
handlers
|
||||
.forEach(handler -> bus.unregister(new KyoriToVelocityHandler<>(handler, PostOrder.LAST)));
|
||||
handlers.forEach(this::unregisterHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -146,7 +150,7 @@ public class VelocityEventManager implements EventManager {
|
||||
ensurePlugin(plugin);
|
||||
Preconditions.checkNotNull(handler, "listener");
|
||||
registeredHandlersByPlugin.remove(plugin, handler);
|
||||
bus.unregister(new KyoriToVelocityHandler<>(handler, PostOrder.LAST));
|
||||
unregisterHandler(handler);
|
||||
}
|
||||
|
||||
public boolean shutdown() throws InterruptedException {
|
||||
@ -196,26 +200,5 @@ public class VelocityEventManager implements EventManager {
|
||||
public int 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