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
  public final void scheduleEffect() {
    if (_state == EffectState.CREATED) {
      if (_skill.isActive() && _skill.getName().startsWith("Item Skill")) {
        if (_effected._itemActiveSkill != null) _effected._itemActiveSkill.exit();
        _effected._itemActiveSkill = this;
      }

      _state = EffectState.ACTING;

      if (_skill.isPvpSkill()) {
        SystemMessage smsg = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
        smsg.addSkillName(_skill);
        getEffected().sendPacket(smsg);
      }

      if (_count > 1) {
        startEffectTaskAtFixedRate(5, _period * 1000);
        return;
      }

      if (_period > 0) {
        startEffectTask(_period * 1000);
        return;
      }
      // effects not having count or period should start
      setInUse(true);
    }

    if (_state == EffectState.ACTING) {
      if (_count-- > 0) {
        if (getInUse()) // effect has to be in use
        {
          if (onActionTime() && _startConditionsCorrect)
            return; // false causes effect to finish right away
        } else if (_count > 0) // do not finish it yet, in case reactivated
        return;
      }
      _state = EffectState.FINISHING;
    }

    if (_state == EffectState.FINISHING) {
      if (getInUse() || !(_count > 1 || _period > 0)) setInUse(false);
      stopEffectTask();
      if (_effectorObject != null) _effectorObject.onEffectFinished(_effected, getSkill());
    }
  }
Exemplo n.º 3
0
  public void removeMember(L2PcInstance member, boolean oust) {
    // the last member (leader) cannot be removed
    if (getMemberCount() == 1 || !getMembers().remove(member)) return;

    member.setPartyRoom(null);
    member.sendPacket(ExClosePartyRoom.STATIC_PACKET);
    if (oust) member.sendPacket(SystemMessageId.OUSTED_FROM_PARTY_ROOM);
    else member.sendPacket(SystemMessageId.PARTY_ROOM_EXITED);

    SystemMessage sm;
    if (oust) sm = new SystemMessage(SystemMessageId.S1_KICKED_FROM_PARTY_ROOM);
    else sm = new SystemMessage(SystemMessageId.S1_LEFT_PARTY_ROOM);
    sm.addPcName(member);
    broadcastPacket(new ExManagePartyRoomMember(ExManagePartyRoomMember.REMOVED, member));
    broadcastPacket(sm);
    updateRoomStatus(false);
  }