コード例 #1
0
  public void updateStatus(L2RaidBossInstance boss, boolean isBossDead) {
    if (!_storedInfo.containsKey(boss.getNpcId())) return;

    final StatsSet info = _storedInfo.get(boss.getNpcId());

    if (isBossDead) {
      boss.setRaidStatus(StatusEnum.DEAD);

      // getRespawnMinDelay() is used as fixed timer, while getRespawnMaxDelay() is used as random
      // timer.
      final int respawnDelay =
          boss.getSpawn().getRespawnMinDelay()
              + Rnd.get(
                  -boss.getSpawn().getRespawnMaxDelay(), boss.getSpawn().getRespawnMaxDelay());
      final long respawnTime = Calendar.getInstance().getTimeInMillis() + (respawnDelay * 3600000);

      info.set("currentHP", boss.getMaxHp());
      info.set("currentMP", boss.getMaxMp());
      info.set("respawnTime", respawnTime);

      if (!_schedules.containsKey(boss.getNpcId())) {
        final Calendar time = Calendar.getInstance();
        time.setTimeInMillis(respawnTime);
        _log.info(
            "RaidBoss: "
                + boss.getName()
                + " - "
                + Util.formatDate(time.getTime(), "d MMM yyyy HH:mm")
                + " ("
                + respawnDelay
                + "h).");

        _schedules.put(
            boss.getNpcId(),
            ThreadPoolManager.getInstance()
                .scheduleGeneral(new spawnSchedule(boss.getNpcId()), respawnDelay * 3600000));
        updateDb();
      }
    } else {
      boss.setRaidStatus(StatusEnum.ALIVE);

      info.set("currentHP", boss.getCurrentHp());
      info.set("currentMP", boss.getCurrentMp());
      info.set("respawnTime", 0L);
    }

    _storedInfo.put(boss.getNpcId(), info);
  }