示例#1
0
 public void run() {
   try {
     if (_isFree) return;
     L2Clan Clan = getOwnerClan();
     if (getOwnerClan().getWarehouse().getAdena() >= getLease()) {
       if (_paidUntil != 0) {
         while (_paidUntil < System.currentTimeMillis()) _paidUntil += _chRate;
       } else _paidUntil = System.currentTimeMillis() + _chRate;
       _paidDayTime = _paidUntil;
       getOwnerClan()
           .getWarehouse()
           .destroyItemByItemId("CH_rental_fee", 57, getLease(), null, null);
       if (_log.isDebugEnabled() || Config.DEBUG)
         _log.warn(
             "deducted "
                 + getLease()
                 + " adena from "
                 + getName()
                 + " owner's cwh for ClanHall _paidUntil"
                 + _paidUntil);
       ThreadPoolManager.getInstance()
           .scheduleGeneral(new FeeTask(), _paidUntil - System.currentTimeMillis());
       _paid = true;
       updateDb();
     } else {
       _paid = false;
       if (System.currentTimeMillis() > _paidUntil + _chRate) {
         if (ClanHallManager.loaded()) {
           AuctionManager.getInstance().initNPC(getId());
           ClanHallManager.getInstance().setFree(getId());
           Clan.broadcastToOnlineMembers(
               new SystemMessage(
                   SystemMessageId
                       .THE_CLAN_HALL_FEE_IS_ONE_WEEK_OVERDUE_THEREFORE_THE_CLAN_HALL_OWNERSHIP_HAS_BEEN_REVOKED));
           _log.info(
               "ClanHall: "
                   + getName()
                   + " set to FREE. Old Clan owner : "
                   + Clan.getName()
                   + ". Adena count in CWH : "
                   + Clan.getWarehouse().getAdena());
         } else ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), 3000);
       } else {
         SystemMessage sm =
             new SystemMessage(
                 SystemMessageId
                     .PAYMENT_FOR_YOUR_CLAN_HALL_HAS_NOT_BEEN_MADE_PLEASE_MAKE_PAYMENT_TO_YOUR_CLAN_WAREHOUSE_BY_TOMORROW);
         Clan.broadcastToOnlineMembers(sm);
         if (System.currentTimeMillis() + (1000 * 60 * 60 * 24) <= _paidUntil + _chRate)
           _paidDayTime = System.currentTimeMillis() + (1000 * 60 * 60 * 24);
         else _paidDayTime = _paidUntil + _chRate;
         ThreadPoolManager.getInstance()
             .scheduleGeneral(new FeeTask(), _paidDayTime - System.currentTimeMillis());
         updateDb();
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#2
0
文件: Fort.java 项目: rean1m5/lucera2
  /**
   * This method will set owner for Fort
   *
   * @param clan
   * @param updateClanPoints
   */
  public boolean setOwner(L2Clan clan, boolean updateClansReputation) {
    ClanHall hall = ClanHallManager.getInstance().getClanHallByOwner(clan);
    if (hall != null) {
      clan.broadcastToOnlineMembers(
          new SystemMessage(SystemMessageId.S1)
              .addString("Вы потеряли ваш кланхолл " + hall.getName()));
      ClanHallManager.getInstance().setFree(hall.getId());
      AuctionManager.getInstance().initNPC(hall.getId());
    }
    if (clan.getAuctionBiddedAt() > 0) {
      Auction a = AuctionManager.getInstance().getAuction(clan.getAuctionBiddedAt());
      if (a != null) {
        a.cancelAuction();
        clan.broadcastToOnlineMembers(
            new SystemMessage(SystemMessageId.S1).addString("Ваше участие в аукционе отменено"));
      }
    }

    if (updateClansReputation) updateClansReputation(clan, false); // update reputation first

    for (L2PcInstance member : clan.getOnlineMembers(0)) {
      giveResidentialSkills(member);
      member.sendSkillList();
    }

    // Remove old owner
    if (getOwnerClan() != null && (clan != null && clan != getOwnerClan())) {
      updateClansReputation(clan, true);
      L2PcInstance oldLord = getOwnerClan().getLeader().getPlayerInstance();
      if (oldLord != null && oldLord.getMountType() == 2) oldLord.dismount();
      removeOwner(true);
    }
    setFortState(0, 0); // initialize fort state
    //	if clan already have castle, don't store him in fortress
    if (clan.getHasCastle() > 0) {
      getSiege()
          .announceToPlayer(
              new SystemMessage(SystemMessageId.S1).addString("Форт снова пренадлежит NPC"),
              0,
              false);
      return false;
    } else {
      getSpawnManager().spawnSpecialEnvoys();
      ThreadPoolManager.getInstance()
          .scheduleGeneral(
              new ScheduleSpecialEnvoysDeSpawn(this),
              1 * 60 * 60 * 1000); // Prepare 1hr task for special envoys despawn
      // if clan have already fortress, remove it
      if (clan.getHasFort() > 0) FortManager.getInstance().getFortByOwner(clan).removeOwner(true);

      setOwnerClan(clan);
      _ownerId = clan.getClanId();
      updateOwnerInDB(); // Update in database

      if (getSiege().getIsInProgress()) { // If siege in progress
        if (Config.FORTSIEGE_REWARD_ID > 0) {
          clan.getWarehouse()
              .addItem(
                  "Siege", Config.FORTSIEGE_REWARD_ID, Config.FORTSIEGE_REWARD_COUNT, null, null);
          if (clan.getLeader().getPlayerInstance() != null)
            clan.getLeader()
                .getPlayerInstance()
                .sendMessage(
                    "Your clan obtain "
                        + Config.FORTSIEGE_REWARD_COUNT
                        + " "
                        + ItemTable.getInstance().getItemName(Config.FORTSIEGE_REWARD_ID));
        }

        getSiege().endSiege();
      }
      return true;
    }
  }