Exemplo n.º 1
0
  private void updateOwnerInDB() {
    L2Clan clan = getOwnerClan();
    int clanId = 0;

    if (clan != null) {
      clanId = clan.getClanId();
      _lastOwnedTime = System.currentTimeMillis();
    } else _lastOwnedTime = 0;

    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement;

      statement =
          con.prepareStatement(
              "UPDATE fort SET owner=?, lastOwnedTime=?, state=?, castleId=? WHERE id = ?");
      statement.setInt(1, clanId);
      statement.setLong(2, _lastOwnedTime);
      statement.setInt(3, 0);
      statement.setInt(4, 0);
      statement.setInt(5, getFortId());
      statement.execute();
      statement.close();

      // ============================================================================
      // Announce to clan memebers
      if (clan != null) {
        clan.setHasFort(getFortId()); // Set has fort flag for new owner
        SystemMessage sm;
        sm = new SystemMessage(SystemMessageId.S1);
        sm.addString(clan.getName() + " победил в битве за форт " + getName());
        Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
        for (L2PcInstance player : pls) player.sendPacket(sm);

        clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
        clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
        ThreadPoolManager.getInstance()
            .scheduleGeneral(
                new FortUpdater(clan, 1), 3600000); // Schedule owner tasks to start running
      }
    } catch (Exception e) {
      _log.warn("Exception: updateOwnerInDB(L2Clan clan): " + e.getMessage());
      e.printStackTrace();
    } finally {
      try {
        con.close();
      } catch (Exception e) {
        _log.warn("" + e.getMessage());
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 2
0
  private void adminAtmosphere(String type, String state, L2PcInstance admin) {
    L2GameServerPacket packet = null;

    if (type.equals("signsky")) {
      if (state.equals("dawn")) packet = new SSQInfo(2);
      else if (state.equals("dusk")) packet = new SSQInfo(1);
    } else if (type.equals("sky")) {
      if (state.equals("night")) packet = SunSet.STATIC_PACKET;
      else if (state.equals("day")) packet = SunRise.STATIC_PACKET;
      else if (state.equals("red")) packet = new ExRedSky(10);
    } else admin.sendMessage("Используйте: //atmosphere <signsky dawn|dusk>|<sky day|night|red>");
    if (packet != null)
      for (L2PcInstance player : L2World.getInstance().getAllPlayers()) player.sendPacket(packet);
  }
Exemplo n.º 3
0
    public void run() {
      int currentOnline =
          (int) (L2World.getInstance().getAllPlayers().size() * Config.ONLINE_PLAYERS_MULTIPLIER);

      if (currentOnline == 1) {
        Announcements.getInstance().announceToAll("Сейчас 1 игрок в игре.");
      } else {
        Announcements.getInstance()
            .announceToAll("Сейчас " + currentOnline + " игрока(ов) в игре.");
      }
      if (Config.ONLINE_PLAYERS_ANNOUNCE_INTERVAL > 0)
        ThreadPoolManager.getInstance()
            .scheduleGeneral(new AnnounceOnline(), Config.ONLINE_PLAYERS_ANNOUNCE_INTERVAL);
    }
Exemplo n.º 4
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) {
      }
    }
  }