diff --git a/libLauncher/src/main/java/ru/gravit/utils/event/EventManager.java b/libLauncher/src/main/java/ru/gravit/utils/event/EventManager.java index 8e33afd6..2bc6446b 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/event/EventManager.java +++ b/libLauncher/src/main/java/ru/gravit/utils/event/EventManager.java @@ -57,12 +57,14 @@ public synchronized void stop() public BlockingQueue queue = new LinkedBlockingQueue<>(QUEUE_MAX_SIZE); //Максимальный размер очереди public int registerHandler(EventHandler func, UUID[] events) { + if(isStarted.get()) throw new IllegalThreadStateException("It is forbidden to add a handler during thread operation."); Arrays.sort(events); handlers.add(new Entry(func,events)); return handlers.size(); } public void unregisterHandler(EventHandler func) { + if(isStarted.get()) throw new IllegalThreadStateException("It is forbidden to remove a handler during thread operation."); handlers.removeIf(e -> e.func.equals(func)); } public void sendEvent(UUID key, EventInterface event, boolean blocking)