@Override protected EventHandler<MouseEvent> createAcceptHandler() { return mouseEvent -> { try { final IPlayer player = city.getPlayer(); final IWarehouseTenant tenant = (IWarehouseTenant) currentPerson.get(); final Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); if (optOffice.isPresent()) { ITradingOffice office = optOffice.get(); office.setOccupiedSpace(office.getOccupiedSpace() + tenant.getAmount()); int weeks = rnd.nextInt(15) + 5; LocalDateTime currentDate = date.getCurrentDate(); for (int i = 0; i < weeks; i++) { currentDate = currentDate.plusWeeks(1); TimedTask task = taskFactory.getWarehouseTenantPayment(player, tenant, currentDate); list.add(task); } TimedTask task = taskFactory.getWarehouseTenantLeaving(office, tenant, date.getCurrentDate().plusWeeks(weeks)); list.add(task); tenant.leave(); } executeOnCloseButtonClicked(); } catch (RuntimeException e) { logger.error("Failed to accept warehouse tentants offer offer", e); } }; }