Exemplo n.º 1
0
 public void removeOwner(boolean updateDB) {
   L2Clan clan = getOwnerClan();
   if (clan != null) {
     for (L2PcInstance member : clan.getOnlineMembers(0)) {
       removeResidentialSkills(member);
       member.sendSkillList();
     }
     clan.setFortId(0);
     clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
     setOwnerClan(null);
     setSupplyLvL(0);
     saveFortVariables();
     removeAllFunctions();
     if (updateDB) {
       updateOwnerInDB();
     }
   }
 }
Exemplo n.º 2
0
  /**
   * This method will set owner for Fort
   *
   * @param clan
   * @param updateClansReputation
   * @return
   */
  public boolean setOwner(L2Clan clan, boolean updateClansReputation) {
    if (clan == null) {
      _log.warning(getClass().getSimpleName() + ": Updating Fort owner with null clan!!!");
      return false;
    }

    final SystemMessage sm =
        SystemMessage.getSystemMessage(SystemMessageId.THE_FORTRESS_BATTLE_OF_S1_HAS_FINISHED);
    sm.addCastleId(getResidenceId());
    getSiege().announceToPlayer(sm);

    final L2Clan oldowner = getOwnerClan();
    if ((oldowner != null) && (clan != oldowner)) {
      // Remove points from old owner
      updateClansReputation(oldowner, true);
      try {
        L2PcInstance oldleader = oldowner.getLeader().getPlayerInstance();
        if (oldleader != null) {
          if (oldleader.getMountType() == MountType.WYVERN) {
            oldleader.dismount();
          }
        }
      } catch (Exception e) {
        _log.log(Level.WARNING, "Exception in setOwner: " + e.getMessage(), e);
      }
      removeOwner(true);
    }
    setFortState(0, 0); // initialize fort state

    // if clan already have castle, don't store him in fortress
    if (clan.getCastleId() > 0) {
      getSiege()
          .announceToPlayer(
              SystemMessage.getSystemMessage(
                  SystemMessageId.THE_REBEL_ARMY_RECAPTURED_THE_FORTRESS));
      return false;
    }

    // Give points to new owner
    if (updateClansReputation) {
      updateClansReputation(clan, false);
    }

    spawnSpecialEnvoys();
    // if clan have already fortress, remove it
    if (clan.getFortId() > 0) {
      FortManager.getInstance().getFortByOwner(clan).removeOwner(true);
    }

    setSupplyLvL(0);
    setOwnerClan(clan);
    updateOwnerInDB(); // Update in database
    saveFortVariables();

    if (getSiege().isInProgress()) {
      getSiege().endSiege();
    }

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