private GameTimeController() {
    _gameStartTime = getDayStartTime();

    GameServer.getInstance().addListener(new OnStartListenerImpl());

    StringBuilder msg = new StringBuilder();
    msg.append("GameTimeController: initialized.").append(" ");
    msg.append("Current time is ");
    msg.append(getGameHour()).append(":");
    if (getGameMin() < 10) msg.append("0");
    msg.append(getGameMin());
    msg.append(" in the ");
    if (isNowNight()) msg.append("night");
    else msg.append("day");
    msg.append(".");

    _log.info(msg.toString());

    long nightStart = 0;
    long dayStart = 60 * 60 * 1000;

    while (_gameStartTime + nightStart < System.currentTimeMillis())
      nightStart += 4 * 60 * 60 * 1000;

    while (_gameStartTime + dayStart < System.currentTimeMillis()) dayStart += 4 * 60 * 60 * 1000;

    dayStart -= System.currentTimeMillis() - _gameStartTime;
    nightStart -= System.currentTimeMillis() - _gameStartTime;

    ThreadPoolManager.getInstance()
        .scheduleAtFixedRate(_dayChangeNotify, nightStart, 4 * 60 * 60 * 1000L);
    ThreadPoolManager.getInstance()
        .scheduleAtFixedRate(_dayChangeNotify, dayStart, 4 * 60 * 60 * 1000L);
  }
Exemple #2
0
  @Override
  public boolean useVoicedCommand(String command, Player activeChar, String target) {
    if (!Config.ALLOW_VOICED_COMMANDS) return false;

    if (command.equals("rev") || command.equals("ver")) {
      activeChar.sendMessage("Project Revision: " + GameServer.PROJECT_REVISION);
      activeChar.sendMessage("Build Revision: beta.0.1");
      activeChar.sendMessage("Update: " + GameServer.UPDATE_NAME);
      activeChar.sendMessage("Build date: " + GameServer.getInstance().getVersion().getBuildDate());
    } else if (command.equals("date") || command.equals("time")) {
      activeChar.sendMessage(DATE_FORMAT.format(new Date(System.currentTimeMillis())));
      return true;
    }

    return false;
  }