Exemplo n.º 1
0
  private void getFriendList() {
    Connection con = null;

    try {
      String sqlQuery =
          "SELECT friendId, friend_name FROM character_friends WHERE "
              + "charId="
              + _activeChar.getObjectId()
              + " ORDER BY friend_name ASC";

      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement = con.prepareStatement(sqlQuery);
      ResultSet rset = statement.executeQuery(sqlQuery);

      int friendId;
      String friendName;
      FriendStatus fs;
      while (rset.next()) {
        friendId = rset.getInt("friendId");
        friendName = rset.getString("friend_name");

        if (friendId == _activeChar.getObjectId()) continue;

        L2PcInstance friend = L2World.getInstance().getPlayer(friendName);

        fs = new FriendStatus(0x00030b7a, friendId, friendName, friend != null);
        _friends.add(fs);
      }

      rset.close();
      statement.close();
    } catch (Exception e) {
      _log.warn("Error found in " + _activeChar.getName() + "'s FriendList: " + e);
    } finally {
      try {
        con.close();
      } catch (Exception e) {
      }
    }
  }