@Override protected final void waitForBattleEndImpl() { eventManager.clearAllEvents(false); graphicsProxy.setPaintingEnabled(false); do { // Make sure remaining system events like e.g. are processed this round try { eventManager.processEvents(); // The exceptions below are expected to occur, and has already been logged in the robot // console, // but still exists in the robot's event queue. Hence we just ignore these! // Look in the HostingRobotProxy.run() to see which robot errors that are already handled. } catch (DeathException ignore) { } catch (WinException ignore) { // Bug fix [2952549] } catch (AbortedException ignore) { } catch (DisabledException ignore) { // Bug fix [2976258] } commands.setOutputText(out.readAndReset()); commands.setGraphicsCalls(graphicsProxy.readoutQueuedCalls()); // Call server execResults = peer.waitForBattleEndImpl(commands); updateStatus(execResults.getCommands(), execResults.getStatus()); // Add remaining events like BattleEndedEvent Otherwise, the robot might never receive those // events if (execResults.getEvents() != null) { for (Event event : execResults.getEvents()) { if (event instanceof BattleEndedEvent) { eventManager.add(event); } } } eventManager.resetCustomEvents(); } while (!execResults.isHalt() && execResults.isShouldWait()); }