public void removeOwner(boolean updateDB) { setFortState(0, 0); L2Clan clan = getOwnerClan(); if (clan != null) { for (L2PcInstance member : clan.getOnlineMembers(0)) { removeResidentialSkills(member); member.sendSkillList(); } clan.setHasFort(0); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); setOwnerClan(null); if (updateDB) updateOwnerInDB(); } }
/** * 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; } }