And handle event exceptions

This commit is contained in:
LeoDog896 2021-04-06 22:29:24 -04:00
parent 512ec8dcbc
commit 5e4af20992

View File

@ -109,6 +109,8 @@ public interface EventHandler extends IExtensionObserver {
*/
default <E extends Event> void callEvent(@NotNull Class<E> eventClass, @NotNull E event) {
try {
// Global listeners
if (!(this instanceof GlobalEventHandler)) {
final GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
@ -126,6 +128,9 @@ public interface EventHandler extends IExtensionObserver {
runEvent(instance.getEventCallbacks(eventClass), event);
}
}
} catch (Exception exception) {
MinecraftServer.getExceptionManager().handleException(exception);
}
}
/**