fix ConcurrentModificationException in Connection::fireEvent

This commit is contained in:
Bixilon 2021-02-11 19:28:32 +01:00
parent b089ffb4a4
commit 5c1278fb72
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -193,7 +193,9 @@ public class Connection {
*/
public boolean fireEvent(ConnectionEvent connectionEvent) {
Minosoft.EVENT_MANAGERS.forEach((eventManager -> eventManager.getGlobalEventListeners().forEach((method) -> method.invoke(connectionEvent))));
this.eventListeners.forEach((method -> method.invoke(connectionEvent)));
synchronized (this.eventListeners) {
this.eventListeners.forEach((method -> method.invoke(connectionEvent)));
}
if (connectionEvent instanceof CancelableEvent cancelableEvent) {
return cancelableEvent.isCancelled();
}