Example #1
0
 private void scheduleTimer() {
   final int gameTime = GameTimeController.getInstance().getGameTime();
   final int hours = (gameTime / 60) % 24;
   final int minutes = gameTime % 60;
   int hourDiff, minDiff;
   hourDiff = (20 - hours);
   if (hourDiff < 0) {
     hourDiff = 24 - (hourDiff *= -1);
   }
   minDiff = (30 - minutes);
   if (minDiff < 0) {
     minDiff = 60 - (minDiff *= -1);
   }
   long diff;
   hourDiff *= 3600000;
   minDiff *= 60000;
   diff = hourDiff + minDiff;
   if (Config.DEBUG) {
     final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
     _log.info(
         "Fantasy Isle: MC show script starting at "
             + format.format(System.currentTimeMillis() + diff)
             + " and is scheduled each next 4 hours.");
   }
   // TODO startRepeatingQuestTimer("Start", diff, 14400000, null, null);
   // missing option to provide different initial delay
   ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new StartMCShow(), diff, 14400000L);
 }
Example #2
0
 public void restartRestockTask(long nextRestockTime) {
   final long remainTime = nextRestockTime - System.currentTimeMillis();
   if (remainTime > 0) {
     _restockTask = ThreadPoolManager.getInstance().scheduleGeneral(new RestockTask(), remainTime);
   } else {
     restock();
   }
 }
Example #3
0
 public boolean decreaseCount(long val) {
   if (_count == null) {
     return false;
   }
   if ((_restockTask == null) || _restockTask.isDone()) {
     _restockTask =
         ThreadPoolManager.getInstance().scheduleGeneral(new RestockTask(), getRestockDelay());
   }
   final boolean result = _count.addAndGet(-val) >= 0;
   save();
   return result;
 }