Esempio n. 1
0
  public L2Clan getOwnerClan() {
    if (_ownerId == 0) return null;

    if (_ownerClan == null) _ownerClan = ClanTable.getInstance().getClan(getOwnerId());

    return _ownerClan;
  }
Esempio n. 2
0
  private void load() {
    Connection con = null;
    try {
      PreparedStatement statement;
      ResultSet rs;

      con = L2DatabaseFactory.getInstance().getConnection(con);

      statement = con.prepareStatement("SELECT * FROM fort WHERE id = ?");
      statement.setInt(1, getFortId());
      rs = statement.executeQuery();

      while (rs.next()) {
        _name = rs.getString("name");
        _siegeDate = Calendar.getInstance();
        _siegeDate.setTimeInMillis(rs.getLong("siegeDate"));
        _lastOwnedTime = rs.getLong("lastOwnedTime");
        _ownerId = rs.getInt("owner");
        _fortType = rs.getInt("fortType");
        _state = rs.getInt("state");
        _castleId = rs.getInt("castleId");
      }

      rs.close();
      statement.close();

      if (_ownerId > 0) {
        L2Clan clan = ClanTable.getInstance().getClan(_ownerId); // Try to find clan instance
        if (clan != null) {
          setOwnerClan(clan);
          clan.setHasFort(getFortId());
          ThreadPoolManager.getInstance()
              .scheduleGeneral(
                  new FortUpdater(clan, 1), 3600000); // Schedule owner tasks to start running
        } else setOwnerClan(null);
      } else setOwnerClan(null);

      if (_state == 2 && _castleId != 0) {
        Castle castle = CastleManager.getInstance().getCastleById(_castleId);
        if (castle != null) castle.addContractFort(getFortId());
      }
    } catch (Exception e) {
      _log.warn("Exception: loadFortData(): " + e.getMessage(), e);
    } finally {
      try {
        if (con != null) con.close();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }
  }